decidim-decidim_awesome 0.6.6 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +93 -36
  3. data/Rakefile +11 -12
  4. data/app/cells/decidim/decidim_awesome/content_blocks/map/error.erb +11 -0
  5. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +14 -0
  6. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +65 -0
  7. data/app/cells/decidim/decidim_awesome/content_blocks/map_form/show.erb +65 -0
  8. data/app/cells/decidim/decidim_awesome/content_blocks/map_form_cell.rb +19 -0
  9. data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +32 -0
  10. data/app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb +51 -0
  11. data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +45 -0
  12. data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +38 -0
  13. data/app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb +4 -0
  14. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +47 -0
  15. data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +40 -0
  16. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +40 -0
  17. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +1 -1
  18. data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +58 -0
  19. data/app/commands/decidim/decidim_awesome/admin/update_config.rb +5 -1
  20. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +49 -0
  21. data/app/commands/decidim/decidim_awesome/create_editor_image.rb +12 -5
  22. data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +58 -0
  23. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +15 -22
  24. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +41 -20
  25. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +4 -0
  26. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +91 -0
  27. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +7 -10
  28. data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +38 -0
  29. data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +38 -0
  30. data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +38 -0
  31. data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +19 -0
  32. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +2 -3
  33. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +1 -1
  34. data/app/controllers/decidim/decidim_awesome/map_component/map_controller.rb +2 -9
  35. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +52 -0
  36. data/app/forms/decidim/decidim_awesome/admin/constraint_form.rb +3 -1
  37. data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +45 -0
  38. data/app/forms/decidim/decidim_awesome/editor_image_form.rb +3 -2
  39. data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +38 -0
  40. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +32 -15
  41. data/app/helpers/decidim/decidim_awesome/admin/system_checker_helpers.rb +36 -0
  42. data/app/helpers/decidim/decidim_awesome/amendments_helper_override.rb +48 -0
  43. data/app/helpers/decidim/decidim_awesome/map_helper.rb +76 -57
  44. data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +78 -0
  45. data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +106 -0
  46. data/app/middleware/decidim/decidim_awesome/current_config.rb +182 -0
  47. data/app/models/decidim/decidim_awesome/awesome_config.rb +15 -0
  48. data/app/models/decidim/decidim_awesome/editor_image.rb +4 -9
  49. data/app/models/decidim/decidim_awesome/user_override.rb +25 -0
  50. data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +5 -0
  51. data/app/packs/entrypoints/decidim_admin_decidim_awesome.scss +1 -0
  52. data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +2 -0
  53. data/app/packs/entrypoints/decidim_decidim_awesome.js +9 -0
  54. data/app/packs/entrypoints/decidim_decidim_awesome.scss +1 -0
  55. data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +1 -0
  56. data/app/packs/entrypoints/decidim_decidim_awesome_custom_fields.js +1 -0
  57. data/app/packs/entrypoints/decidim_decidim_awesome_iframe.scss +1 -0
  58. data/app/packs/entrypoints/decidim_decidim_awesome_map.js +5 -0
  59. data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -0
  60. data/app/{assets → packs}/images/decidim/decidim_awesome/platoniq-logo.png +0 -0
  61. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +82 -0
  62. data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +48 -0
  63. data/app/packs/src/decidim/decidim_awesome/admin/codemirror.js +14 -0
  64. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +55 -0
  65. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +77 -0
  66. 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
  67. data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +24 -0
  68. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +23 -0
  69. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +17 -0
  70. 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
  71. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +131 -0
  72. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +59 -0
  73. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +52 -0
  74. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +130 -0
  75. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +112 -0
  76. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +31 -0
  77. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +88 -0
  78. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +221 -0
  79. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +51 -0
  80. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +190 -0
  81. data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +22 -0
  82. data/app/{assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 → packs/src/decidim/decidim_awesome/forms/autosave.js} +20 -17
  83. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +207 -0
  84. data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +107 -0
  85. data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +22 -0
  86. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +25 -0
  87. data/{vendor/assets/javascripts → app/packs/src/vendor}/image-resize.min.js +0 -0
  88. data/{vendor/assets/javascripts → app/packs/src/vendor}/image-upload.min.js +0 -0
  89. data/app/packs/src/vendor/jquery.truncate.js +105 -0
  90. data/app/packs/src/vendor/leaflet.featuregroup.subgroup.js +184 -0
  91. data/app/packs/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +16 -0
  92. data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +28 -0
  93. data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +29 -0
  94. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/admin/constraints.scss +21 -9
  95. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +93 -0
  96. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +41 -0
  97. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +71 -0
  98. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +19 -0
  99. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +3 -3
  100. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +176 -0
  101. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +6 -4
  102. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +58 -0
  103. data/app/{assets → packs}/stylesheets/decidim/decidim_awesome/forms/autosave.scss +2 -2
  104. data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +348 -0
  105. data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +2 -0
  106. data/app/presenters/decidim/decidim_awesome/menu_item_presenter_override.rb +25 -0
  107. data/app/presenters/decidim/decidim_awesome/menu_presenter_override.rb +23 -0
  108. data/app/uploaders/decidim/cw/decidim_awesome/image_uploader.rb +26 -0
  109. data/app/uploaders/decidim/decidim_awesome/image_uploader.rb +4 -21
  110. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +28 -22
  111. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -0
  112. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +3 -3
  113. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +21 -0
  114. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +1 -3
  115. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +25 -0
  116. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +0 -2
  117. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +11 -12
  118. data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +1 -1
  119. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +3 -4
  120. data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +1 -1
  121. data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +6 -0
  122. data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +13 -0
  123. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +37 -0
  124. data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +13 -0
  125. data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +1 -1
  126. data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +1 -1
  127. data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +6 -0
  128. data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +6 -0
  129. data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +1 -1
  130. data/app/views/decidim/decidim_awesome/map_component/map/_api_ready.html.erb +3 -0
  131. data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +68 -0
  132. data/app/views/decidim/decidim_awesome/map_component/map/{error.erb → error.html.erb} +2 -0
  133. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +3 -96
  134. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +101 -0
  135. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +83 -0
  136. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -0
  137. data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +34 -16
  138. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +6 -1
  139. data/app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb +1 -1
  140. data/app/views/v0.25/decidim/proposals/collaborative_drafts/_show.html.erb +128 -0
  141. data/app/views/{v0.23 → v0.25}/layouts/decidim/_head.html.erb +12 -10
  142. data/app/views/v0.25/layouts/decidim/admin/_header.html.erb +11 -0
  143. data/app/views/v0.26/decidim/proposals/collaborative_drafts/_show.html.erb +128 -0
  144. data/app/views/{v0.22 → v0.26}/layouts/decidim/_head.html.erb +18 -10
  145. data/app/views/v0.26/layouts/decidim/admin/_header.html.erb +11 -0
  146. data/config/assets.rb +46 -0
  147. data/config/i18n-tasks.yml +6 -0
  148. data/config/locales/ca.yml +147 -13
  149. data/config/locales/cs.yml +137 -3
  150. data/config/locales/en.yml +170 -11
  151. data/config/locales/es.yml +136 -2
  152. data/config/locales/eu.yml +1 -161
  153. data/config/locales/fr.yml +276 -142
  154. data/config/locales/it.yml +346 -0
  155. data/config/locales/ja.yml +345 -0
  156. data/config/locales/nl.yml +167 -136
  157. data/config/locales/pt-BR.yml +346 -0
  158. data/config/locales/pt-PT.yml +7 -0
  159. data/config/locales/pt.yml +7 -0
  160. data/config/locales/sv.yml +109 -152
  161. data/db/migrate/20210628150825_change_awesome_config_var_type.rb +12 -0
  162. data/lib/decidim/decidim_awesome/admin_engine.rb +19 -12
  163. data/lib/decidim/decidim_awesome/awesome.rb +214 -0
  164. data/lib/decidim/decidim_awesome/awesome_helpers.rb +17 -17
  165. data/lib/decidim/decidim_awesome/checksums.yml +23 -16
  166. data/lib/decidim/decidim_awesome/config.rb +55 -9
  167. data/lib/decidim/decidim_awesome/content_parsers/editor_images_parser.rb +39 -0
  168. data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +27 -21
  169. data/lib/decidim/decidim_awesome/custom_fields.rb +94 -0
  170. data/lib/decidim/decidim_awesome/engine.rb +42 -14
  171. data/lib/decidim/decidim_awesome/iframe_component/admin_engine.rb +23 -0
  172. data/lib/decidim/decidim_awesome/iframe_component/component.rb +6 -6
  173. data/lib/decidim/decidim_awesome/map_component/admin_engine.rb +23 -0
  174. data/lib/decidim/decidim_awesome/map_component/component.rb +13 -6
  175. data/lib/decidim/decidim_awesome/map_component/engine.rb +34 -0
  176. data/lib/decidim/decidim_awesome/menu_hacker.rb +2 -1
  177. data/lib/decidim/decidim_awesome/system_checker.rb +1 -1
  178. data/lib/decidim/decidim_awesome/test/factories.rb +2 -2
  179. data/lib/decidim/decidim_awesome/test/initializer.rb +25 -0
  180. data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +30 -2
  181. data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +7 -2
  182. data/lib/decidim/decidim_awesome/test/shared_examples/box_label_editor.rb +116 -0
  183. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +18 -0
  184. data/lib/decidim/decidim_awesome/test/shared_examples/controller_examples.rb +13 -0
  185. data/lib/decidim/decidim_awesome/test/shared_examples/current_config_examples.rb +143 -0
  186. data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +47 -0
  187. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +4 -0
  188. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +0 -17
  189. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +420 -0
  190. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +202 -0
  191. data/lib/decidim/decidim_awesome/version.rb +2 -2
  192. data/lib/decidim/decidim_awesome.rb +4 -119
  193. data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +37 -0
  194. data/lib/tasks/decidim_awesome_webpacker_tasks.rake +62 -0
  195. metadata +148 -83
  196. data/app/assets/config/decidim_admin_decidim_awesome_manifest.css +0 -3
  197. data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +0 -2
  198. data/app/assets/config/decidim_decidim_awesome_manifest.css +0 -5
  199. data/app/assets/config/decidim_decidim_awesome_manifest.js +0 -3
  200. data/app/assets/images/decidim/decidim_awesome/loading.gif +0 -0
  201. data/app/assets/javascripts/decidim/decidim_awesome/admin/constraints.js.es6 +0 -54
  202. data/app/assets/javascripts/decidim/decidim_awesome/admin.js +0 -2
  203. data/app/assets/javascripts/decidim/decidim_awesome/application.js +0 -4
  204. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/categories.js.es6 +0 -25
  205. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/legacy_map.js.es6 +0 -225
  206. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/legacy_proposals.js.es6 +0 -82
  207. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +0 -215
  208. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +0 -131
  209. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +0 -94
  210. data/app/assets/javascripts/decidim/decidim_awesome/editors/markdown_view.js.es6 +0 -12
  211. data/app/assets/javascripts/decidim/decidim_awesome/editors/quill_editor.js.es6 +0 -160
  212. data/app/assets/javascripts/decidim/decidim_awesome/proposals/images.js.es6 +0 -25
  213. data/app/assets/stylesheets/decidim/decidim_awesome/admin.scss +0 -49
  214. data/app/assets/stylesheets/decidim/decidim_awesome/application.scss +0 -8
  215. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/leaflet.scss.erb +0 -9
  216. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +0 -66
  217. data/app/assets/stylesheets/decidim/decidim_awesome/editors/markdown_view.scss +0 -27
  218. data/app/assets/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -7
  219. data/app/awesome_overrides/presenters/decidim/menu_presenter_override.rb +0 -39
  220. data/app/awesome_overrides/presenters/decidim/proposals/proposal_presenter_override.rb +0 -64
  221. data/app/controllers/decidim/decidim_awesome/iframe_component/application_controller.rb +0 -15
  222. data/app/controllers/decidim/decidim_awesome/map_component/application_controller.rb +0 -15
  223. data/app/views/v0.22/layouts/decidim/admin/_header.html.erb +0 -11
  224. data/app/views/v0.23/layouts/decidim/admin/_header.html.erb +0 -12
  225. data/lib/decidim/decidim_awesome/content_renderers/markdown_renderer.rb +0 -18
  226. data/lib/decidim/decidim_awesome/content_renderers.rb +0 -9
  227. data/lib/decidim/decidim_awesome/test/themes/css.lvh.me.css +0 -3
  228. data/lib/decidim/decidim_awesome/test/themes/erb.lvh.me.scss.erb +0 -2
  229. data/lib/decidim/decidim_awesome/test/themes/scss.lvh.me.scss +0 -1
  230. data/lib/decidim/decidim_awesome/test/themes/test-theme/body.scss +0 -4
  231. data/vendor/assets/images/layers-2x.png +0 -0
  232. data/vendor/assets/images/layers.png +0 -0
  233. data/vendor/assets/images/marker-icon.png +0 -0
  234. data/vendor/assets/javascripts/codemirror-4.inline-attachment.js +0 -89
  235. data/vendor/assets/javascripts/form-storage.js +0 -824
  236. data/vendor/assets/javascripts/highlight.min.js +0 -44
  237. data/vendor/assets/javascripts/inline-attachment.js +0 -399
  238. data/vendor/assets/javascripts/inscrybmde.min.js +0 -7
  239. data/vendor/assets/javascripts/jquery.inline-attachment.js +0 -66
  240. data/vendor/assets/javascripts/jsrender.min.js +0 -4
  241. data/vendor/assets/javascripts/leaflet.featuregroup.subgroup.js +0 -6
  242. data/vendor/assets/stylesheets/default.min.css +0 -1
  243. data/vendor/assets/stylesheets/foundation.min.css +0 -1
  244. data/vendor/assets/stylesheets/github.min.css +0 -2
  245. data/vendor/assets/stylesheets/inscrybmde.min.css +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f080eae1f34847934c143b7bdc9c091632701cb339f269754640d5f2a78f879
4
- data.tar.gz: 64f8f793914cf99e2f5ac37801039000936911799c518da44528698f6c3fba92
3
+ metadata.gz: 82220fe500241ed7230f9b9c75496674ba199a90692d9b1e1ef0988dcfe73d8e
4
+ data.tar.gz: c0067b640dcc77a30556266f04af28337711cc084d3bddfd8b45d9c9e3566657
5
5
  SHA512:
6
- metadata.gz: 507f43c02cfe83261c5e0caa656387aba8dc7ffa15a80c70305e71736e1aeebec90a6678f663ca4de854740f17ef2960a29f9d58caf980e1c0dbd534b1d0c46b
7
- data.tar.gz: 7398b5cacb4eed3ff628a7026c2934c089dcbe8b1cf9ff9cd22275228816fa1ddc9ba50909dbf4bccf4e0e671349517c8bea4485e8c3dd709868f17000ef55a2
6
+ metadata.gz: 13e277af1691dfe07af969b3422914e88738fddc84bbbe70bfdd029bf1abb04b618eac788fda19b8a802be612ccd27b145f9603f3f7032bdc10aef2c32f3ea28
7
+ data.tar.gz: d6710fa6ca902f9c03c2a8ccf8024b7770b12246fca1aa639a6e0d7eb657e88d68cf14c22169492236d6f496490a15f9aedb398bcdeefe14e41106b3a9f5d5cc
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Decidim::DecidimAwesome
2
2
 
3
- [![Build](https://github.com/Platoniq/decidim-module-decidim_awesome/workflows/Build/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions)
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)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/2dada53525dd5a944089/maintainability)](https://codeclimate.com/github/Platoniq/decidim-module-decidim_awesome/maintainability)
5
- [![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)
6
6
 
7
7
  Usability and UX tweaks for Decidim.
8
8
 
9
9
  This plugin allows the administrators to expand the possibilities of Decidim beyond some existing limitations.
10
10
  All tweaks are provided in a optional fashion with granular permissions that let the administrator to choose exactly where to apply those mods. Some tweaks can be applied to any assembly, other in an specific participatory process or even in type of component only.
11
11
 
12
- **This in beta status, we do not accept any responsibility for breaking anything. Feedback is appreciated though.**
12
+ **DISCLAIMER: This module is heavily tested and widely used, howevever we do not accept any responsibility for breaking anything. Feedback is appreciated though.**
13
13
 
14
14
  ## Why this plugin?
15
15
 
@@ -24,6 +24,8 @@ Because Decidim is awesome and so is this!
24
24
 
25
25
  Read the [CHANGELOG](CHANGELOG.md) for Decidim compatibility.
26
26
 
27
+ > **TL;DR people**: Jump to the [installation part](#installation)
28
+
27
29
  DecidimAwesome is a module that hacks Decidim in order to provide more features or improve some aspects of it.
28
30
 
29
31
  It generates and admin module that allows to choose what hacks to apply.
@@ -75,44 +77,25 @@ It also provides a simple search by category, each category is assigned to a dif
75
77
 
76
78
  ![Awesome map](examples/awesome-map.png)
77
79
 
78
- #### 7. Allow Decidim to use custom CSS themes for every tenant
79
-
80
- When customizing CSS for a Decidim installation, each change affects all the organizations (tenant).
81
-
82
- This feature allows to customize each organization css without affecting the others in the same Decidim installation.
83
-
84
- ##### To create a theme
85
-
86
- 1. Get your hostname for the organization, theme search will be based on this (e.g: `myorganization.com`)
87
- 2. Create in you Decidim application this folder: `app/assets/themes/`
88
- 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`)
89
- 4. Modify that file as you like, you can use any SASS function available (such as `@import`)
90
- 5. Restart your server, enjoy!
91
-
92
- See an example here:
93
- https://github.com/Platoniq/decidim-demo/tree/master/app/assets/themes
94
-
95
- NOTE: Files presents in the `app/assets/themes` folder are added automatically into the precompile list of Rails by this plugin.
96
-
97
- #### 8. Fullscreen Iframe component
80
+ #### 7. Fullscreen Iframe component
98
81
 
99
82
  Another simple component that can be used to embed and Iframe with any external content in it that fills all the viewport.
100
83
 
101
84
  ![Fullscreen iframe](examples/fullscreen-iframe.png)
102
85
 
103
- #### 9. Live support chat
86
+ #### 8. Live support chat
104
87
 
105
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).
106
89
 
107
90
  ![Intergram screenshot](examples/intergram.png)
108
91
 
109
- #### 10. Custom CSS applied only according scoped restrictions
92
+ #### 9. Custom CSS applied only according scoped restrictions
110
93
 
111
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!
112
95
 
113
96
  ![CSS screenshot](examples/custom_styles.png)
114
97
 
115
- #### 11. Change the main menu of Decidim entirely!
98
+ #### 10. Change the main menu of Decidim entirely!
116
99
 
117
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.
118
101
 
@@ -121,21 +104,57 @@ Feel free to hide, modify or add items in the Decidim's main menu. You can also
121
104
  ![Menu hacks screenshot](examples/menu-3.png)
122
105
  ![Menu hacks screenshot](examples/menu-4.png)
123
106
 
107
+ #### 11. Assign admins to specific scopes and prevent them modify anything else
108
+
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.
110
+
111
+ ![Scoped admins authorized](examples/scoped_admins_authorized.png)
112
+ ![Scoped admins unauthorized](examples/scoped_admins_unauthorized.png)
113
+ ![Scoped admins configuration](examples/scoped_admins_config.png)
114
+
115
+ #### 12. Custom fields for proposals
116
+
117
+ Now admins can substitute the body of a proposal with a set of form fields.
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.
119
+
120
+ Technically, the content is stored in the database as an XML document compatible with normal HTML (it uses the DL/DT/DD elements).
121
+
122
+ ![Custom fields screenshot](examples/custom-fields-1.png)
123
+ ![Custom fields screenshot](examples/custom-fields-2.png)
124
+ ![Custom fields screenshot](examples/custom-fields-1.gif)
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
+
124
146
  #### To be continued...
125
147
 
126
- Some things in the road-map:
148
+ We're not done! Please check the [issues](/Platoniq/decidim-module-decidim_awesome/issues) (and participate) to see what's on our mind
127
149
 
128
- 1. Improve the conversation in comments by allowing images
129
- 1. Allow to create non-private surveys where the responding user is known by admins
130
- 1. Manipulate menus (reorder, change texts, add new items)
131
- 1. Propose something! or even better send a PR!
150
+ Also feel free to propose something! or even better send a PR!
132
151
 
133
152
  ## Installation
134
153
 
135
154
  Add this line to your application's Gemfile:
136
155
 
137
156
  ```ruby
138
- gem "decidim-decidim_awesome", "~> 0.6.6"
157
+ gem "decidim-decidim_awesome"
139
158
  ```
140
159
 
141
160
  And then execute:
@@ -143,15 +162,45 @@ And then execute:
143
162
  ```bash
144
163
  bundle
145
164
  bundle exec rails decidim_decidim_awesome:install:migrations
165
+ bundle exec rails decidim_decidim_awesome:webpacker:install
146
166
  bundle exec rails db:migrate
147
167
  ```
148
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
+
187
+ The correct version of Decidim Awesome should resolved automatically by the Bundler.
188
+ However you can force some specific version using `gem "decidim-decidim_awesome", "~> 0.8.0"` in the Gemfile.
189
+
149
190
  Depending on your Decidim version, choose the corresponding Awesome version to ensure compatibility:
150
191
 
151
192
  | Awesome version | Compatible Decidim versions |
152
193
  |---|---|
153
- | 0.5.x | 0.21.x, 0.22.x |
194
+ | 0.8.x | 0.25.x, 0.26.x |
195
+ | 0.7.x | 0.23.x, 0.24.x |
154
196
  | 0.6.x | 0.22.x, 0.23.x |
197
+ | 0.5.x | 0.21.x, 0.22.x |
198
+
199
+ > *Heads up!*
200
+ > * 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.
201
+ > * 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
202
+ `bin/rails decidim_awesome:active_storage_migrations:migrate_from_carrierwave`
203
+ > * version 0.7.1 requires database migrations! Don't forget the migrations step when updating.
155
204
 
156
205
  ## Configuration
157
206
 
@@ -160,6 +209,8 @@ admins do not even see it.
160
209
 
161
210
  In order to personalize default values, create an initializer such as:
162
211
 
212
+ > **NOTE**: this is not necessary unless you want to **disable** some features. All features are enabled by default.
213
+
163
214
  ```ruby
164
215
  # config/initializers/awesome_defaults.rb
165
216
 
@@ -173,6 +224,12 @@ Decidim::DecidimAwesome.configure do |config|
173
224
 
174
225
  # De-activated, admins don't even see it as an option
175
226
  config.use_markdown_editor = :disabled
227
+
228
+ # Disable scoped admins
229
+ config.scoped_admins = :disabled
230
+
231
+ # any other config var from lib/decidim/decidim_awesome.rb
232
+ ...
176
233
  end
177
234
  ```
178
235
 
@@ -271,8 +328,8 @@ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal
271
328
  To test a specific apprasail configured version do the following:
272
329
 
273
330
  ```
274
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rake test_app
275
- DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.23 rspec
331
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rake test_app
332
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal decidim-0.25 rspec
276
333
  ```
277
334
 
278
335
  Note that the database user has to have rights to create and drop a database in
@@ -328,4 +385,4 @@ This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
328
385
 
329
386
  ## Credits
330
387
 
331
- This plugin has been developed by ![Platoniq](app/assets/images/decidim/decidim_awesome/platoniq-logo.png)
388
+ 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>
@@ -0,0 +1,14 @@
1
+ <section class="wrapper-home map-block home-section">
2
+ <div class="row">
3
+
4
+ <%= section_title %></h3>
5
+
6
+ <div class="row">
7
+ <div class="columns medium-12">
8
+ <%= awesome_map_for global_map_components do %>
9
+ <%= render partial: "decidim/decidim_awesome/map_component/map/map_template.html", locals: { categories: all_categories, map_height: model.settings.map_height } %>
10
+ <% end %>
11
+ </div>
12
+ </div>
13
+ </div>
14
+ </section>
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module ContentBlocks
6
+ class MapCell < Decidim::ViewModel
7
+ include Cell::ViewModel::Partial
8
+ include Decidim::DecidimAwesome::MapHelper
9
+ include Decidim::CardHelper
10
+
11
+ delegate :snippets, to: :controller
12
+ delegate :settings, to: :model
13
+ alias current_settings settings
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
+
25
+ def hide_controls
26
+ true
27
+ end
28
+
29
+ def all_categories
30
+ return if @all_categories.present?
31
+
32
+ @category_ids ||= Decidim::Category.pluck(:id, :decidim_participatory_space_type, :decidim_participatory_space_id).select do |category|
33
+ _id, space_type, space_id = category
34
+ space = space_type.constantize.find(space_id)
35
+ space.organization == current_organization
36
+ end.map(&:first)
37
+
38
+ @all_categories ||= Decidim::Category.where(id: @category_ids)
39
+ end
40
+
41
+ def global_map_components
42
+ @global_map_components ||= Decidim::Component.where(manifest_name: [:meetings, :proposals]).published.filter do |component|
43
+ case component.manifest.name
44
+ when :meetings
45
+ true
46
+ when :proposals
47
+ component.settings.geocoding_enabled
48
+ else
49
+ false
50
+ end
51
+ end
52
+ end
53
+
54
+ def section_title
55
+ return if model.settings.title.blank?
56
+ return if model.settings.title.values.join.blank?
57
+
58
+ content_tag :h3, class: "section-heading" do
59
+ translated_attribute(model.settings.title)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,65 @@
1
+ <% form.fields_for :settings, form.object.settings do |settings_fields| %>
2
+ <h3><%= t("text_settings", scope: i18n_scope) %></h3>
3
+
4
+ <div class="row">
5
+ <%= settings_fields.translated :text_field, :title, label: t("title", scope: i18n_scope) %>
6
+ </div>
7
+
8
+ <h3 class="mt-m"><%= t("map_settings", scope: i18n_scope) %></h3>
9
+
10
+ <div class="row two-buttons">
11
+ <div>
12
+ <%= settings_fields.number_field :truncate, label: t("truncate", scope: i18n_scope) %>
13
+ </div>
14
+ <div>
15
+ <%= settings_fields.number_field :map_height, label: t("map_height", scope: i18n_scope) %>
16
+ </div>
17
+ </div>
18
+
19
+ <div class="row two-buttons">
20
+ <div>
21
+ <%= settings_fields.text_field :map_center, label: t("map_center", scope: i18n_scope) %>
22
+ <p class="help-text"><%= t("map_center_help", scope: i18n_scope) %></p>
23
+ </div>
24
+ <div><%= settings_fields.number_field :map_zoom, label: t("map_zoom", scope: i18n_scope) %>
25
+ <p class="help-text"><%= t("map_zoom_help", scope: i18n_scope) %></p>
26
+ </div>
27
+ </div>
28
+ <div class="row two-buttons">
29
+ <div>
30
+ <%= settings_fields.check_box :menu_amendments, label: t("menu_amendments", scope: i18n_scope) %>
31
+ </div>
32
+ <div><%= settings_fields.check_box :menu_meetings, label: t("menu_meetings", scope: i18n_scope) %>
33
+ </div>
34
+ </div>
35
+ <div class="row two-buttons">
36
+ <div><%= settings_fields.check_box :show_not_answered, label: t("show_not_answered", scope: i18n_scope) %></div>
37
+ <div><%= settings_fields.check_box :show_accepted, label: t("show_accepted", scope: i18n_scope) %>
38
+ </div>
39
+ </div>
40
+ <div class="row two-buttons">
41
+ <div><%= settings_fields.check_box :show_withdrawn, label: t("show_withdrawn", scope: i18n_scope) %></div>
42
+ <div><%= settings_fields.check_box :show_evaluating, label: t("show_evaluating", scope: i18n_scope) %>
43
+ </div>
44
+ </div>
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>
48
+ </div>
49
+ <% end %>
50
+
51
+ <style>
52
+ .two-buttons {
53
+ width: 100%;
54
+ display: flex;
55
+ justify-content: center;
56
+ align-items: center;
57
+ gap: 1em;
58
+ }
59
+ .two-buttons > div {
60
+ width: 50%;
61
+ }
62
+ .help-text {
63
+ margin-top: -1.5em;
64
+ }
65
+ </style>
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module ContentBlocks
6
+ class MapFormCell < Decidim::ViewModel
7
+ alias form model
8
+
9
+ def content_block
10
+ options[:content_block]
11
+ end
12
+
13
+ def i18n_scope
14
+ "decidim.decidim_awesome.content_blocks.map"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ module NeedsConstraintHelpers
7
+ private
8
+
9
+ def create_constraint_never(var)
10
+ settings = { "participatory_space_manifest" => "none" }
11
+ subconfig = AwesomeConfig.find_or_initialize_by(var: "#{var}_#{@ident}", organization: @organization)
12
+ @constraint = ConfigConstraint.create!(
13
+ awesome_config: subconfig,
14
+ settings: settings
15
+ )
16
+ end
17
+
18
+ def constraint_can_be_destroyed?(constraint)
19
+ return true if constraint.awesome_config.blank?
20
+ return true if constraint.awesome_config.constraints.count > 1
21
+
22
+ case constraint.awesome_config.var.to_s
23
+ when /^proposal_custom_field/
24
+ false
25
+ else
26
+ true
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -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,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class CreateProposalCustomField < Rectify::Command
7
+ include NeedsConstraintHelpers
8
+
9
+ # Public: Initializes the command.
10
+ #
11
+ def initialize(organization)
12
+ @organization = organization
13
+ @ident = rand(36**8).to_s(36)
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid.
19
+ # - :invalid if we couldn't proceed.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ fields = AwesomeConfig.find_or_initialize_by(var: :proposal_custom_fields, organization: @organization)
24
+ fields.value = {} unless fields.value.is_a? Hash
25
+ # TODO: prevent (unlikely) colisions with exisiting values
26
+ fields.value[@ident] = default_definition
27
+ fields.save!
28
+
29
+ create_constraint_never(:proposal_custom_field)
30
+
31
+ broadcast(:ok, @ident)
32
+ rescue StandardError => e
33
+ broadcast(:invalid, e.message)
34
+ end
35
+
36
+ private
37
+
38
+ def default_definition
39
+ # '[{"type":"textarea","required":true,"label":"Body","className":"form-control","name":"body","subtype":"textarea"}]'
40
+ "[]"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ class CreateScopedAdmin < Rectify::Command
7
+ include NeedsConstraintHelpers
8
+
9
+ # Public: Initializes the command.
10
+ #
11
+ def initialize(organization)
12
+ @organization = organization
13
+ @ident = rand(36**8).to_s(36)
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid.
19
+ # - :invalid if we couldn't proceed.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ admins = AwesomeConfig.find_or_initialize_by(var: :scoped_admins, organization: @organization)
24
+ admins.value = {} unless admins.value.is_a? Hash
25
+ # TODO: prevent (unlikely) colisions with exisiting values
26
+ admins.value[@ident] = []
27
+ admins.save!
28
+
29
+ create_constraint_never(:scoped_admin)
30
+
31
+ broadcast(:ok, @ident)
32
+ rescue StandardError => e
33
+ broadcast(:invalid, e.message)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -4,6 +4,8 @@ module Decidim
4
4
  module DecidimAwesome
5
5
  module Admin
6
6
  class DestroyConstraint < Rectify::Command
7
+ include NeedsConstraintHelpers
8
+
7
9
  # Public: Initializes the command.
8
10
  #
9
11
  # constraint - A constraint constraint
@@ -18,6 +20,8 @@ module Decidim
18
20
  #
19
21
  # Returns nothing.
20
22
  def call
23
+ return broadcast(:invalid, I18n.t("cannot_be_destroyed", scope: "decidim.decidim_awesome.admin.config.constraints")) unless constraint_can_be_destroyed?(constraint)
24
+
21
25
  constraint.destroy!
22
26
  broadcast(:ok)
23
27
  rescue StandardError => e