decidim-decidim_awesome 0.7.2 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +181 -0
  3. data/README.md +61 -35
  4. data/Rakefile +11 -12
  5. data/app/cells/decidim/decidim_awesome/content_blocks/map/error.erb +11 -0
  6. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +1 -61
  7. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +11 -0
  8. data/app/cells/decidim/decidim_awesome/content_blocks/map_form/show.erb +8 -4
  9. data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +51 -0
  10. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +47 -0
  11. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +49 -0
  12. data/app/commands/decidim/decidim_awesome/create_editor_image.rb +12 -5
  13. data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +58 -0
  14. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +24 -24
  15. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +9 -1
  16. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +91 -0
  17. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +5 -8
  18. data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +19 -0
  19. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +2 -3
  20. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +1 -1
  21. data/app/controllers/decidim/decidim_awesome/map_component/map_controller.rb +2 -6
  22. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +2 -0
  23. data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +45 -0
  24. data/app/forms/decidim/decidim_awesome/editor_image_form.rb +3 -2
  25. data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +38 -0
  26. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +22 -9
  27. data/app/helpers/decidim/decidim_awesome/admin/system_checker_helpers.rb +36 -0
  28. data/app/helpers/decidim/decidim_awesome/map_helper.rb +18 -12
  29. data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +2 -2
  30. data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +106 -0
  31. data/app/models/decidim/decidim_awesome/editor_image.rb +4 -9
  32. data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +5 -0
  33. data/app/packs/entrypoints/decidim_admin_decidim_awesome.scss +1 -0
  34. data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +2 -0
  35. data/app/packs/entrypoints/decidim_decidim_awesome.js +9 -0
  36. data/app/packs/entrypoints/decidim_decidim_awesome.scss +1 -0
  37. data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +1 -0
  38. data/app/packs/entrypoints/decidim_decidim_awesome_custom_fields.js +1 -0
  39. data/app/packs/entrypoints/decidim_decidim_awesome_iframe.scss +1 -0
  40. data/app/packs/entrypoints/decidim_decidim_awesome_map.js +5 -0
  41. data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -0
  42. data/app/{assets → packs}/images/decidim/decidim_awesome/platoniq-logo.png +0 -0
  43. data/app/{assets/javascripts/decidim/decidim_awesome/admin/auto_edit.js.es6 → packs/src/decidim/decidim_awesome/admin/auto_edit.js} +39 -34
  44. data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +48 -0
  45. data/app/{assets/javascripts/decidim/decidim_awesome/admin/codemirror.js.es6 → packs/src/decidim/decidim_awesome/admin/codemirror.js} +4 -4
  46. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +55 -0
  47. data/app/{assets/javascripts/decidim/decidim_awesome/admin/form_builder.js.es6 → packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js} +23 -26
  48. data/app/{assets/javascripts/decidim/decidim_awesome/admin/form_exit_warn.js.es6 → packs/src/decidim/decidim_awesome/admin/form_exit_warn.js} +0 -2
  49. data/app/{assets/javascripts/decidim/decidim_awesome/admin/user_picker.js.es6 → packs/src/decidim/decidim_awesome/admin/user_picker.js} +3 -3
  50. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +23 -0
  51. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +17 -0
  52. data/app/{assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6 → packs/src/decidim/decidim_awesome/awesome_map/api/api_fetcher.js} +1 -15
  53. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +134 -0
  54. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +59 -0
  55. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +52 -0
  56. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +129 -0
  57. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +130 -0
  58. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +31 -0
  59. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +88 -0
  60. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +221 -0
  61. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +51 -0
  62. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +191 -0
  63. data/app/{assets/javascripts/decidim/decidim_awesome/editors/tabs_focus.js.es6 → packs/src/decidim/decidim_awesome/editors/tabs_focus.js} +4 -6
  64. data/app/{assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 → packs/src/decidim/decidim_awesome/forms/autosave.js} +20 -17
  65. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +207 -0
  66. data/app/{assets/javascripts/decidim/decidim_awesome/forms/rich_text_plugin.js.es6 → packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js} +23 -21
  67. data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +22 -0
  68. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +25 -0
  69. data/{vendor/assets/javascripts → app/packs/src/vendor}/image-resize.min.js +0 -0
  70. data/{vendor/assets/javascripts → app/packs/src/vendor}/image-upload.min.js +0 -0
  71. data/{vendor/assets/javascripts → app/packs/src/vendor}/jquery.truncate.js +0 -0
  72. data/app/packs/src/vendor/leaflet.featuregroup.subgroup.js +184 -0
  73. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +2 -1
  74. data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +28 -0
  75. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +8 -6
  76. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/constraints.scss +13 -13
  77. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +37 -10
  78. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +41 -0
  79. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +71 -0
  80. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +19 -0
  81. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +3 -3
  82. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +176 -0
  83. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +6 -4
  84. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +58 -0
  85. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/forms/autosave.scss +2 -2
  86. data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +348 -0
  87. data/app/presenters/decidim/decidim_awesome/menu_item_presenter_override.rb +25 -0
  88. data/app/presenters/decidim/decidim_awesome/menu_presenter_override.rb +23 -0
  89. data/app/uploaders/decidim/cw/decidim_awesome/image_uploader.rb +26 -0
  90. data/app/uploaders/decidim/decidim_awesome/image_uploader.rb +4 -16
  91. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +28 -22
  92. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +1 -1
  93. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +1 -1
  94. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +1 -0
  95. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +1 -1
  96. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +7 -6
  97. data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +1 -1
  98. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +3 -3
  99. data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +1 -1
  100. data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +6 -0
  101. data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +13 -0
  102. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +37 -0
  103. data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +13 -0
  104. data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +1 -1
  105. data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +1 -1
  106. data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +5 -3
  107. data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +1 -1
  108. data/app/views/decidim/decidim_awesome/map_component/map/_api_ready.html.erb +3 -0
  109. data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +68 -0
  110. data/app/views/decidim/decidim_awesome/map_component/map/{error.erb → error.html.erb} +2 -0
  111. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +3 -67
  112. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +1 -1
  113. data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +13 -9
  114. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +0 -2
  115. data/app/views/{v0.24 → v0.25}/decidim/proposals/collaborative_drafts/_show.html.erb +0 -0
  116. data/app/views/{v0.23 → v0.25}/layouts/decidim/_head.html.erb +12 -10
  117. data/app/views/v0.25/layouts/decidim/admin/_header.html.erb +11 -0
  118. data/app/views/{v0.23 → v0.26}/decidim/proposals/collaborative_drafts/_show.html.erb +1 -7
  119. data/app/views/{v0.24 → v0.26}/layouts/decidim/_head.html.erb +16 -10
  120. data/app/views/v0.26/layouts/decidim/admin/_header.html.erb +11 -0
  121. data/config/assets.rb +46 -0
  122. data/config/i18n-tasks.yml +6 -0
  123. data/config/locales/ca.yml +77 -13
  124. data/config/locales/cs.yml +65 -1
  125. data/config/locales/en.yml +69 -1
  126. data/config/locales/es.yml +65 -1
  127. data/config/locales/eu.yml +0 -232
  128. data/config/locales/fr.yml +117 -53
  129. data/config/locales/it.yml +65 -1
  130. data/config/locales/ja.yml +66 -3
  131. data/config/locales/nl.yml +5 -46
  132. data/config/locales/pt-BR.yml +348 -0
  133. data/config/locales/pt-PT.yml +7 -0
  134. data/config/locales/pt.yml +7 -0
  135. data/config/locales/sv.yml +67 -182
  136. data/lib/decidim/decidim_awesome/admin_engine.rb +10 -15
  137. data/lib/decidim/decidim_awesome/awesome.rb +214 -0
  138. data/lib/decidim/decidim_awesome/awesome_helpers.rb +0 -7
  139. data/lib/decidim/decidim_awesome/checksums.yml +13 -16
  140. data/lib/decidim/decidim_awesome/config.rb +1 -0
  141. data/lib/decidim/decidim_awesome/content_parsers/editor_images_parser.rb +39 -0
  142. data/lib/decidim/decidim_awesome/engine.rb +27 -55
  143. data/lib/decidim/decidim_awesome/iframe_component/admin_engine.rb +23 -0
  144. data/lib/decidim/decidim_awesome/iframe_component/component.rb +6 -6
  145. data/lib/decidim/decidim_awesome/map_component/admin_engine.rb +23 -0
  146. data/lib/decidim/decidim_awesome/map_component/component.rb +6 -5
  147. data/lib/decidim/decidim_awesome/map_component/engine.rb +34 -0
  148. data/lib/decidim/decidim_awesome/menu_hacker.rb +1 -0
  149. data/lib/decidim/decidim_awesome/test/factories.rb +2 -2
  150. data/lib/decidim/decidim_awesome/test/initializer.rb +25 -0
  151. data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +30 -2
  152. data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +7 -2
  153. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +18 -0
  154. data/lib/decidim/decidim_awesome/test/shared_examples/controller_examples.rb +13 -0
  155. data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +47 -0
  156. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +0 -17
  157. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +9 -17
  158. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +202 -0
  159. data/lib/decidim/decidim_awesome/version.rb +2 -2
  160. data/lib/decidim/decidim_awesome.rb +4 -152
  161. data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +37 -0
  162. data/lib/tasks/decidim_awesome_webpacker_tasks.rake +64 -0
  163. data/package.json +211 -0
  164. metadata +113 -113
  165. data/app/assets/config/decidim_admin_decidim_awesome_manifest.css +0 -3
  166. data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +0 -2
  167. data/app/assets/config/decidim_decidim_awesome_manifest.css +0 -5
  168. data/app/assets/config/decidim_decidim_awesome_manifest.js +0 -4
  169. data/app/assets/config/legacy_decidim_admin_decidim_awesome_manifest.js +0 -2
  170. data/app/assets/config/legacy_decidim_decidim_awesome_manifest.js +0 -4
  171. data/app/assets/javascripts/decidim/decidim_awesome/admin/constraints.js.es6 +0 -54
  172. data/app/assets/javascripts/decidim/decidim_awesome/admin/legacy_form_builder.js.es6 +0 -80
  173. data/app/assets/javascripts/decidim/decidim_awesome/awesome_admin.js +0 -7
  174. data/app/assets/javascripts/decidim/decidim_awesome/awesome_application.js +0 -3
  175. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/categories.js.es6 +0 -25
  176. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/hashtags.js.es6 +0 -48
  177. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/layers.js.es6 +0 -107
  178. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/load_map.js.es6 +0 -15
  179. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +0 -207
  180. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/markers.js.es6 +0 -56
  181. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +0 -132
  182. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +0 -107
  183. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/utilities.js.es6 +0 -57
  184. data/app/assets/javascripts/decidim/decidim_awesome/editors/legacy_quill_editor.js.es6 +0 -172
  185. data/app/assets/javascripts/decidim/decidim_awesome/editors/quill_editor.js.es6 +0 -185
  186. data/app/assets/javascripts/decidim/decidim_awesome/forms/custom_fields_builder.js.es6 +0 -211
  187. data/app/assets/javascripts/decidim/decidim_awesome/legacy_admin.js +0 -7
  188. data/app/assets/javascripts/decidim/decidim_awesome/legacy_application.js +0 -3
  189. data/app/assets/javascripts/decidim/decidim_awesome/proposals/custom_fields.js.es6 +0 -21
  190. data/app/assets/javascripts/decidim/decidim_awesome/proposals/images.js.es6 +0 -25
  191. data/app/assets/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +0 -35
  192. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_admin.scss +0 -64
  193. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_application.scss +0 -22
  194. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/leaflet.scss.erb +0 -18
  195. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +0 -160
  196. data/app/assets/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -22
  197. data/app/awesome_overrides/forms/decidim/proposals/proposal_wizard_create_step_form_override.rb +0 -28
  198. data/app/awesome_overrides/presenters/decidim/menu_presenter_override.rb +0 -39
  199. data/app/controllers/concerns/decidim/decidim_awesome/admin_not_found_redirect.rb +0 -39
  200. data/app/controllers/decidim/decidim_awesome/iframe_component/application_controller.rb +0 -15
  201. data/app/controllers/decidim/decidim_awesome/map_component/application_controller.rb +0 -15
  202. data/app/views/v0.23/layouts/decidim/admin/_header.html.erb +0 -12
  203. data/app/views/v0.24/layouts/decidim/admin/_header.html.erb +0 -12
  204. data/lib/decidim/decidim_awesome/test/themes/css.lvh.me.css +0 -3
  205. data/lib/decidim/decidim_awesome/test/themes/erb.lvh.me.scss.erb +0 -2
  206. data/lib/decidim/decidim_awesome/test/themes/scss.lvh.me.scss +0 -1
  207. data/lib/decidim/decidim_awesome/test/themes/test-theme/body.scss +0 -4
  208. data/vendor/assets/images/layers-2x.png +0 -0
  209. data/vendor/assets/images/layers.png +0 -0
  210. data/vendor/assets/images/marker-icon.png +0 -0
  211. data/vendor/assets/javascripts/codemirror-4.inline-attachment.js +0 -89
  212. data/vendor/assets/javascripts/codemirror.js +0 -9801
  213. data/vendor/assets/javascripts/delta.min.js +0 -405
  214. data/vendor/assets/javascripts/delta.min.js.map +0 -1
  215. data/vendor/assets/javascripts/europa.min.js +0 -4
  216. data/vendor/assets/javascripts/form-builder.min.js +0 -19
  217. data/vendor/assets/javascripts/form-render.min.js +0 -19
  218. data/vendor/assets/javascripts/form-storage.js +0 -824
  219. data/vendor/assets/javascripts/highlight.min.js +0 -44
  220. data/vendor/assets/javascripts/inline-attachment.js +0 -399
  221. data/vendor/assets/javascripts/inscrybmde.min.js +0 -7
  222. data/vendor/assets/javascripts/jquery-ui.min.js +0 -13
  223. data/vendor/assets/javascripts/jquery.inline-attachment.js +0 -66
  224. data/vendor/assets/javascripts/jsrender.min.js +0 -4
  225. data/vendor/assets/javascripts/keymap/sublime.js +0 -720
  226. data/vendor/assets/javascripts/leaflet.featuregroup.subgroup.js +0 -6
  227. data/vendor/assets/javascripts/mode/css/css.js +0 -864
  228. data/vendor/assets/javascripts/select2.js +0 -6147
  229. data/vendor/assets/langs/en-US.lang +0 -110
  230. data/vendor/assets/stylesheets/codemirror.css +0 -350
  231. data/vendor/assets/stylesheets/default.min.css +0 -1
  232. data/vendor/assets/stylesheets/foundation.min.css +0 -1
  233. data/vendor/assets/stylesheets/github.min.css +0 -2
  234. data/vendor/assets/stylesheets/inscrybmde.min.scss +0 -194
  235. data/vendor/assets/stylesheets/jquery-ui.min.css +0 -7
  236. data/vendor/assets/stylesheets/select2-foundation-theme.css +0 -249
  237. data/vendor/assets/stylesheets/select2.css +0 -515
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8913b46e29378088cc9b9eed9b69b0321e404f52900b725cea8e213bea47502e
4
- data.tar.gz: 5a79234c4b57bd7ea62589f833fef5ffff0468d4fec7ef907cbaabeb96df4dc0
3
+ metadata.gz: b4110437605bf9896fee1a5becc6c16f6b91ece51cb3721efe261b7db6c14c88
4
+ data.tar.gz: 7175bbc19bddc7a8fd674a19d340836a13e09afbd64f6256430695fe49460b91
5
5
  SHA512:
6
- metadata.gz: cde9b7f7cfa19d19a9a9157c152e34a7ac849fd75b8cb2a23ae487836e561ff43bb961fa83d38e495069a427ec67e35afe05f1131ba1cbdf3509d25161f2b16f
7
- data.tar.gz: 20fa96490ce61a2679c13864e8b580f607b482a00176c684e1fd9f8014666f004a76299134c7096f57f9ff1e6aaaa2b4dca72df460fd1ad2180f5f129cea6291
6
+ metadata.gz: 3a0aca02ca09a39d27444e9650c804817c47b7fbaf902dc7c0e546b28301705287da973ae72ed7a64a8dfa5d3a84baa039393e4b313e1394ace09cef61d28307
7
+ data.tar.gz: c2e343284fdc6e1062e465ecf88724b86bb6a8e68ab759abc4c23353473cb45ee9a855d3e52431b46ae97f916800eb083f73b2c7073d79c26b317dd6f03fc152
data/CHANGELOG.md ADDED
@@ -0,0 +1,181 @@
1
+ CHANGELOG
2
+ =========
3
+
4
+ v0.8.0
5
+ ------
6
+
7
+ Compatibility:
8
+ - Decidim v0.26.x
9
+ - Decidim v0.25.x
10
+
11
+ Features:
12
+ - Several bug fixing related to deactivating features (now there's a test for it).
13
+ - Now awesome components can be disabled using the `disabled_components` configuration var.
14
+ - Feature: Custom redirections editor: Create shorter URL redirections to other places, inside or outside Decidim.
15
+ - Update to webpacker compatiblity and Decidim 0.25
16
+ - Added tasks `bin/rails decidim_awesome:active_storage_migrations:check_migration_from_carrierwave` and `bin/rails decidim_awesome:active_storage_migrations:migrate_from_carrierwave` (also accessible as a backgroundjob from the awesome admin checks)
17
+ - REMOVED: SCSS themes are not available anymore (the alternative is to use custom styles). This is mostly because of webpacker.
18
+
19
+ v0.7.2
20
+ ------
21
+
22
+ Compatibility:
23
+ - Decidim v0.24.x
24
+ - Decidim v0.23.x
25
+
26
+ Features:
27
+ - Added custom fields (with admin interface and scopable) to replace normal body in proposals.
28
+ - Change Markdown editor behaviour: now it is converted to HTML before storing in the database. This makes the editor compatible with all Rich Text editors.
29
+ - Added icons in the awesome config menu
30
+ - Fixes scoped admins accessing process groups
31
+
32
+ v0.7.1
33
+ ------
34
+
35
+ Compatibility:
36
+ - Decidim v0.24.x
37
+ - Decidim v0.23.x
38
+
39
+ Features:
40
+ - Fix CSS custom styles when using html characters
41
+ - Add Awesome Map content block for the homepage
42
+ - Added processes groups constraint for different scoped tweaks
43
+ - Added "Never" constraint to deactivated scoped tweaks temporarily
44
+ - Change Markdown editor behaviour: now it is converted to HTML before storing in the database. This makes the editor compatible with all Rich Text editors. This also takes this feature out the the "experimental" zone as the resulting edited text is fully compatible with standard Decidim.
45
+ - Added scoped admins feature: Any user can be turned into a limited admin and scoped to one or more participatory spaces.
46
+ - Fix allowing access to participatory space admins (only full admins can access the module).
47
+ - Added `participatory_spaces_routes_context` config variable to specify additional routes correspondences to participatory spaces.
48
+
49
+ v0.7.0
50
+ ------
51
+
52
+ Compatibility:
53
+ - Decidim v0.24
54
+ - Decidim v0.23.x
55
+ - Decidim v0.23
56
+
57
+ v0.6.7
58
+ ------
59
+
60
+ Compatibility:
61
+ - Decidim v0.23.x
62
+ - Decidim v0.23
63
+ - Decidim v0.22
64
+
65
+ Features:
66
+ - Feature: Truncate description in map popups to configurable character limit
67
+ - Add CSS validation and syntax highlighting in CSS boxes editors
68
+ - Fix: filter awesome map by hash takes into account the status of categories
69
+
70
+ v0.6.6
71
+ ------
72
+
73
+ Compatibility:
74
+ - Decidim v0.23.3
75
+ - Decidim v0.23.2
76
+ - Decidim v0.23.1
77
+ - Decidim v0.23
78
+ - Decidim v0.22
79
+
80
+ Features:
81
+ - Fix: Prevents overrides for menus not specified in awesome config
82
+ - Fix: Respect original @if condition for menu presenter for native menus
83
+
84
+ v0.6.5
85
+ ------
86
+
87
+ Compatibility:
88
+ - Decidim v0.23.3
89
+ - Decidim v0.23.2
90
+ - Decidim v0.23.1
91
+ - Decidim v0.23
92
+ - Decidim v0.22
93
+
94
+ Features:
95
+ - Allow admins to modify the main Decidim menu
96
+
97
+ v0.6.4
98
+ ------
99
+
100
+ Compatibility:
101
+ - Decidim v0.23.3
102
+ - Decidim v0.23.2
103
+ - Decidim v0.23.1
104
+ - Decidim v0.23
105
+ - Decidim v0.22
106
+
107
+ Features:
108
+ - Fixes a 500 error when custom styles is empty
109
+ - Fixes removal of existing css boxes when other configuration are changed
110
+
111
+ v0.6.3
112
+ ------
113
+
114
+ Compatibility:
115
+ - Decidim v0.23.3
116
+ - Decidim v0.23.2
117
+ - Decidim v0.23.1
118
+ - Decidim v0.23
119
+ - Decidim v0.22
120
+
121
+ Features:
122
+ - Adds custom scoped styles
123
+
124
+ v0.6.2
125
+ ------
126
+
127
+ Compatibility:
128
+ - Decidim release/0.23-stable
129
+ - Decidim v0.23.1
130
+ - Decidim v0.23
131
+ - Decidim v0.22
132
+
133
+ Features:
134
+ - Fixes compatibility with proposals in branch `release/0.23-stable`
135
+
136
+ v0.6.1
137
+ ------
138
+
139
+ Compatibility:
140
+ - Decidim v0.23
141
+ - Decidim v0.22
142
+
143
+ Features:
144
+ - Improve awesome map categories visualization
145
+ - Fix image uploader
146
+ - Adds announcements for full screen iframes
147
+
148
+ v0.6
149
+ ----
150
+
151
+ Compatibility:
152
+ - Decidim v0.23
153
+ - Decidim v0.22
154
+
155
+ Features:
156
+ - Full screen iframe component
157
+ - live support chat linked with Telegram
158
+
159
+ v0.4, 0.5
160
+ ----
161
+
162
+ Compatibility:
163
+ - Decidim v0.22
164
+ - Decidim v0.21
165
+
166
+ Features:
167
+ - Decidim CSS themes for tenants
168
+
169
+ v0.3
170
+ ----
171
+
172
+ Compatibility:
173
+ - Decidim v0.21
174
+ - Decidim v0.20
175
+
176
+ Features:
177
+ - Awesome map
178
+ - Images in rich text editors
179
+ - Images in textarea editors
180
+ - Autosave forms
181
+ - Scoped constraints for each feature
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # Decidim::DecidimAwesome
2
2
 
3
- [![[CI] Test 0.24](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-24.yml/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-24.yml)
4
- [![[CI] Test 0.23](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-23.yml/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test-23.yml)
3
+ [![[CI] Test](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test.yml/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions/workflows/test.yml)
5
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/2dada53525dd5a944089/maintainability)](https://codeclimate.com/github/Platoniq/decidim-module-decidim_awesome/maintainability)
6
- [![Test Coverage](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome/branch/master/graph/badge.svg?token=TFBMCLLZJG)](undefined)
5
+ [![Test Coverage](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome/branch/master/graph/badge.svg?token=TFBMCLLZJG)](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome)
7
6
 
8
7
  Usability and UX tweaks for Decidim.
9
8
 
@@ -78,44 +77,25 @@ It also provides a simple search by category, each category is assigned to a dif
78
77
 
79
78
  ![Awesome map](examples/awesome-map.png)
80
79
 
81
- #### 7. Allow Decidim to use custom CSS themes for every tenant
82
-
83
- When customizing CSS for a Decidim installation, each change affects all the organizations (tenant).
84
-
85
- This feature allows to customize each organization css without affecting the others in the same Decidim installation.
86
-
87
- ##### To create a theme
88
-
89
- 1. Get your hostname for the organization, theme search will be based on this (e.g: `myorganization.com`)
90
- 2. Create in you Decidim application this folder: `app/assets/themes/`
91
- 3. Create a file in that folder with the same name as the host and suffixed `.css` or `.scss` (e.g: `app/assets/themes/myorganization.com.scss`)
92
- 4. Modify that file as you like, you can use any SASS function available (such as `@import`)
93
- 5. Restart your server, enjoy!
94
-
95
- See an example here:
96
- https://github.com/Platoniq/decidim-demo/tree/master/app/assets/themes
97
-
98
- NOTE: Files presents in the `app/assets/themes` folder are added automatically into the precompile list of Rails by this plugin.
99
-
100
- #### 8. Fullscreen Iframe component
80
+ #### 7. Fullscreen Iframe component
101
81
 
102
82
  Another simple component that can be used to embed and Iframe with any external content in it that fills all the viewport.
103
83
 
104
84
  ![Fullscreen iframe](examples/fullscreen-iframe.png)
105
85
 
106
- #### 9. Live support chat
86
+ #### 8. Live support chat
107
87
 
108
88
  With this feature you can have a support chat in Decidim. It is linked to a [Telegram](https://telegram.org/) group or a single user chat using the [[IntergramBot](https://web.telegram.org/#/im?p=@IntergramBot). Just invite the bot to a group or chat with it directly, grab your ID, put it on the Awesome settings and have fun!. For more info or for hosting your own version of the bot check the [Intergram project](https://github.com/idoco/intergram).
109
89
 
110
90
  ![Intergram screenshot](examples/intergram.png)
111
91
 
112
- #### 10. Custom CSS applied only according scoped restrictions
92
+ #### 9. Custom CSS applied only according scoped restrictions
113
93
 
114
94
  With this feature you can create directly in the admin a CSS snipped that is only applied globally, in a particular assembly or even a single proposal!
115
95
 
116
96
  ![CSS screenshot](examples/custom_styles.png)
117
97
 
118
- #### 11. Change the main menu of Decidim entirely!
98
+ #### 10. Change the main menu of Decidim entirely!
119
99
 
120
100
  Feel free to hide, modify or add items in the Decidim's main menu. You can also change the order, establish some conditions (like showing only for logged users) or open in a new window.
121
101
 
@@ -124,7 +104,7 @@ Feel free to hide, modify or add items in the Decidim's main menu. You can also
124
104
  ![Menu hacks screenshot](examples/menu-3.png)
125
105
  ![Menu hacks screenshot](examples/menu-4.png)
126
106
 
127
- #### 12. Assign admins to specific scopes and prevent them modify anything else
107
+ #### 11. Assign admins to specific scopes and prevent them modify anything else
128
108
 
129
109
  Convert any user on the platform (that is not currently an admin) to a limited subset of participatory spaces or event compoponents. Just add users to a box and scope them to some constraints. These users will se the "Edit" button in everywhere they have permissions. Any access to unallowed zones will redirect the user to the admin index page.
130
110
 
@@ -132,7 +112,7 @@ Convert any user on the platform (that is not currently an admin) to a limited s
132
112
  ![Scoped admins unauthorized](examples/scoped_admins_unauthorized.png)
133
113
  ![Scoped admins configuration](examples/scoped_admins_config.png)
134
114
 
135
- #### 13. Custom fields for proposals
115
+ #### 12. Custom fields for proposals
136
116
 
137
117
  Now admins can substitute the body of a proposal with a set of form fields.
138
118
  Edition is make with a Drag & Drop interface in the admin and can (and should) be scoped to apply only to certain proposal components.
@@ -143,6 +123,26 @@ Technically, the content is stored in the database as an XML document compatible
143
123
  ![Custom fields screenshot](examples/custom-fields-2.png)
144
124
  ![Custom fields screenshot](examples/custom-fields-1.gif)
145
125
 
126
+ #### 13. Custom Redirections (or URL shortener feature)
127
+
128
+ Admins can create custom paths that redirect to other places. Destinations can be internal absolute paths or external sites.
129
+ There's also possible to choose to sanitize (ie: remove) any query string or to maintain it (so you can decide to use).
130
+
131
+ For instance you can create a redirection like
132
+
133
+ * `/take-me-somewhere` => `/processes/canary-islands`
134
+
135
+ Using a link with a query string (ie: `/take-me-somewhere?locale=es`) that will redirect the user to:
136
+
137
+ * `/processes/canary-islands` if query string is sanitized
138
+ * `/processes/canary-islands?locale=es` if query string is not sanitized
139
+
140
+ > Redirections work only after all other routes have been processed, you cannot override an existing route.
141
+ > The admin panel comes with a button to check if the redirection works (meaning that no other route is used by te application).
142
+ > Non-working routes will simply be ignored.
143
+
144
+ ![Custom redirections screenshot](examples/custom-redirections.png)
145
+
146
146
  #### To be continued...
147
147
 
148
148
  We're not done! Please check the [issues](/Platoniq/decidim-module-decidim_awesome/issues) (and participate) to see what's on our mind
@@ -154,7 +154,7 @@ Also feel free to propose something! or even better send a PR!
154
154
  Add this line to your application's Gemfile:
155
155
 
156
156
  ```ruby
157
- gem "decidim-decidim_awesome", "~> 0.7.2"
157
+ gem "decidim-decidim_awesome"
158
158
  ```
159
159
 
160
160
  And then execute:
@@ -162,18 +162,44 @@ And then execute:
162
162
  ```bash
163
163
  bundle
164
164
  bundle exec rails decidim_decidim_awesome:install:migrations
165
+ bundle exec rails decidim_decidim_awesome:webpacker:install
165
166
  bundle exec rails db:migrate
166
167
  ```
167
168
 
169
+ > NOTE: the `decidim_decidim_awesome:webpacker:install` is only necessary for Decidim versions starting at 0.25.
170
+
171
+ If you are upgrading from a version prior to 0.8, make sure to visit the URL `/admin/decidim_awesome/checks` and run image migrations for the old images:
172
+
173
+ ![Check image migrations](examples/check_image_migrations.png)
174
+
175
+ If you are a system admin, you can also perform this task by executing this rake task in the console:
176
+
177
+ ```
178
+ RAILS_ENV=production bin/rails decidim_awesome:active_storage_migrations:migrate_from_carrierwave
179
+ ```
180
+
181
+ Or check your migration status with:
182
+ ```
183
+ RAILS_ENV=production bin/rails decidim_awesome:active_storage_migrations:check_migration_from_carrierwave
184
+ ```
185
+
186
+ The correct version of Decidim Awesome should resolved automatically by the Bundler.
187
+ However you can force some specific version using `gem "decidim-decidim_awesome", "~> 0.8.0"` in the Gemfile.
188
+
168
189
  Depending on your Decidim version, choose the corresponding Awesome version to ensure compatibility:
169
190
 
170
191
  | Awesome version | Compatible Decidim versions |
171
192
  |---|---|
172
- | 0.5.x | 0.21.x, 0.22.x |
173
- | 0.6.x | 0.22.x, 0.23.x |
193
+ | 0.8.x | 0.25.x, 0.26.x |
174
194
  | 0.7.x | 0.23.x, 0.24.x |
195
+ | 0.6.x | 0.22.x, 0.23.x |
196
+ | 0.5.x | 0.21.x, 0.22.x |
175
197
 
176
- > *Heads up!* version 0.7.1 requires database migrations! Don't forget the migrations step when updating.
198
+ > *Heads up!*
199
+ > * version 0.8.0 removes CSS Themes for tenants. If you have been using them you will have to manually migrate them to custom styles.
200
+ > * version 0.8.0 uses ActiveStorage, same as Decidim 0.25. 2 new rake task have been introduced to facilitate the migration: `bin/rails decidim_awesome:active_storage_migrations:check_migration_from_carrierwave` and
201
+ `bin/rails decidim_awesome:active_storage_migrations:migrate_from_carrierwave`
202
+ > * version 0.7.1 requires database migrations! Don't forget the migrations step when updating.
177
203
 
178
204
  ## Configuration
179
205
 
@@ -301,8 +327,8 @@ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal
301
327
  To test a specific apprasail configured version do the following:
302
328
 
303
329
  ```
304
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rake test_app
305
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rspec
330
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rake test_app
331
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rspec
306
332
  ```
307
333
 
308
334
  Note that the database user has to have rights to create and drop a database in
@@ -358,4 +384,4 @@ This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
358
384
 
359
385
  ## Credits
360
386
 
361
- This plugin has been developed by ![Platoniq](app/assets/images/decidim/decidim_awesome/platoniq-logo.png)
387
+ This plugin has been developed by ![Platoniq](app/packs/images/decidim/decidim_awesome/platoniq-logo.png)
data/Rakefile CHANGED
@@ -10,32 +10,30 @@ def install_module(path)
10
10
  end
11
11
  end
12
12
 
13
- def seed_db(path)
13
+ def override_webpacker_config_files(path)
14
14
  Dir.chdir(path) do
15
- system("bundle exec rake db:seed")
15
+ system("bundle exec rake decidim_decidim_awesome:webpacker:install")
16
16
  end
17
17
  end
18
18
 
19
- def copy_themes
20
- FileUtils.cp_r "lib/decidim/decidim_awesome/test/themes", "spec/decidim_dummy_app/app/assets/themes", verbose: true
19
+ def seed_db(path)
20
+ Dir.chdir(path) do
21
+ system("bundle exec rake db:seed")
22
+ end
21
23
  end
22
24
 
23
- def copy_headers
25
+ def copy_helpers
24
26
  FileUtils.mkdir_p "spec/decidim_dummy_app/app/views/v0.11", verbose: true
25
27
  FileUtils.cp_r "lib/decidim/decidim_awesome/test/layouts", "spec/decidim_dummy_app/app/views/v0.11/layouts", verbose: true
26
- end
27
-
28
- desc "copy test theme files"
29
- task :copy_themes do
30
- copy_themes
28
+ FileUtils.cp "lib/decidim/decidim_awesome/test/initializer.rb", "spec/decidim_dummy_app/config/initializers/decidim_awesome.rb", verbose: true
31
29
  end
32
30
 
33
31
  desc "Generates a dummy app for testing"
34
32
  task test_app: "decidim:generate_external_test_app" do
35
33
  ENV["RAILS_ENV"] = "test"
36
34
  install_module("spec/decidim_dummy_app")
37
- copy_themes
38
- copy_headers
35
+ override_webpacker_config_files("spec/decidim_dummy_app")
36
+ copy_helpers
39
37
  end
40
38
 
41
39
  desc "Generates a development app."
@@ -54,4 +52,5 @@ task :development_app do
54
52
 
55
53
  install_module("development_app")
56
54
  seed_db("development_app")
55
+ override_webpacker_config_files("development_app")
57
56
  end
@@ -0,0 +1,11 @@
1
+ <section class="wrapper-home map-block home-section">
2
+ <div class="row">
3
+ <div class="columns">
4
+ <div class="callout alert">
5
+ <p><%= t("unavailable", scope: "decidim.decidim_awesome.map_component.map.error") %></p>
6
+ </div>
7
+
8
+ <%= render partial: "decidim/decidim_awesome/map_component/map/api_ready.html" %>
9
+ </div>
10
+ </div>
11
+ </div>
@@ -6,67 +6,7 @@
6
6
  <div class="row">
7
7
  <div class="columns medium-12">
8
8
  <%= awesome_map_for global_map_components do %>
9
- <script id="marker-proposal-popup" type="text/x-jsrender">
10
- <div class="map-info__content">
11
- <h3>{{>title.translation}}</h3>
12
- <div id="bodyContent">
13
- <div class="description">{{:body.translation}}</div>
14
- <div class="map__date-adress">
15
- <div class="address card__extra">
16
- <div class="address__icon">{{:icon}}</div>
17
- <div class="address__details">
18
- <span>{{>address}}</span><br>
19
- </div>
20
- </div>
21
- </div>
22
- <div class="map-info__button">
23
- <a href="{{>link}}" class="button button--sc">
24
- <%= t("view_proposal", scope: "decidim.decidim_awesome.map_component.map.show") %>
25
- </a>
26
- </div>
27
- </div>
28
- </div>
29
- </script>
30
-
31
- <script id="marker-meeting-popup" type="text/x-jsrender">
32
- <div class="map-info__content">
33
- <h3>{{>title.translation}}</h3>
34
- <div id="bodyContent">
35
- <div class="description">{{:description.translation}}</div>
36
- <div class="map__date-adress">
37
- <div class="card__datetime">
38
- <div class="card__datetime__date">
39
- {{>startTimeDay}} <span class="card__datetime__month">{{>startTimeMonth}} {{>startTimeYear}}</span>
40
- </div>
41
- <div class="card__datetime__time">{{>starTime}}</div>
42
- </div>
43
- <div class="address card__extra">
44
- <div class="address__icon">{{:icon}}</div>
45
- <div class="address__details">
46
- <strong>{{:location.translation}}</strong><br>
47
- <span>{{>address}}</span><br>
48
- <span>{{:locationHints.translation}}</span>
49
- </div>
50
- </div>
51
- </div>
52
- <div class="map-info__button">
53
- <a href="{{>link}}" class="button button--sc">
54
- <%= t("decidim.meetings.meetings_map.view_meeting") %>
55
- </a>
56
- </div>
57
- </div>
58
- </div>
59
- </script>
60
-
61
- <style type="text/css">
62
- #awesome-map .leaflet-container {
63
- height: <%= model.settings.map_height %>px;
64
- }
65
- </style>
66
- <script>
67
- window.AwesomeMap = window.AwesomeMap || {};
68
- window.AwesomeMap.categories = <%= all_categories.to_json.html_safe %>;
69
- </script>
9
+ <%= render partial: "decidim/decidim_awesome/map_component/map/map_template.html", locals: { categories: all_categories, map_height: model.settings.map_height } %>
70
10
  <% end %>
71
11
  </div>
72
12
  </div>
@@ -4,6 +4,7 @@ module Decidim
4
4
  module DecidimAwesome
5
5
  module ContentBlocks
6
6
  class MapCell < Decidim::ViewModel
7
+ include Cell::ViewModel::Partial
7
8
  include Decidim::DecidimAwesome::MapHelper
8
9
  include Decidim::CardHelper
9
10
 
@@ -11,6 +12,16 @@ module Decidim
11
12
  delegate :settings, to: :model
12
13
  alias current_settings settings
13
14
 
15
+ def show
16
+ return error unless Decidim::Map.configured?
17
+
18
+ render
19
+ end
20
+
21
+ def error
22
+ render
23
+ end
24
+
14
25
  def hide_controls
15
26
  true
16
27
  end
@@ -19,10 +19,10 @@
19
19
  <div class="row two-buttons">
20
20
  <div>
21
21
  <%= settings_fields.text_field :map_center, label: t("map_center", scope: i18n_scope) %>
22
- <%= t("map_center_help", scope: i18n_scope) %>
22
+ <p class="help-text"><%= t("map_center_help", scope: i18n_scope) %></p>
23
23
  </div>
24
24
  <div><%= settings_fields.number_field :map_zoom, label: t("map_zoom", scope: i18n_scope) %>
25
- <%= t("map_zoom_help", scope: i18n_scope) %>
25
+ <p class="help-text"><%= t("map_zoom_help", scope: i18n_scope) %></p>
26
26
  </div>
27
27
  </div>
28
28
  <div class="row two-buttons">
@@ -42,8 +42,9 @@
42
42
  <div><%= settings_fields.check_box :show_evaluating, label: t("show_evaluating", scope: i18n_scope) %>
43
43
  </div>
44
44
  </div>
45
- <div class="row">
46
- <%= settings_fields.check_box :show_rejected, label: t("show_rejected", scope: i18n_scope) %>
45
+ <div class="row two-buttons">
46
+ <div><%= settings_fields.check_box :show_rejected, label: t("show_rejected", scope: i18n_scope) %></div>
47
+ <div><%= settings_fields.check_box :menu_merge_components, label: t("menu_merge_components", scope: i18n_scope) %></div>
47
48
  </div>
48
49
  <% end %>
49
50
 
@@ -58,4 +59,7 @@
58
59
  .two-buttons > div {
59
60
  width: 50%;
60
61
  }
62
+ .help-text {
63
+ margin-top: -1.5em;
64
+ }
61
65
  </style>
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class CreateCustomRedirect < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ def initialize(form)
10
+ @form = form
11
+ @redirections = AwesomeConfig.find_or_initialize_by(var: :custom_redirects, organization: form.current_organization)
12
+ end
13
+
14
+ # Executes the command. Broadcasts these events:
15
+ #
16
+ # - :ok when everything is valid.
17
+ # - :invalid if we couldn't proceed.
18
+ #
19
+ # Returns nothing.
20
+ def call
21
+ return broadcast(:invalid) if form.invalid?
22
+ return broadcast(:invalid, I18n.t("custom_redirects.origin_exists", scope: "decidim.decidim_awesome.admin")) if url_exists?
23
+
24
+ create_redirection!
25
+ broadcast(:ok)
26
+ rescue StandardError => e
27
+ broadcast(:invalid, e.message)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :form, :redirections
33
+
34
+ delegate :to_params, to: :form
35
+
36
+ def create_redirection!
37
+ redirections.value = {} unless redirections.value.is_a? Hash
38
+ redirections.value[to_params[0]] = to_params[1]
39
+ redirections.save!
40
+ end
41
+
42
+ def url_exists?
43
+ return false unless redirections
44
+ return false unless redirections.value.is_a? Hash
45
+
46
+ redirections.value[form.origin].present?
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class DestroyCustomRedirect < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # item - the redirections item to destroy
10
+ # organization
11
+ def initialize(item, organization)
12
+ @item = item
13
+ @organization = organization
14
+ @redirections = AwesomeConfig.find_by(var: :custom_redirects, organization: organization)
15
+ end
16
+
17
+ # Executes the command. Broadcasts these events:
18
+ #
19
+ # - :ok when everything is valid.
20
+ # - :invalid if we couldn't proceed.
21
+ #
22
+ # Returns nothing.
23
+ def call
24
+ return broadcast(:invalid) unless url_exists?
25
+
26
+ redirections.value&.except!(item.origin)
27
+ redirections.save!
28
+
29
+ broadcast(:ok, @item)
30
+ rescue StandardError => e
31
+ broadcast(:invalid, e.message)
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :organization, :item, :redirections
37
+
38
+ def url_exists?
39
+ return false unless redirections
40
+ return false unless redirections.value.is_a? Hash
41
+
42
+ redirections.value[item.origin].present?
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end