Files
nairobi/app/components/budgets/map_component.rb
Javi Martín 69ae2d31ee Extract component to render the budget map
We're going to make a change, and it's easier if we've already got a
component with tests so we don't have to write system tests to check
whether the map is rendered.
2022-05-02 20:25:25 +02:00

27 lines
550 B
Ruby

class Budgets::MapComponent < ApplicationComponent
delegate :render_map, to: :helpers
attr_reader :budget
def initialize(budget)
@budget = budget
end
def render?
!budget.informing?
end
private
def coordinates
return unless budget.present?
if budget.publishing_prices_or_later? && budget.investments.selected.any?
investments = budget.investments.selected
else
investments = budget.investments
end
MapLocation.where(investment_id: investments).map(&:json_data)
end
end