This check isn't necessary since commit 7e3dd47d5, since now we check
that the budget is present before creating the components which call
this method.
25 lines
531 B
Ruby
25 lines
531 B
Ruby
class Budgets::MapComponent < ApplicationComponent
|
|
delegate :render_map, to: :helpers
|
|
attr_reader :budget
|
|
|
|
def initialize(budget)
|
|
@budget = budget
|
|
end
|
|
|
|
def render?
|
|
feature?(:map) && !budget.informing?
|
|
end
|
|
|
|
private
|
|
|
|
def coordinates
|
|
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
|