Added layer control to map to allow each geozone display to be toggled on/off

Note we're adding a `name` property to the geozones investments sidebar
map even if we don't render the geozones in the map, in order to
simplify the JavaScript function `geozoneLayers`.
This commit is contained in:
CoslaJohn
2024-08-07 14:14:34 +01:00
committed by Javi Martín
parent cb8b0ad6ff
commit 624e60eab9
5 changed files with 81 additions and 12 deletions

View File

@@ -25,7 +25,8 @@ class Admin::Geozones::IndexComponent < ApplicationComponent
{
outline_points: geozone.outline_points,
color: geozone.color,
headings: [link_to(geozone.name, edit_admin_geozone_path(geozone))]
headings: [link_to(geozone.name, edit_admin_geozone_path(geozone))],
name: geozone.name
}
end
end

View File

@@ -27,7 +27,8 @@ class Budgets::Investments::MapComponent < ApplicationComponent
[
{
outline_points: heading.geozone.outline_points,
color: heading.geozone.color
color: heading.geozone.color,
name: heading.name
}
]
end

View File

@@ -27,10 +27,15 @@ class Budgets::MapComponent < ApplicationComponent
{
outline_points: geozone.outline_points,
color: geozone.color,
headings: budget.headings.where(geozone: geozone).map do |heading|
headings: geozone_headings(geozone).map do |heading|
link_to heading.name, budget_investments_path(budget, heading_id: heading.id)
end
end,
name: geozone_headings(geozone).map(&:name).join(", ")
}
end
end
def geozone_headings(geozone)
budget.headings.where(geozone: geozone)
end
end