diff --git a/app/assets/javascripts/forms.js b/app/assets/javascripts/forms.js
index 0a2dfe107..23f2b4c83 100644
--- a/app/assets/javascripts/forms.js
+++ b/app/assets/javascripts/forms.js
@@ -27,11 +27,12 @@
});
},
synchronizeInputs: function() {
- var banners, inputs, processes, progress_bar;
+ var banners, geozones, inputs, processes, progress_bar;
progress_bar = "[name='progress_bar[percentage]']";
processes = "[name='legislation_process[background_color]'], [name='legislation_process[font_color]']";
banners = "[name='banner[background_color]'], [name='banner[font_color]']";
- inputs = $(progress_bar + ", " + processes + ", " + banners);
+ geozones = "[name='geozone[color]']";
+ inputs = $(progress_bar + ", " + processes + ", " + banners + ", " + geozones);
inputs.on({
input: function() {
$("[name='" + this.name + "']").val($(this).val());
diff --git a/app/assets/javascripts/map.js b/app/assets/javascripts/map.js
index 80a8c6af6..4b2e4a5a2 100644
--- a/app/assets/javascripts/map.js
+++ b/app/assets/javascripts/map.js
@@ -78,6 +78,7 @@
}
App.Map.addInvestmentsMarkers(investmentsMarkers, createMarker);
+ App.Map.addGeozones(map);
},
leafletMap: function(element) {
var centerData, mapCenterLatLng;
@@ -194,6 +195,28 @@
map.attributionControl.setPrefix(App.Map.attributionPrefix());
L.tileLayer(mapTilesProvider, { attribution: mapAttribution }).addTo(map);
},
+ addGeozones: function(map) {
+ var geozones = $(map._container).data("geozones");
+
+ if (geozones) {
+ geozones.forEach(function(geozone) {
+ App.Map.addGeozone(geozone, map);
+ });
+ }
+ },
+ addGeozone: function(geozone, map) {
+ var polygon = L.polygon(geozone.outline_points, {
+ color: geozone.color,
+ fillOpacity: 0.3,
+ className: "map-polygon"
+ });
+
+ if (geozone.headings !== undefined) {
+ polygon.bindPopup(geozone.headings.join("
"));
+ }
+
+ polygon.addTo(map);
+ },
openMarkerPopup: function(e) {
var marker = e.target;
$.ajax("/investments/" + marker.options.id + "/json_data", {
diff --git a/app/views/admin/budget_headings/_form.html.erb b/app/components/admin/budget_headings/form_component.html.erb
similarity index 84%
rename from app/views/admin/budget_headings/_form.html.erb
rename to app/components/admin/budget_headings/form_component.html.erb
index c51d55f18..af488f177 100644
--- a/app/views/admin/budget_headings/_form.html.erb
+++ b/app/components/admin/budget_headings/form_component.html.erb
@@ -12,12 +12,19 @@
<% end %>
- <% if @budget.show_money? %>
+ <% if budget.show_money? %>
<%= f.text_field :price, maxlength: 8 %>
<% else %>
<%= f.hidden_field :price, value: 0 %>
<% end %>
+ <% if feature?(:map) %>
+ <%= f.select :geozone_id,
+ geozone_options,
+ include_blank: t("geozones.none"),
+ hint: t("admin.budget_headings.form.geozone_info") %>
+ <% end %>
+
<% if heading.budget.approval_voting? %>
<%= f.number_field :max_ballot_lines,
hint: t("admin.budget_headings.form.max_ballot_lines_info") %>
@@ -41,7 +48,7 @@
- <% if respond_to?(:single_heading?) && single_heading? %>
+ <% if single_heading? %>
<%= f.submit t("admin.budgets_wizard.headings.continue"), class: "button success" %>
<% else %>
<%= f.submit t("admin.budget_headings.form.#{action}"), class: "button hollow" %>
diff --git a/app/components/admin/budget_headings/form_component.rb b/app/components/admin/budget_headings/form_component.rb
new file mode 100644
index 000000000..16dd3cbfd
--- /dev/null
+++ b/app/components/admin/budget_headings/form_component.rb
@@ -0,0 +1,25 @@
+class Admin::BudgetHeadings::FormComponent < ApplicationComponent
+ include TranslatableFormHelper
+ include GlobalizeHelper
+ attr_reader :heading, :path, :action
+
+ def initialize(heading, path:, action:)
+ @heading = heading
+ @path = path
+ @action = action
+ end
+
+ private
+
+ def budget
+ heading.budget
+ end
+
+ def single_heading?
+ helpers.respond_to?(:single_heading?) && helpers.single_heading?
+ end
+
+ def geozone_options
+ Geozone.all.map { |geozone| [geozone.name, geozone.id] }
+ end
+end
diff --git a/app/components/admin/budget_headings/headings_component.html.erb b/app/components/admin/budget_headings/headings_component.html.erb
index d8ba48040..93f42a88f 100644
--- a/app/components/admin/budget_headings/headings_component.html.erb
+++ b/app/components/admin/budget_headings/headings_component.html.erb
@@ -5,11 +5,12 @@
| <%= Budget::Heading.human_attribute_name(:name) %> |
<% if budget.show_money? %>
- <%= Budget::Heading.human_attribute_name(:price) %> |
+ <%= Budget::Heading.human_attribute_name(:price) %> |
<% end %>
<% if budget.approval_voting? %>
<%= Budget::Heading.human_attribute_name(:max_ballot_lines) %> |
<% end %>
+ <%= Budget::Heading.human_attribute_name(:geozone_id) %> |
<%= t("admin.actions.actions") %> |
@@ -23,6 +24,9 @@
<% if budget.approval_voting? %>
<%= heading.max_ballot_lines %> |
<% end %>
+
+ <%= geozone_for(heading) %>
+ |
<%= render Admin::TableActionsComponent.new(heading) %>
|
diff --git a/app/components/admin/budget_headings/headings_component.rb b/app/components/admin/budget_headings/headings_component.rb
index 396944392..ea2c251ca 100644
--- a/app/components/admin/budget_headings/headings_component.rb
+++ b/app/components/admin/budget_headings/headings_component.rb
@@ -14,4 +14,12 @@ class Admin::BudgetHeadings::HeadingsComponent < ApplicationComponent
def budget
@budget ||= group.budget
end
+
+ def geozone_for(heading)
+ if heading.geozone
+ link_to heading.geozone.name, edit_admin_geozone_path(heading.geozone)
+ else
+ t("geozones.none")
+ end
+ end
end
diff --git a/app/components/admin/budgets_wizard/headings/creation_step_component.html.erb b/app/components/admin/budgets_wizard/headings/creation_step_component.html.erb
index a8ca3d7b4..236eeaf6d 100644
--- a/app/components/admin/budgets_wizard/headings/creation_step_component.html.erb
+++ b/app/components/admin/budgets_wizard/headings/creation_step_component.html.erb
@@ -1,3 +1,3 @@
<%= render Admin::BudgetsWizard::CreationStepComponent.new(heading, next_step_path) do %>
- <%= render "/admin/budget_headings/form", heading: heading, path: form_path, action: "create" %>
+ <%= render Admin::BudgetHeadings::FormComponent.new(heading, path: form_path, action: "create") %>
<% end %>
diff --git a/app/components/admin/budgets_wizard/headings/edit_component.html.erb b/app/components/admin/budgets_wizard/headings/edit_component.html.erb
index 5a269b582..2ee8c913e 100644
--- a/app/components/admin/budgets_wizard/headings/edit_component.html.erb
+++ b/app/components/admin/budgets_wizard/headings/edit_component.html.erb
@@ -4,4 +4,4 @@
<%= render Admin::BudgetsWizard::CreationTimelineComponent.new("headings") %>
-<%= render "/admin/budget_headings/form", heading: heading, path: form_path, action: "submit" %>
+<%= render Admin::BudgetHeadings::FormComponent.new(heading, path: form_path, action: "submit") %>
diff --git a/app/components/admin/geozones/form_component.html.erb b/app/components/admin/geozones/form_component.html.erb
new file mode 100644
index 000000000..7d55ecf00
--- /dev/null
+++ b/app/components/admin/geozones/form_component.html.erb
@@ -0,0 +1,46 @@
+<%= form_for [:admin, geozone] do |f| %>
+
+ <%= render "shared/errors", resource: geozone %>
+
+
+ <%= f.text_field :name %>
+
+
+
+
+ <%= f.text_field :census_code, hint: t("admin.geozones.geozone.code_help") %>
+
+
+
+ <%= f.text_field :external_code, hint: t("admin.geozones.geozone.code_help") %>
+
+
+
+
+ <%= f.text_field :html_map_coordinates, hint: t("admin.geozones.geozone.coordinates_help") %>
+
+
+
+ <%= f.text_area :geojson, rows: "10", hint: t("admin.geozones.geozone.geojson_help") %>
+
+
+
+ <%= f.label :color, nil, for: "color_input", id: "color_input_label" %>
+
+ <%= t("admin.geozones.geozone.color_help", format_help: t("admin.shared.color_help")) %>
+
+
+
+ <%= f.text_field :color, label: false, type: :color %>
+
+
+ <%= f.text_field :color, label: false, id: "color_input" %>
+
+
+
+
+
+ <%= f.submit(value: t("admin.geozones.edit.form.submit_button"),
+ class: "button success") %>
+
+<% end %>
diff --git a/app/components/admin/geozones/form_component.rb b/app/components/admin/geozones/form_component.rb
new file mode 100644
index 000000000..9f3ace2ca
--- /dev/null
+++ b/app/components/admin/geozones/form_component.rb
@@ -0,0 +1,7 @@
+class Admin::Geozones::FormComponent < ApplicationComponent
+ attr_reader :geozone
+
+ def initialize(geozone)
+ @geozone = geozone
+ end
+end
diff --git a/app/components/admin/geozones/index_component.html.erb b/app/components/admin/geozones/index_component.html.erb
new file mode 100644
index 000000000..74aeca62d
--- /dev/null
+++ b/app/components/admin/geozones/index_component.html.erb
@@ -0,0 +1,31 @@
+<%= header do %>
+ <%= link_to t("admin.geozones.index.create"), new_admin_geozone_path %>
+<% end %>
+
+
+
+
+ | <%= t("admin.geozones.geozone.name") %> |
+ <%= t("admin.geozones.geozone.external_code") %> |
+ <%= t("admin.geozones.geozone.census_code") %> |
+ <%= t("admin.geozones.geozone.coordinates") %> |
+ <%= t("admin.geozones.geozone.geojson") %> |
+ <%= t("admin.actions.actions") %> |
+
+
+
+
+ <% geozones.each do |geozone| %>
+
+ | <%= geozone.name %> |
+ <%= geozone.external_code %> |
+ <%= geozone.census_code %> |
+ <%= yes_no_text(geozone.html_map_coordinates.present?) %> |
+ <%= yes_no_text(geozone.geojson.present?) %> |
+
+ <%= render Admin::TableActionsComponent.new(geozone) %>
+ |
+
+ <% end %>
+
+
diff --git a/app/components/admin/geozones/index_component.rb b/app/components/admin/geozones/index_component.rb
new file mode 100644
index 000000000..d9cee9e84
--- /dev/null
+++ b/app/components/admin/geozones/index_component.rb
@@ -0,0 +1,22 @@
+class Admin::Geozones::IndexComponent < ApplicationComponent
+ include Header
+ attr_reader :geozones
+
+ def initialize(geozones)
+ @geozones = geozones
+ end
+
+ private
+
+ def title
+ t("admin.geozones.index.title")
+ end
+
+ def yes_no_text(condition)
+ if condition
+ t("shared.yes")
+ else
+ t("shared.no")
+ end
+ end
+end
diff --git a/app/components/budgets/investments/map_component.html.erb b/app/components/budgets/investments/map_component.html.erb
new file mode 100644
index 000000000..7e2d99ebb
--- /dev/null
+++ b/app/components/budgets/investments/map_component.html.erb
@@ -0,0 +1,3 @@
+
+ <%= render_map(map_location, investments_coordinates: coordinates, geozones_data: geozones_data) %>
+
diff --git a/app/components/budgets/investments/map_component.rb b/app/components/budgets/investments/map_component.rb
new file mode 100644
index 000000000..897524ca2
--- /dev/null
+++ b/app/components/budgets/investments/map_component.rb
@@ -0,0 +1,34 @@
+class Budgets::Investments::MapComponent < ApplicationComponent
+ attr_reader :heading, :investments
+ delegate :render_map, to: :helpers
+
+ def initialize(investments, heading:)
+ @investments = investments
+ @heading = heading
+ end
+
+ def render?
+ map_location&.available?
+ end
+
+ private
+
+ def map_location
+ MapLocation.from_heading(heading) if heading.present?
+ end
+
+ def coordinates
+ MapLocation.where(investment: investments).map(&:json_data)
+ end
+
+ def geozones_data
+ return unless heading.geozone.present?
+
+ [
+ {
+ outline_points: heading.geozone.outline_points,
+ color: heading.geozone.color
+ }
+ ]
+ end
+end
diff --git a/app/components/budgets/map_component.html.erb b/app/components/budgets/map_component.html.erb
index fa2284472..33aea81a7 100644
--- a/app/components/budgets/map_component.html.erb
+++ b/app/components/budgets/map_component.html.erb
@@ -1,4 +1,4 @@
-
+
<%= t("budgets.index.map") %>
- <%= render_map(nil, investments_coordinates: coordinates) %>
+ <%= render_map(nil, investments_coordinates: coordinates, geozones_data: geozones_data) %>
diff --git a/app/components/budgets/map_component.rb b/app/components/budgets/map_component.rb
index 1da16c137..dcbc427d6 100644
--- a/app/components/budgets/map_component.rb
+++ b/app/components/budgets/map_component.rb
@@ -13,8 +13,6 @@ class Budgets::MapComponent < ApplicationComponent
private
def coordinates
- return unless budget.present?
-
if budget.publishing_prices_or_later? && budget.investments.selected.any?
investments = budget.investments.selected
else
@@ -23,4 +21,16 @@ class Budgets::MapComponent < ApplicationComponent
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
diff --git a/app/components/shared/map_location_component.rb b/app/components/shared/map_location_component.rb
index 69371228b..e82f1f8a1 100644
--- a/app/components/shared/map_location_component.rb
+++ b/app/components/shared/map_location_component.rb
@@ -1,10 +1,11 @@
class Shared::MapLocationComponent < ApplicationComponent
- attr_reader :investments_coordinates, :form
+ attr_reader :investments_coordinates, :form, :geozones_data
- def initialize(map_location, investments_coordinates: nil, form: nil)
+ def initialize(map_location, investments_coordinates: nil, form: nil, geozones_data: nil)
@map_location = map_location
@investments_coordinates = investments_coordinates
@form = form
+ @geozones_data = geozones_data
end
def map_location
@@ -56,7 +57,8 @@ class Shared::MapLocationComponent < ApplicationComponent
marker_remove_selector: "##{remove_marker_id}",
marker_investments_coordinates: investments_coordinates,
marker_latitude: map_location.latitude.presence,
- marker_longitude: map_location.longitude.presence
+ marker_longitude: map_location.longitude.presence,
+ geozones: geozones_data
}.merge(input_selectors)
end
diff --git a/app/controllers/admin/geozones_controller.rb b/app/controllers/admin/geozones_controller.rb
index 930d2877d..794a5985f 100644
--- a/app/controllers/admin/geozones_controller.rb
+++ b/app/controllers/admin/geozones_controller.rb
@@ -17,7 +17,7 @@ class Admin::GeozonesController < Admin::BaseController
@geozone = Geozone.new(geozone_params)
if @geozone.save
- redirect_to admin_geozones_path
+ redirect_to admin_geozones_path, notice: t("admin.geozones.create.notice")
else
render :new
end
@@ -25,7 +25,7 @@ class Admin::GeozonesController < Admin::BaseController
def update
if @geozone.update(geozone_params)
- redirect_to admin_geozones_path
+ redirect_to admin_geozones_path, notice: t("admin.geozones.update.notice")
else
render :edit
end
@@ -47,6 +47,6 @@ class Admin::GeozonesController < Admin::BaseController
end
def allowed_params
- [:name, :external_code, :census_code, :html_map_coordinates]
+ [:name, :external_code, :census_code, :html_map_coordinates, :geojson, :color]
end
end
diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb
index ca9a18d0c..84277042f 100644
--- a/app/controllers/budgets/investments_controller.rb
+++ b/app/controllers/budgets/investments_controller.rb
@@ -20,7 +20,6 @@ module Budgets
before_action :load_ballot, only: [:index, :show]
before_action :load_heading, only: [:index, :show]
- before_action :load_map, only: [:index]
before_action :set_random_seed, only: :index
before_action :load_categories, only: :index
before_action :set_default_investment_filter, only: :index
@@ -41,10 +40,9 @@ module Budgets
def index
@investments = investments.page(params[:page]).per(PER_PAGE).for_render
-
@investment_ids = @investments.ids
- @investments_map_coordinates = MapLocation.where(investment: investments).map(&:json_data)
+ @investments_in_map = investments
@tag_cloud = tag_cloud
@remote_translations = detect_remote_translations(@investments)
end
@@ -179,9 +177,5 @@ module Budgets
params[:filter] ||= "selected"
end
end
-
- def load_map
- @map_location = MapLocation.from_heading(@heading) if @heading.present?
- end
end
end
diff --git a/app/controllers/concerns/admin/budget_headings_actions.rb b/app/controllers/concerns/admin/budget_headings_actions.rb
index 202aa5ff1..1a1db8314 100644
--- a/app/controllers/concerns/admin/budget_headings_actions.rb
+++ b/app/controllers/concerns/admin/budget_headings_actions.rb
@@ -59,7 +59,7 @@ module Admin::BudgetHeadingsActions
end
def allowed_params
- valid_attributes = [:price, :population, :allow_custom_content, :latitude, :longitude, :max_ballot_lines]
+ valid_attributes = [:price, :population, :allow_custom_content, :latitude, :longitude, :max_ballot_lines, :geozone_id]
[*valid_attributes, translation_params(Budget::Heading)]
end
diff --git a/app/models/budget.rb b/app/models/budget.rb
index 6cbe93b0d..4fc250bf4 100644
--- a/app/models/budget.rb
+++ b/app/models/budget.rb
@@ -34,6 +34,7 @@ class Budget < ApplicationRecord
has_many :ballots, dependent: :destroy
has_many :groups, dependent: :destroy
has_many :headings, through: :groups
+ has_many :geozones, through: :headings
has_many :lines, through: :ballots, class_name: "Budget::Ballot::Line"
has_many :phases, class_name: "Budget::Phase"
has_many :budget_administrators, dependent: :destroy
diff --git a/app/models/budget/heading.rb b/app/models/budget/heading.rb
index 94c61511e..7b8fbde57 100644
--- a/app/models/budget/heading.rb
+++ b/app/models/budget/heading.rb
@@ -22,6 +22,7 @@ class Budget
end
belongs_to :group
+ belongs_to :geozone
has_many :investments
has_many :content_blocks
diff --git a/app/models/concerns/geojson_format_validator.rb b/app/models/concerns/geojson_format_validator.rb
new file mode 100644
index 000000000..e2a88f0e8
--- /dev/null
+++ b/app/models/concerns/geojson_format_validator.rb
@@ -0,0 +1,23 @@
+class GeojsonFormatValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ if value.present?
+ geojson = parse_json(value)
+
+ unless geojson?(geojson)
+ record.errors.add(attribute, :invalid)
+ end
+ end
+ end
+
+ private
+
+ def parse_json(geojson_data)
+ JSON.parse(geojson_data) rescue nil
+ end
+
+ def geojson?(geojson)
+ return false unless geojson.is_a?(Hash)
+
+ geojson.dig("geometry", "coordinates").is_a?(Array)
+ end
+end
diff --git a/app/models/geozone.rb b/app/models/geozone.rb
index 57b5e6cb4..be2930ca8 100644
--- a/app/models/geozone.rb
+++ b/app/models/geozone.rb
@@ -4,7 +4,9 @@ class Geozone < ApplicationRecord
has_many :proposals
has_many :debates
has_many :users
+ has_many :headings, class_name: "Budget::Heading", dependent: :nullify
validates :name, presence: true
+ validates :geojson, geojson_format: true
scope :public_for_api, -> { all }
@@ -17,4 +19,28 @@ class Geozone < ApplicationRecord
association.klass.where(geozone: self).empty?
end
end
+
+ def outline_points
+ normalized_coordinates.map { |longlat| [longlat.last, longlat.first] }
+ end
+
+ private
+
+ def normalized_coordinates
+ if geojson.present?
+ if geojson.match(/"coordinates"\s*:\s*\[{4}/)
+ coordinates.reduce([], :concat).reduce([], :concat)
+ elsif geojson.match(/"coordinates"\s*:\s*\[{3}/)
+ coordinates.reduce([], :concat)
+ else
+ coordinates
+ end
+ else
+ []
+ end
+ end
+
+ def coordinates
+ JSON.parse(geojson)["geometry"]["coordinates"]
+ end
end
diff --git a/app/views/admin/budget_headings/edit.html.erb b/app/views/admin/budget_headings/edit.html.erb
index 2102d8e3c..4127240dc 100644
--- a/app/views/admin/budget_headings/edit.html.erb
+++ b/app/views/admin/budget_headings/edit.html.erb
@@ -1,3 +1,7 @@
<%= render "header", action: "edit" %>
-<%= render "form", heading: @heading, path: admin_budget_group_heading_path(@budget, @group, @heading), action: "submit" %>
+<%= render Admin::BudgetHeadings::FormComponent.new(
+ @heading,
+ path: admin_budget_group_heading_path(@budget, @group, @heading),
+ action: "submit"
+) %>
diff --git a/app/views/admin/budget_headings/new.html.erb b/app/views/admin/budget_headings/new.html.erb
index 3e1810fbc..ecce0ba3a 100644
--- a/app/views/admin/budget_headings/new.html.erb
+++ b/app/views/admin/budget_headings/new.html.erb
@@ -1,3 +1,7 @@
<%= render "header", action: "create" %>
-<%= render "form", heading: @heading, path: admin_budget_group_headings_path(@budget, @group), action: "create" %>
+<%= render Admin::BudgetHeadings::FormComponent.new(
+ @heading,
+ path: admin_budget_group_headings_path(@budget, @group),
+ action: "create"
+) %>
diff --git a/app/views/admin/geozones/_form.html.erb b/app/views/admin/geozones/_form.html.erb
deleted file mode 100644
index 97eaed50e..000000000
--- a/app/views/admin/geozones/_form.html.erb
+++ /dev/null
@@ -1,27 +0,0 @@
-<%= form_for [:admin, @geozone] do |f| %>
-
- <%= render "shared/errors", resource: @geozone %>
-
-
- <%= f.text_field :name %>
-
-
-
-
- <%= f.text_field :census_code, hint: t("admin.geozones.geozone.code_help") %>
-
-
-
- <%= f.text_field :external_code, hint: t("admin.geozones.geozone.code_help") %>
-
-
-
-
- <%= f.text_field :html_map_coordinates, hint: t("admin.geozones.geozone.coordinates_help") %>
-
-
-
- <%= f.submit(value: t("admin.geozones.edit.form.submit_button"),
- class: "button success") %>
-
-<% end %>
diff --git a/app/views/admin/geozones/edit.html.erb b/app/views/admin/geozones/edit.html.erb
index 107ef505d..500a03ddd 100644
--- a/app/views/admin/geozones/edit.html.erb
+++ b/app/views/admin/geozones/edit.html.erb
@@ -4,4 +4,4 @@
<%= t("admin.geozones.edit.editing") %>
-<%= render "form" %>
+<%= render Admin::Geozones::FormComponent.new(@geozone) %>
diff --git a/app/views/admin/geozones/index.html.erb b/app/views/admin/geozones/index.html.erb
index c8dabf366..105224725 100644
--- a/app/views/admin/geozones/index.html.erb
+++ b/app/views/admin/geozones/index.html.erb
@@ -1,30 +1 @@
-<%= link_to t("admin.geozones.index.create"),
- new_admin_geozone_path, class: "button float-right" %>
-
-
<%= t("admin.geozones.index.title") %>
-
-
-
-
- | <%= t("admin.geozones.geozone.name") %> |
- <%= t("admin.geozones.geozone.external_code") %> |
- <%= t("admin.geozones.geozone.census_code") %> |
- <%= t("admin.geozones.geozone.coordinates") %> |
- <%= t("admin.actions.actions") %> |
-
-
-
-
- <% @geozones.each do |geozone| %>
-
- | <%= geozone.name %> |
- <%= geozone.external_code %> |
- <%= geozone.census_code %> |
- <%= geozone.html_map_coordinates %> |
-
- <%= render Admin::TableActionsComponent.new(geozone) %>
- |
-
- <% end %>
-
-
+<%= render Admin::Geozones::IndexComponent.new(@geozones) %>
diff --git a/app/views/admin/geozones/new.html.erb b/app/views/admin/geozones/new.html.erb
index d29c9eac0..b957f2cda 100644
--- a/app/views/admin/geozones/new.html.erb
+++ b/app/views/admin/geozones/new.html.erb
@@ -4,4 +4,4 @@
<%= t("admin.geozones.new.creating") %>
-<%= render "form" %>
+<%= render Admin::Geozones::FormComponent.new(@geozone) %>
diff --git a/app/views/budgets/investments/_map.html.erb b/app/views/budgets/investments/_map.html.erb
deleted file mode 100644
index be68bcdbe..000000000
--- a/app/views/budgets/investments/_map.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-
- <%= render_map(@map_location, investments_coordinates: @investments_map_coordinates) %>
-
diff --git a/app/views/budgets/investments/_sidebar.html.erb b/app/views/budgets/investments/_sidebar.html.erb
index a45ea333f..9aba3eeb1 100644
--- a/app/views/budgets/investments/_sidebar.html.erb
+++ b/app/views/budgets/investments/_sidebar.html.erb
@@ -22,10 +22,7 @@
<%= render Budgets::Investments::ContentBlocksComponent.new(@heading) %>
-
-<% if @map_location&.available? %>
- <%= render "budgets/investments/map" %>
-<% end %>
+<%= render Budgets::Investments::MapComponent.new(@investments_in_map, heading: @heading) %>
<%= render "shared/tag_cloud", taggable: "Budget::Investment" %>
<%= render "budgets/investments/categories" %>
<%= render Budgets::Investments::FiltersComponent.new %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index d6563e507..f2089ca9c 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -201,7 +201,9 @@ en:
geozone:
name: Name
external_code: "External code (optional)"
+ color: "Color (optional)"
census_code: "Census code (optional)"
+ geojson: "GeoJSON data (optional)"
html_map_coordinates: "HTML