By using the bindPopup function instead of the click event popups work when using the keyboard. Note that now we are loading all the map markers in the first request in a single query to the database (needed when there is a lot or markers to show). Because of that we removed the AJAX endpoint.
37 lines
878 B
Ruby
37 lines
878 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.investments_json_data(investments)
|
|
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
|