Merge pull request #5390 Geozone Admin maps

This makes it easier to see if Geojson has been imported correctly.
This commit is contained in:
coslajohn
2024-03-21 17:47:37 +00:00
committed by GitHub
parent 82c24a7ef3
commit 529357c980
5 changed files with 35 additions and 0 deletions

View File

@@ -29,3 +29,10 @@
<% end %>
</tbody>
</table>
<section>
<h3><%= t("admin.geozones.index.geojson_map") %></h3>
<p class="help-text"><%= t("admin.geozones.index.geojson_map_help") %></p>
<%= render Shared::MapLocationComponent.new(nil, geozones_data: geozones_data) %>
</section>

View File

@@ -19,4 +19,14 @@ class Admin::Geozones::IndexComponent < ApplicationComponent
t("shared.no")
end
end
def geozones_data
geozones.map do |geozone|
{
outline_points: geozone.outline_points,
color: geozone.color,
headings: [link_to(geozone.name, edit_admin_geozone_path(geozone))]
}
end
end
end

View File

@@ -1400,6 +1400,8 @@ en:
index:
title: Geozone
create: Create geozone
geojson_map: GeoJSON Map
geojson_map_help: "If GeoJSON coordinates are available they will be displayed on the map below"
geozone:
name: Name
external_code: External code

View File

@@ -1400,6 +1400,8 @@ es:
index:
title: Zonas
create: Crear una zona
geojson_map: Mapa GeoJSON
geojson_map_help: "Si las coordenadas GeoJSON están disponibles, aparecerán en el siguiente mapa"
geozone:
name: Nombre
external_code: Código externo

View File

@@ -142,4 +142,18 @@ describe "Admin geozones", :admin do
expect(page).to have_link "Area 51", href: budget_investments_path(budget, heading_id: heading.id)
end
end
scenario "Show polygons on geozone admin view" do
Setting["feature.map"] = true
geojson = '{ "geometry": { "type": "Polygon", "coordinates": [[-0.1,51.5],[-0.2,51.4],[-0.3,51.6]] } }'
geozone = create(:geozone, name: "Polygon me!", geojson: geojson)
visit admin_geozones_path
find(".map-polygon").click
within ".map-location" do
expect(page).to have_link "Polygon me!", href: edit_admin_geozone_path(geozone)
end
end
end