From c3991933b8c6899e70d9faac57e862c11bd7e039 Mon Sep 17 00:00:00 2001 From: Joonas Date: Thu, 30 Nov 2023 15:39:45 +0200 Subject: [PATCH] Add new shapes --- Gemfile | 1 + Gemfile.lock | 11 +- .../decidim/locations/locations/show.erb | 10 +- .../decidim/locations/locations_command.rb | 4 +- app/forms/decidim/locations/location_form.rb | 11 + .../decidim/locations/locations_helper.rb | 10 +- .../entrypoints/decidim_locations_edit_map.js | 2 +- .../src/decidim/geoman/leaflet-geoman.css | 284 ++++++++++++++++++ .../src/decidim/geoman/leaflet-geoman.min.js | 1 + .../locations/map/controller/location.js | 14 +- .../map/integration/add_input_group.js | 52 ++++ .../locations/map/integration/center_shape.js | 32 ++ .../map/integration/coord_average.js | 23 ++ .../locations/map/integration/forms.js | 188 ++++++------ .../{avg_coordinates.js => point_distance.js} | 0 .../src/decidim/revgeocoding/provider/here.js | 4 +- .../decidim/locations/locations.scss | 2 +- ...20211202091118_create_decidim_locations.rb | 2 + decidim-tags.gemspec | 2 + .../api/types/location_attributes.rb | 2 + .../locations/api/types/location_type.rb | 2 + 21 files changed, 529 insertions(+), 128 deletions(-) create mode 100644 app/packs/src/decidim/geoman/leaflet-geoman.css create mode 100644 app/packs/src/decidim/geoman/leaflet-geoman.min.js create mode 100644 app/packs/src/decidim/locations/map/integration/add_input_group.js create mode 100644 app/packs/src/decidim/locations/map/integration/center_shape.js create mode 100644 app/packs/src/decidim/locations/map/integration/coord_average.js rename app/packs/src/decidim/locations/map/integration/{avg_coordinates.js => point_distance.js} (100%) diff --git a/Gemfile b/Gemfile index bd6e6b2..038fb62 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ gem "decidim-locations", path: "." gem "bootsnap", "~> 1.4" gem "puma", ">= 5.0.0" +gem "rgeo-geojson", "~> 2.1", ">= 2.1.1" gem "uglifier", "~> 4.1" group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 1f13093..f1584df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,6 +3,7 @@ PATH specs: decidim-locations (0.27.4) decidim-core (~> 0.27.4) + rgeo-geojson (~> 2.1, >= 2.1.1) GEM remote: https://rubygems.org/ @@ -111,7 +112,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.4) + carrierwave (2.2.5) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) @@ -362,7 +363,7 @@ GEM temple erubi (1.12.0) escape_utils (1.3.0) - excon (0.104.0) + excon (0.105.0) execjs (2.9.1) extended-markdown-filter (0.7.0) html-pipeline (~> 2.9) @@ -499,7 +500,7 @@ GEM msgpack (1.7.2) multi_xml (0.6.0) mustache (1.1.1) - net-imap (0.4.6) + net-imap (0.4.7) date net-protocol net-pop (0.1.2) @@ -636,6 +637,9 @@ GEM actionpack (>= 5.2) railties (>= 5.2) rexml (3.2.6) + rgeo (3.0.1) + rgeo-geojson (2.1.1) + rgeo (>= 1.0.0) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) @@ -810,6 +814,7 @@ DEPENDENCIES letter_opener_web (~> 2.0) listen (~> 3.1) puma (>= 5.0.0) + rgeo-geojson (~> 2.1, >= 2.1.1) rubocop-faker rubocop-performance (~> 1.15.0) spring (~> 2.0) diff --git a/app/cells/decidim/locations/locations/show.erb b/app/cells/decidim/locations/locations/show.erb index 80d700c..c5e95a5 100644 --- a/app/cells/decidim/locations/locations/show.erb +++ b/app/cells/decidim/locations/locations/show.erb @@ -18,20 +18,24 @@ <% form.fields_for :locations do |locations| %> <% locations.fields_for "#{ loc.id ||= new_id }" do |location| %> <%= location.hidden_field :address, class: "location-address", autocomplete: "off", value: loc.address %> + <%= location.hidden_field :shape, class: "location-shape", autocomplete: "off", value: loc.shape %> <%= location.hidden_field :latitude, class: "location-latitude", autocomplete: "off", value: loc.latitude %> <%= location.hidden_field :longitude, class: "location-longitude", autocomplete: "off", value: loc.longitude %> + <%= location.hidden_field :geojson, class: "location-geojson", autocomplete: "off", value: loc.geojson %> <% end %> <% end %> <% end %> -