decidim-navigation_maps 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +144 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/config/admin/decidim_navigation_maps_manifest.css +3 -0
  6. data/app/assets/config/admin/decidim_navigation_maps_manifest.js +3 -0
  7. data/app/assets/config/decidim_navigation_maps_manifest.css +3 -0
  8. data/app/assets/config/decidim_navigation_maps_manifest.js +1 -0
  9. data/app/assets/images/decidim/navigation_maps/icon.svg +1 -0
  10. data/app/assets/javascripts/decidim/navigation_maps/admin/map_editor.js +88 -0
  11. data/app/assets/javascripts/decidim/navigation_maps/admin/navigation_maps.js +143 -0
  12. data/app/assets/javascripts/decidim/navigation_maps/map_view.js +123 -0
  13. data/app/assets/javascripts/decidim/navigation_maps/navigation_maps.js +44 -0
  14. data/app/assets/stylesheets/decidim/navigation_maps/_variables.scss +3 -0
  15. data/app/assets/stylesheets/decidim/navigation_maps/admin/navigation_maps.scss +102 -0
  16. data/app/assets/stylesheets/decidim/navigation_maps/navigation_maps.scss +58 -0
  17. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_styles.erb +18 -0
  18. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_tabs.erb +5 -0
  19. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_tabs_content.erb +8 -0
  20. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map/_template.erb +13 -0
  21. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map/show.erb +21 -0
  22. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map_cell.rb +22 -0
  23. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_form.erb +36 -0
  24. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_modal.erb +12 -0
  25. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_tabs.erb +6 -0
  26. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/_tabs_content.erb +11 -0
  27. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb +35 -0
  28. data/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form_cell.rb +32 -0
  29. data/app/commands/decidim/navigation_maps/save_area.rb +58 -0
  30. data/app/commands/decidim/navigation_maps/save_blueprints.rb +72 -0
  31. data/app/controllers/decidim/navigation_maps/admin/application_controller.rb +13 -0
  32. data/app/controllers/decidim/navigation_maps/admin/areas_controller.rb +94 -0
  33. data/app/controllers/decidim/navigation_maps/admin/blueprints_controller.rb +64 -0
  34. data/app/forms/decidim/navigation_maps/area_form.rb +37 -0
  35. data/app/forms/decidim/navigation_maps/blueprint_form.rb +39 -0
  36. data/app/forms/decidim/navigation_maps/blueprint_forms.rb +9 -0
  37. data/app/models/decidim/navigation_maps/application_record.rb +10 -0
  38. data/app/models/decidim/navigation_maps/blueprint.rb +27 -0
  39. data/app/models/decidim/navigation_maps/blueprint_area.rb +32 -0
  40. data/app/queries/decidim/navigation_maps/organization_blueprints.rb +20 -0
  41. data/app/uploaders/decidim/navigation_maps/blueprint_uploader.rb +22 -0
  42. data/app/views/decidim/navigation_maps/admin/areas/_form.html.erb +39 -0
  43. data/app/views/decidim/navigation_maps/admin/areas/new.html.erb +17 -0
  44. data/app/views/decidim/navigation_maps/admin/areas/show.html.erb +14 -0
  45. data/config/i18n-tasks.yml +10 -0
  46. data/config/locales/ca.yml +45 -0
  47. data/config/locales/cs.yml +45 -0
  48. data/config/locales/en.yml +46 -0
  49. data/config/locales/es.yml +45 -0
  50. data/db/migrate/20191022092624_create_decidim_navigation_maps_blueprints.rb +13 -0
  51. data/db/migrate/20191120185739_add_title_to_navigation_maps_blueprints.rb +10 -0
  52. data/db/migrate/20191125142751_create_decidim_navigation_maps_blueprint_areas.rb +18 -0
  53. data/db/migrate/20191126045831_add_link_type_to_decidim_navigation_maps_blueprint_areas.rb +8 -0
  54. data/db/migrate/20191126154019_add_area_id_to_decidim_navigation_maps_blueprint_areas.rb +16 -0
  55. data/db/migrate/20191127093746_add_color_to_navigation_maps_blueprint_areas.rb +7 -0
  56. data/lib/decidim/navigation_maps.rb +13 -0
  57. data/lib/decidim/navigation_maps/admin.rb +10 -0
  58. data/lib/decidim/navigation_maps/admin_engine.rb +34 -0
  59. data/lib/decidim/navigation_maps/engine.rb +34 -0
  60. data/lib/decidim/navigation_maps/navigation_map_cell_helpers.rb +28 -0
  61. data/lib/decidim/navigation_maps/test/factories.rb +29 -0
  62. data/lib/decidim/navigation_maps/version.rb +9 -0
  63. data/vendor/assets/images/draw/layers-2x.png +0 -0
  64. data/vendor/assets/images/draw/layers.png +0 -0
  65. data/vendor/assets/images/draw/marker-icon-2x.png +0 -0
  66. data/vendor/assets/images/draw/marker-icon.png +0 -0
  67. data/vendor/assets/images/draw/marker-shadow.png +0 -0
  68. data/vendor/assets/images/draw/spritesheet-2x.png +0 -0
  69. data/vendor/assets/images/draw/spritesheet.png +0 -0
  70. data/vendor/assets/images/draw/spritesheet.svg +156 -0
  71. data/vendor/assets/images/images/layers-2x.png +0 -0
  72. data/vendor/assets/images/images/layers.png +0 -0
  73. data/vendor/assets/images/images/marker-icon-2x.png +0 -0
  74. data/vendor/assets/images/images/marker-icon.png +0 -0
  75. data/vendor/assets/images/images/marker-shadow.png +0 -0
  76. data/vendor/assets/javascripts/jquery.form.js +1277 -0
  77. data/vendor/assets/javascripts/jsrender.min.js +4 -0
  78. data/vendor/assets/javascripts/jsrender.min.js.map +1 -0
  79. data/vendor/assets/javascripts/leaflet-geoman.min.js +1 -0
  80. data/vendor/assets/javascripts/leaflet.js +5 -0
  81. data/vendor/assets/stylesheets/leaflet-geoman.css +164 -0
  82. metadata +183 -0
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module NavigationMaps
5
+ # This query finds the published blueprints for and organization
6
+ class OrganizationBlueprints < Rectify::Query
7
+ def initialize(organization)
8
+ @organization = organization
9
+ end
10
+
11
+ def query
12
+ Decidim::NavigationMaps::Blueprint.where(organization: @organization)
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :organization
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module NavigationMaps
5
+ # This class deals with uploading images to a Blueprints.
6
+ class BlueprintUploader < Decidim::ImageUploader
7
+ process :validate_size, :validate_dimensions
8
+
9
+ version :thumbnail do
10
+ process resize_to_fit: [nil, 237]
11
+ end
12
+
13
+ def extension_white_list
14
+ %w(jpg jpeg png svg)
15
+ end
16
+
17
+ def max_image_height_or_width
18
+ 8000
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ <div class="field">
2
+ <%= form.translated :text_field, :title, autofocus: true, class: "navigation_maps-area-direct" %>
3
+ <%= form.translated :text_area, :description, class: "navigation_maps-area-direct" %>
4
+
5
+ <%= form.text_field :link %>
6
+ <p class="help-text" id="blueprint_area_link-help"><%= link_suggestions %></p>
7
+
8
+ <%= form.color_field :color %>
9
+
10
+ <%= form.check_box :no_popup, label: t(".no_popup") %>
11
+ </div>
12
+
13
+ <script type="text/javascript">
14
+
15
+ (function() {
16
+ var area_link = document.getElementById('blueprint_area_link');
17
+ var help = document.getElementById('blueprint_area_link-help');
18
+ var direct = document.getElementById('blueprint_area_no_popup');
19
+ var direct_elements = document.getElementsByClassName('navigation_maps-area-direct');
20
+
21
+ for(var a of help.getElementsByTagName('a')) {
22
+ a.addEventListener("click", function(e) {
23
+ area_link.value = e.target.hash;
24
+ e.preventDefault();
25
+ });
26
+ }
27
+
28
+ function changeDirects(checked) {
29
+ for(var input of direct_elements) {
30
+ input.disabled = checked;
31
+ }
32
+ }
33
+ changeDirects(direct.checked);
34
+ direct.addEventListener('change', function(e) {
35
+ changeDirects(e.target.checked);
36
+ });
37
+ })();
38
+
39
+ </script>
@@ -0,0 +1,17 @@
1
+ <%= decidim_form_for(@form, url: blueprint_areas_path, remote: true) do |f| %>
2
+ <div class="card">
3
+ <div class="card-divider">
4
+ <h2 class="card-title"><%= t ".area" %></h2>
5
+ </div>
6
+ <div class="card-section">
7
+ <%= render partial: "form", object: f %>
8
+ <%= f.hidden_field :area %>
9
+ <%= f.hidden_field :area_id %>
10
+ <%= f.hidden_field :area_type %>
11
+ </div>
12
+ </div>
13
+ <div class="button--double form-general-submit">
14
+ <%= f.submit t(".save") %>
15
+ <button class="button hollow" type="button" data-close><%= t(".cancel") %></button>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%= decidim_form_for(@form, url: blueprint_area_path, remote: true) do |f| %>
2
+ <div class="card">
3
+ <div class="card-divider">
4
+ <h2 class="card-title">#<%= @form.id %>: <%= t ".area" %></h2>
5
+ </div>
6
+ <div class="card-section">
7
+ <%= render partial: "form", object: f %>
8
+ </div>
9
+ </div>
10
+ <div class="button--double form-general-submit">
11
+ <%= f.submit t(".save") %>
12
+ <button class="button hollow" type="button" data-close><%= t(".cancel") %></button>
13
+ </div>
14
+ <% end %>
@@ -0,0 +1,10 @@
1
+ ---
2
+
3
+ base_locale: en
4
+ locales: [en]
5
+
6
+ ignore_unused:
7
+ - "decidim.components.navigation_maps.name"
8
+
9
+ ignore_missing:
10
+ - decidim.participatory_processes.scopes.global
@@ -0,0 +1,45 @@
1
+ ca:
2
+ decidim:
3
+ components:
4
+ navigation_maps:
5
+ name: NavigationMaps
6
+ navigation_maps:
7
+ admin:
8
+ areas:
9
+ create:
10
+ error: Ha ocorregut un error creant l'àrea
11
+ success: Àrea creada correctament
12
+ form:
13
+ no_popup: Sense pop-up, enllaça l'àrea directament.
14
+ new:
15
+ area: Detalls de la nova àrea
16
+ cancel: Cancel·la
17
+ save: Desa
18
+ show:
19
+ area: Detalls de l'àrea
20
+ cancel: Cancel·la
21
+ link_suggestions: 'Truc: usa %{map} per enllaçar altres pestanyes'
22
+ save: Desa
23
+ update:
24
+ error: Ha ocorregut un error desant l'àrea
25
+ success: Àrea desada correctament
26
+ content_blocks:
27
+ name: Mapa interactiu
28
+ navigation_map:
29
+ view: Participa
30
+ navigation_map_settings_form:
31
+ add: Afegeix
32
+ blueprint_image: Imatge del plànol
33
+ description: Descripció
34
+ editor: Editor del mapa
35
+ id: Id
36
+ image_missing: Si us plau, afegeix una imatge del plànol per començar
37
+ info: Informació general
38
+ link: Enllaç
39
+ remove_blueprint: Elimina el plànol
40
+ title: Títol
41
+ type: Tipus
42
+ upload_image: Puja una imatge
43
+ create:
44
+ error: S'ha produït un error en crear el plànol
45
+ success: Plànol creat correctament
@@ -0,0 +1,45 @@
1
+ cs:
2
+ decidim:
3
+ components:
4
+ navigation_maps:
5
+ name: Navigační Mapy
6
+ navigation_maps:
7
+ admin:
8
+ areas:
9
+ create:
10
+ error: Došlo k chybě při vytváření oblasti
11
+ success: Oblast byla úspěšně vytvořena
12
+ form:
13
+ no_popup: Nepoužívejte vyskakovací okno, odkazujte přímo na oblast.
14
+ new:
15
+ area: Detaily nové oblasti
16
+ cancel: Zrušit
17
+ save: Uložit
18
+ show:
19
+ area: Detaily oblasti
20
+ cancel: Zrušit
21
+ link_suggestions: 'Tip: použijte %{map} pro propojení dalších karet'
22
+ save: Uložit
23
+ update:
24
+ error: Došlo k chybě při ukládání oblasti
25
+ success: Oblast úspěšně uložena
26
+ content_blocks:
27
+ name: Navigační Mapy
28
+ navigation_map:
29
+ view: Zapojte se
30
+ navigation_map_settings_form:
31
+ add: Přidat
32
+ blueprint_image: Obrázek plánu
33
+ description: Popis
34
+ editor: Editor mapy
35
+ id: Id
36
+ image_missing: Pro začátek přidejte obrázek plánu
37
+ info: Obecné informace
38
+ link: Odkaz
39
+ remove_blueprint: Smazat tento plán
40
+ title: Název
41
+ type: Typ
42
+ upload_image: Nahrát obrázek
43
+ create:
44
+ error: Chyba při vytváření plánu
45
+ success: Plán byl úspěšně vytvořen
@@ -0,0 +1,46 @@
1
+ ---
2
+ en:
3
+ decidim:
4
+ components:
5
+ navigation_maps:
6
+ name: NavigationMaps
7
+ navigation_maps:
8
+ admin:
9
+ areas:
10
+ create:
11
+ error: An error ocurred while creating the area
12
+ success: Area created successfully
13
+ form:
14
+ no_popup: Do not use a popup, link the area directly.
15
+ new:
16
+ area: New area details
17
+ cancel: Cancel
18
+ save: Save
19
+ show:
20
+ area: Area details
21
+ cancel: Cancel
22
+ link_suggestions: 'Tip: use %{map} to link other tabs'
23
+ save: Save
24
+ update:
25
+ error: An error ocurred while saving the area
26
+ success: Area saved successfully
27
+ content_blocks:
28
+ name: Navigation Maps
29
+ navigation_map:
30
+ view: Take part
31
+ navigation_map_settings_form:
32
+ add: Add
33
+ blueprint_image: Blueprint image
34
+ description: Description
35
+ editor: Map Editor
36
+ id: Id
37
+ image_missing: Please add a blueprint image to start
38
+ info: General info
39
+ link: Link
40
+ remove_blueprint: Delete this blueprint
41
+ title: Title
42
+ type: Type
43
+ upload_image: Upload image
44
+ create:
45
+ error: Error creating blueprint
46
+ success: Blueprint created successfully
@@ -0,0 +1,45 @@
1
+ es:
2
+ decidim:
3
+ components:
4
+ navigation_maps:
5
+ name: NavigationMaps
6
+ navigation_maps:
7
+ admin:
8
+ areas:
9
+ create:
10
+ error: Se ha producido un error al crear el área
11
+ success: Área creada correctamente
12
+ form:
13
+ no_popup: No utilizar un popup, enlazar el área directamente.
14
+ new:
15
+ area: Detalles de la nueva área
16
+ cancel: Cancelar
17
+ save: Guardar
18
+ show:
19
+ area: Detalles del área
20
+ cancel: Cancelar
21
+ link_suggestions: 'Truco: usa %{map} para enlazar otras pestañas'
22
+ save: Guardar
23
+ update:
24
+ error: Se ha producido un error al guardar el área
25
+ success: Área guardada correctamente
26
+ content_blocks:
27
+ name: Navigation Maps
28
+ navigation_map:
29
+ view: Take part
30
+ navigation_map_settings_form:
31
+ add: Add
32
+ blueprint_image: Blueprint image
33
+ description: Description
34
+ editor: Map Editor
35
+ id: Id
36
+ image_missing: Please add a blueprint image to start
37
+ info: General info
38
+ link: Link
39
+ remove_blueprint: Delete this blueprint
40
+ title: Title
41
+ type: Type
42
+ upload_image: Upload image
43
+ create:
44
+ error: Error creating blueprint
45
+ success: Blueprint created successfully
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimNavigationMapsBlueprints < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_navigation_maps_blueprints do |t|
6
+ t.jsonb :blueprint
7
+ t.string :image
8
+ t.references :decidim_organization, null: false, foreign_key: true, index: { name: "decidim_navigation_maps_constraint_organization" }
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddTitleToNavigationMapsBlueprints < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_table :decidim_navigation_maps_blueprints do |t|
6
+ t.jsonb :title, default: {}
7
+ t.jsonb :description, default: {}
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateDecidimNavigationMapsBlueprintAreas < ActiveRecord::Migration[5.2]
4
+ def change
5
+ create_table :decidim_navigation_maps_blueprint_areas do |t|
6
+ t.jsonb :area
7
+ t.references :decidim_navigation_maps_blueprint, null: false, foreign_key: true, index: { name: "decidim_navigation_maps_constraint_blueprint_id" }
8
+ t.jsonb :title, default: {}
9
+ t.jsonb :description, default: {}
10
+ t.string :area_type
11
+ t.string :url
12
+
13
+ t.timestamps
14
+ end
15
+
16
+ remove_column :decidim_navigation_maps_blueprints, :blueprint, :jsonb
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddLinkTypeToDecidimNavigationMapsBlueprintAreas < ActiveRecord::Migration[5.2]
4
+ def change
5
+ rename_column :decidim_navigation_maps_blueprint_areas, :url, :link
6
+ add_column :decidim_navigation_maps_blueprint_areas, :link_type, :string
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddAreaIdToDecidimNavigationMapsBlueprintAreas < ActiveRecord::Migration[5.2]
4
+ class Area < ApplicationRecord
5
+ self.table_name = "decidim_navigation_maps_blueprint_areas"
6
+ end
7
+
8
+ def change
9
+ add_column :decidim_navigation_maps_blueprint_areas, :area_id, :string
10
+
11
+ Area.find_each do |area|
12
+ area.area_id = area.id
13
+ area.save!
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddColorToNavigationMapsBlueprintAreas < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :decidim_navigation_maps_blueprint_areas, :color, :string
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/navigation_maps/admin"
4
+ require "decidim/navigation_maps/engine"
5
+ require "decidim/navigation_maps/admin_engine"
6
+
7
+ module Decidim
8
+ # This namespace holds the logic of the `NavigationMaps` component. This component
9
+ # allows users to create navigation_maps in a participatory space.
10
+ module NavigationMaps
11
+ autoload :NavigationMapCellHelpers, "decidim/navigation_maps/navigation_map_cell_helpers"
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module NavigationMaps
5
+ # This module contains all the domain logic associated to Decidim's NavigationMaps
6
+ # component admin panel.
7
+ module Admin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module NavigationMaps
5
+ # This is the engine that runs on the public interface of `NavigationMaps`.
6
+ class AdminEngine < ::Rails::Engine
7
+ isolate_namespace Decidim::NavigationMaps::Admin
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ routes do
13
+ # Add admin engine routes here
14
+ resources :blueprints, only: [:index, :show, :create] do
15
+ resources :areas, param: :area_id
16
+ end
17
+ end
18
+
19
+ initializer "decidim_navigation_maps.admin_mount_routes" do
20
+ Decidim::Core::Engine.routes do
21
+ mount Decidim::NavigationMaps::AdminEngine, at: "/admin/navigation_maps", as: "decidim_admin_navigation_maps"
22
+ end
23
+ end
24
+
25
+ initializer "decidim_navigation_maps.admin_assets" do |app|
26
+ app.config.assets.precompile += %w(admin/decidim_navigation_maps_manifest.js admin/decidim_navigation_maps_manifest.css)
27
+ end
28
+
29
+ def load_seed
30
+ nil
31
+ end
32
+ end
33
+ end
34
+ end