Note that in the budgets wizard test we now create district with no associated geozone, so the text "all city" will appear in the districts table too, meaning we can't use `within "section", text: "All city" do` anymore since it would result in an ambiguous match. Co-Authored-By: Julian Herrero <microweb10@gmail.com> Co-Authored-By: Javi Martín <javim@elretirao.net>
37 lines
894 B
Ruby
37 lines
894 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
|
|
|
|
def geozones_data
|
|
budget.geozones.map do |geozone|
|
|
{
|
|
outline_points: geozone.outline_points,
|
|
color: geozone.color,
|
|
headings: budget.headings.where(geozone: geozone).map do |heading|
|
|
link_to heading.name, budget_investments_path(budget, heading_id: heading.id)
|
|
end
|
|
}
|
|
end
|
|
end
|
|
end
|