decidim-decidim_awesome 0.10.2 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/README.md +177 -60
  4. data/app/cells/concerns/decidim/decidim_awesome/global_menu_cell_override.rb +20 -0
  5. data/app/cells/concerns/decidim/decidim_awesome/proposal_l_cell_override.rb +24 -0
  6. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +5 -12
  7. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +9 -5
  8. data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +54 -0
  9. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/modal.erb +18 -0
  10. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +37 -32
  11. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb +9 -4
  12. data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +2 -2
  13. data/app/commands/concerns/decidim/decidim_awesome/proposals/admin/update_proposal_override.rb +31 -0
  14. data/app/commands/concerns/decidim/decidim_awesome/proposals/create_collaborative_draft_override.rb +27 -0
  15. data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +27 -0
  16. data/app/commands/concerns/decidim/decidim_awesome/proposals/update_collaborative_draft_override.rb +27 -0
  17. data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +26 -0
  18. data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +1 -1
  19. data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +4 -3
  20. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +1 -1
  21. data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +1 -1
  22. data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +6 -3
  23. data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +1 -1
  24. data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +1 -1
  25. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +2 -2
  26. data/app/commands/decidim/decidim_awesome/command.rb +1 -7
  27. data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +43 -0
  28. data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +4 -3
  29. data/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb +34 -0
  30. data/app/controllers/concerns/decidim/decidim_awesome/limit_pending_amendments.rb +35 -0
  31. data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +1 -1
  32. data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +9 -22
  33. data/app/controllers/concerns/decidim/decidim_awesome/proposals/proposal_votes_controller_override.rb +3 -3
  34. data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
  35. data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +2 -0
  36. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +14 -10
  37. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +10 -9
  38. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +23 -20
  39. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +6 -10
  40. data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +76 -0
  41. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +6 -10
  42. data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +14 -6
  43. data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +2 -2
  44. data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +2 -2
  45. data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +8 -3
  46. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +3 -3
  47. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +18 -5
  48. data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +21 -0
  49. data/app/forms/{decidim → concerns/decidim}/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +2 -1
  50. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +28 -14
  51. data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +2 -2
  52. data/app/forms/decidim/decidim_awesome/admin/intergram_form.rb +4 -0
  53. data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +4 -4
  54. data/app/helpers/concerns/decidim/decidim_awesome/amendments_helper_override.rb +65 -0
  55. data/app/helpers/concerns/decidim/decidim_awesome/breadcrumb_helper_override.rb +23 -0
  56. data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +110 -0
  57. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +6 -27
  58. data/app/helpers/decidim/decidim_awesome/map_helper.rb +8 -27
  59. data/app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb +22 -0
  60. data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +5 -4
  61. data/app/middleware/decidim/decidim_awesome/current_config.rb +3 -5
  62. data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +39 -10
  63. data/app/models/decidim/decidim_awesome/awesome_config.rb +1 -1
  64. data/app/models/decidim/decidim_awesome/paper_trail_version.rb +8 -4
  65. data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +35 -1
  66. data/app/models/decidim/decidim_awesome/vote_weight.rb +2 -2
  67. data/app/overrides/decidim/proposals/admin/proposals/show/add_private_body.html.erb.deface +7 -0
  68. data/app/overrides/decidim/proposals/admin/proposals/show/replace_body.html.erb.deface +5 -0
  69. data/app/overrides/decidim/proposals/proposals/_proposal_aside/limit_amendments_modal.html.erb.deface +5 -0
  70. data/app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface +1 -1
  71. data/app/overrides/layouts/decidim/_decidim_javascript/add_awesome_tags.html.erb.deface +6 -0
  72. data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +4 -11
  73. data/app/overrides/layouts/decidim/admin/_header/{replace_scripts.html.erb.deface → add_awesome_tags.html.erb.deface} +4 -4
  74. data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +1 -2
  75. data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.js +4 -0
  76. data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.scss +1 -0
  77. data/app/packs/entrypoints/decidim_decidim_awesome.js +2 -2
  78. data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -1
  79. data/app/packs/entrypoints/decidim_editor.js +14 -0
  80. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +96 -69
  81. data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +46 -41
  82. data/app/packs/src/decidim/decidim_awesome/admin/codemirror.js +3 -3
  83. data/app/packs/src/decidim/decidim_awesome/admin/constraint_form_events.js +115 -0
  84. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +9 -5
  85. data/app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js +22 -11
  86. data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +26 -8
  87. data/app/packs/src/decidim/decidim_awesome/admin/tabs_change.js +31 -0
  88. data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +34 -21
  89. data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +28 -0
  90. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +5 -16
  91. data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +1 -0
  92. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +1 -15
  93. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +33 -11
  94. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +9 -12
  95. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +28 -0
  96. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +3 -4
  97. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +12 -12
  98. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +11 -7
  99. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +6 -13
  100. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +51 -20
  101. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +27 -18
  102. data/app/packs/src/decidim/decidim_awesome/editor/index.js +94 -0
  103. data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +28 -23
  104. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +29 -25
  105. data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +27 -32
  106. data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +31 -15
  107. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +16 -10
  108. data/app/packs/src/decidim/decidim_awesome/voting/voting_cards.js +47 -38
  109. data/app/packs/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +11 -12
  110. data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +15 -0
  111. data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +24 -12
  112. data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +49 -29
  113. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +28 -71
  114. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_styles.scss +48 -0
  115. data/app/packs/stylesheets/decidim/decidim_awesome/admin/intergram_fixes.scss +11 -0
  116. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +17 -26
  117. data/app/packs/stylesheets/decidim/decidim_awesome/amendments/modal.scss +5 -0
  118. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +11 -49
  119. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +19 -0
  120. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +4 -19
  121. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +1 -1
  122. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +41 -35
  123. data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +6 -6
  124. data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +118 -0
  125. data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +26 -0
  126. data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +41 -59
  127. data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +14 -3
  128. data/app/permissions/decidim/decidim_awesome/permissions.rb +3 -4
  129. data/app/presenters/concerns/decidim/decidim_awesome/breadcrumb_root_menu_item_presenter_override.rb +23 -0
  130. data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_item_presenter_override.rb +10 -2
  131. data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_presenter_override.rb +8 -0
  132. data/app/presenters/concerns/decidim/decidim_awesome/proposals/proposal_presenter_override.rb +20 -0
  133. data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +30 -0
  134. data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +1 -1
  135. data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +70 -0
  136. data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +1 -1
  137. data/app/queries/decidim/decidim_awesome/private_data_finder.rb +19 -0
  138. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +72 -0
  139. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +38 -0
  140. data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +34 -0
  141. data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +59 -0
  142. data/app/types/concerns/decidim/decidim_awesome/{proposal_type_override.rb → add_proposal_type_vote_weights.rb} +3 -1
  143. data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +23 -17
  144. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +50 -48
  145. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -2
  146. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +25 -18
  147. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +7 -6
  148. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +12 -16
  149. data/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb +39 -23
  150. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +35 -17
  151. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_private_custom_fields.html.erb +1 -0
  152. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +68 -80
  153. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +16 -12
  154. data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +8 -6
  155. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +22 -12
  156. data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +1 -49
  157. data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +14 -9
  158. data/app/views/decidim/decidim_awesome/admin/constraints/show.html.erb +14 -9
  159. data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +20 -5
  160. data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +5 -5
  161. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +14 -13
  162. data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +5 -5
  163. data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +44 -0
  164. data/app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb +44 -0
  165. data/app/views/decidim/decidim_awesome/admin/menu_hacks/_form.html.erb +6 -6
  166. data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +21 -12
  167. data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +39 -42
  168. data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +21 -12
  169. data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +8 -5
  170. data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +20 -0
  171. data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +14 -18
  172. data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +23 -0
  173. data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +8 -2
  174. data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +7 -12
  175. data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +53 -37
  176. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +14 -5
  177. data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_vote_button.html.erb +0 -3
  178. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +9 -7
  179. data/app/views/layouts/decidim/decidim_awesome/_intergram_widget.html.erb +9 -6
  180. data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +12 -0
  181. data/app/views/layouts/decidim/decidim_awesome/admin/application.html.erb +1 -73
  182. data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +19 -0
  183. data/config/assets.rb +3 -33
  184. data/config/i18n-tasks.yml +23 -3
  185. data/config/locales/ca.yml +110 -23
  186. data/config/locales/cs.yml +121 -19
  187. data/config/locales/de.yml +61 -20
  188. data/config/locales/en.yml +125 -35
  189. data/config/locales/es.yml +109 -22
  190. data/config/locales/eu.yml +22 -5
  191. data/config/locales/fr.yml +107 -20
  192. data/config/locales/hu.yml +53 -12
  193. data/config/locales/it.yml +22 -20
  194. data/config/locales/ja.yml +107 -20
  195. data/config/locales/lt.yml +0 -8
  196. data/config/locales/nl.yml +16 -17
  197. data/config/locales/pt-BR.yml +23 -20
  198. data/config/locales/pt-PT.yml +0 -1
  199. data/config/locales/ro-RO.yml +11 -7
  200. data/config/locales/sv.yml +24 -13
  201. data/config/rubocop/disabled.yml +11 -0
  202. data/config/rubocop/faker.yml +480 -0
  203. data/config/rubocop/rails.yml +88 -0
  204. data/config/rubocop/rspec.yml +65 -0
  205. data/config/rubocop/ruby.yml +1210 -0
  206. data/db/migrate/20240306175331_rename_editor_images_awesome_config.rb +18 -0
  207. data/db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb +29 -0
  208. data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +20 -0
  209. data/db/seeds.rb +3 -3
  210. data/lib/decidim/decidim_awesome/admin_engine.rb +26 -7
  211. data/lib/decidim/decidim_awesome/api/types/localized_custom_fields_type.rb +22 -0
  212. data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +51 -0
  213. data/lib/decidim/decidim_awesome/awesome.rb +74 -23
  214. data/lib/decidim/decidim_awesome/awesome_helpers.rb +6 -2
  215. data/lib/decidim/decidim_awesome/checksums.yml +47 -44
  216. data/lib/decidim/decidim_awesome/config.rb +1 -1
  217. data/lib/decidim/decidim_awesome/custom_fields.rb +13 -5
  218. data/lib/decidim/decidim_awesome/engine.rb +165 -56
  219. data/lib/decidim/decidim_awesome/iframe_component/component.rb +1 -2
  220. data/lib/decidim/decidim_awesome/lock.rb +47 -0
  221. data/lib/decidim/decidim_awesome/map_component/component.rb +1 -1
  222. data/lib/decidim/decidim_awesome/menu.rb +165 -0
  223. data/lib/decidim/decidim_awesome/menu_hacker.rb +4 -8
  224. data/lib/decidim/decidim_awesome/system_checker.rb +2 -4
  225. data/lib/decidim/decidim_awesome/test/factories.rb +10 -10
  226. data/lib/decidim/decidim_awesome/test/initializer.rb +7 -12
  227. data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +2 -2
  228. data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +2 -2
  229. data/lib/decidim/decidim_awesome/test/shared_examples/{box_label_editor.rb → box_label_editor_examples.rb} +17 -17
  230. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +23 -5
  231. data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +155 -0
  232. data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +7 -7
  233. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +42 -58
  234. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +9 -8
  235. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +32 -24
  236. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +97 -22
  237. data/lib/decidim/decidim_awesome/version.rb +2 -2
  238. data/lib/decidim/decidim_awesome/voting_manifest.rb +5 -10
  239. data/lib/decidim/decidim_awesome.rb +1 -2
  240. data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +1 -1
  241. data/lib/tasks/decidim_awesome_upgrade_tasks.rake +4 -0
  242. data/package.json +21 -30
  243. metadata +86 -63
  244. data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +0 -38
  245. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/show.erb +0 -15
  246. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/vote_button.erb +0 -15
  247. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter_cell.rb +0 -21
  248. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal/show.erb +0 -16
  249. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal_cell.rb +0 -20
  250. data/app/cells/decidim/proposals/proposal_m/footer.erb +0 -13
  251. data/app/helpers/decidim/decidim_awesome/amendments_helper_override.rb +0 -48
  252. data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +0 -78
  253. data/app/overrides/layouts/decidim/_head/add_awesome_legacy_scripts.rb +0 -14
  254. data/app/overrides/layouts/decidim/admin/_header/replace_styles.html.erb.deface +0 -3
  255. data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +0 -2
  256. data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +0 -1
  257. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +0 -55
  258. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +0 -218
  259. data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +0 -22
  260. data/app/packs/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +0 -19
  261. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -58
  262. data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +0 -348
  263. data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +0 -64
  264. data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +0 -11
  265. data/app/views/decidim/decidim_awesome/voting/voting_cards/_proposal_m_cell_footer.erb +0 -15
@@ -4,6 +4,7 @@ require "rails"
4
4
  require "deface"
5
5
  require "decidim/core"
6
6
  require "decidim/decidim_awesome/awesome_helpers"
7
+ require "decidim/decidim_awesome/menu"
7
8
 
8
9
  module Decidim
9
10
  module DecidimAwesome
@@ -26,46 +27,68 @@ module Decidim
26
27
  helper Decidim::LayoutHelper if respond_to?(:helper)
27
28
  end
28
29
  # Include additional helpers globally
29
- ActionView::Base.include(Decidim::DecidimAwesome::AwesomeHelpers)
30
+ ActiveSupport.on_load(:action_view) { include Decidim::DecidimAwesome::AwesomeHelpers }
30
31
  # Also for cells
31
32
  Decidim::ViewModel.include(Decidim::DecidimAwesome::AwesomeHelpers)
32
33
 
33
34
  # Override EtiquetteValidator
34
- EtiquetteValidator.include(Decidim::DecidimAwesome::EtiquetteValidatorOverride) if DecidimAwesome.enabled?([:validate_title_max_caps_percent,
35
- :validate_title_max_marks_together,
36
- :validate_title_start_with_caps,
37
- :validate_body_max_caps_percent,
38
- :validate_body_max_marks_together,
39
- :validate_body_start_with_caps])
35
+ EtiquetteValidator.include(Decidim::DecidimAwesome::EtiquetteValidatorOverride) if DecidimAwesome.enabled?(:validate_title_max_caps_percent,
36
+ :validate_title_max_marks_together,
37
+ :validate_title_start_with_caps,
38
+ :validate_body_max_caps_percent,
39
+ :validate_body_max_marks_together,
40
+ :validate_body_start_with_caps)
40
41
 
41
42
  # Custom fields need to deal with several places
42
- if DecidimAwesome.enabled?([:proposal_custom_fields,
43
- :validate_title_min_length,
44
- :validate_title_max_caps_percent,
45
- :validate_title_max_marks_together,
46
- :validate_title_start_with_caps,
47
- :validate_body_min_length,
48
- :validate_body_max_caps_percent,
49
- :validate_body_max_marks_together,
50
- :validate_body_start_with_caps])
43
+ if DecidimAwesome.enabled?(:proposal_custom_fields,
44
+ :proposal_private_custom_fields,
45
+ :validate_title_min_length,
46
+ :validate_title_max_caps_percent,
47
+ :validate_title_max_marks_together,
48
+ :validate_title_start_with_caps,
49
+ :validate_body_min_length,
50
+ :validate_body_max_caps_percent,
51
+ :validate_body_max_marks_together,
52
+ :validate_body_start_with_caps)
51
53
  Decidim::Proposals::ProposalWizardCreateStepForm.include(Decidim::DecidimAwesome::Proposals::ProposalWizardCreateStepFormOverride)
52
54
  end
53
55
 
54
- # override user's admin property
55
- Decidim::User.include(Decidim::DecidimAwesome::UserOverride) if DecidimAwesome.enabled?(:scoped_admins)
56
+ if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields)
57
+ Decidim::Proposals::ProposalWizardCreateStepForm.include(Decidim::DecidimAwesome::Proposals::ProposalFormOverride)
58
+ Decidim::Proposals::Admin::ProposalForm.include(Decidim::DecidimAwesome::Proposals::ProposalFormOverride)
59
+ Decidim::Proposals::ProposalPresenter.include(Decidim::DecidimAwesome::Proposals::ProposalPresenterOverride)
60
+ Decidim::Proposals::CreateProposal.include(Decidim::DecidimAwesome::Proposals::CreateProposalOverride)
61
+ Decidim::Proposals::CreateCollaborativeDraft.include(Decidim::DecidimAwesome::Proposals::CreateCollaborativeDraftOverride)
62
+ Decidim::Proposals::Admin::CreateProposal.include(Decidim::DecidimAwesome::Proposals::CreateProposalOverride)
63
+ Decidim::Proposals::UpdateProposal.include(Decidim::DecidimAwesome::Proposals::UpdateProposalOverride)
64
+ Decidim::Proposals::UpdateCollaborativeDraft.include(Decidim::DecidimAwesome::Proposals::UpdateCollaborativeDraftOverride)
65
+ Decidim::Proposals::Admin::UpdateProposal.include(Decidim::DecidimAwesome::Proposals::Admin::UpdateProposalOverride)
66
+ Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::AddProposalTypeCustomFields)
67
+ end
68
+
69
+ if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields, :weighted_proposal_voting)
70
+ # add vote weight/private_body to proposals
71
+ Decidim::Proposals::Proposal.include(Decidim::DecidimAwesome::HasProposalExtraFields)
72
+ Decidim::Proposals::CollaborativeDraft.include(Decidim::DecidimAwesome::HasProposalExtraFields)
73
+ end
56
74
 
57
75
  if DecidimAwesome.enabled?(:weighted_proposal_voting)
58
76
  # add vote weight to proposal vote
59
77
  Decidim::Proposals::ProposalVote.include(Decidim::DecidimAwesome::HasVoteWeight)
60
- # add vote weight cache to proposal
61
- Decidim::Proposals::Proposal.include(Decidim::DecidimAwesome::HasProposalExtraFields)
62
- Decidim::Proposals::ProposalSerializer.include(Decidim::DecidimAwesome::ProposalSerializerOverride)
63
- Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::ProposalTypeOverride)
64
- Decidim::Proposals::ProposalMCell.include(Decidim::DecidimAwesome::ProposalMCellOverride)
78
+ Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::AddProposalTypeVoteWeights)
79
+ Decidim::Proposals::ProposalLCell.include(Decidim::DecidimAwesome::ProposalLCellOverride)
65
80
  end
66
81
 
67
- Decidim::MenuPresenter.include(Decidim::DecidimAwesome::MenuPresenterOverride)
68
- Decidim::MenuItemPresenter.include(Decidim::DecidimAwesome::MenuItemPresenterOverride)
82
+ # override user's admin property
83
+ Decidim::User.include(Decidim::DecidimAwesome::UserOverride) if DecidimAwesome.enabled?(:scoped_admins)
84
+
85
+ if DecidimAwesome.enabled?(:menu, :content_block_main_menu)
86
+ Decidim::ContentBlocks::GlobalMenuCell.include(Decidim::DecidimAwesome::GlobalMenuCellOverride)
87
+ Decidim::BreadcrumbHelper.include(Decidim::DecidimAwesome::BreadcrumbHelperOverride)
88
+ Decidim::MenuPresenter.include(Decidim::DecidimAwesome::MenuPresenterOverride)
89
+ Decidim::MenuItemPresenter.include(Decidim::DecidimAwesome::MenuItemPresenterOverride)
90
+ Decidim::BreadcrumbRootMenuItemPresenter.include(Decidim::DecidimAwesome::BreadcrumbRootMenuItemPresenterOverride)
91
+ end
69
92
 
70
93
  # Late registering of components to take into account initializer values
71
94
  DecidimAwesome.registered_components.each do |manifest, block|
@@ -78,19 +101,29 @@ module Decidim
78
101
 
79
102
  initializer "decidim_decidim_awesome.overrides", after: "decidim.action_controller" do
80
103
  config.to_prepare do
104
+ # Auto-insert some csp directives
105
+ Decidim::ApplicationController.include(Decidim::DecidimAwesome::ContentSecurityPolicy)
106
+ Decidim::Admin::ApplicationController.include(Decidim::DecidimAwesome::ContentSecurityPolicy)
107
+
81
108
  # redirect unauthorized scoped admins to allowed places or custom redirects if configured
82
- Decidim::ErrorsController.include(Decidim::DecidimAwesome::NotFoundRedirect) if DecidimAwesome.enabled?([:scoped_admins, :custom_redirects])
109
+ Decidim::ErrorsController.include(Decidim::DecidimAwesome::NotFoundRedirect) if DecidimAwesome.enabled?(:scoped_admins, :custom_redirects)
83
110
 
84
111
  # Custom fields need to deal with several places
85
- if DecidimAwesome.enabled?(:proposal_custom_fields)
112
+ if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields)
86
113
  Decidim::Proposals::ApplicationHelper.include(Decidim::DecidimAwesome::Proposals::ApplicationHelperOverride)
87
114
  Decidim::AmendmentsHelper.include(Decidim::DecidimAwesome::AmendmentsHelperOverride)
88
115
  end
116
+ if DecidimAwesome.enabled?(:proposal_custom_fields, :proposal_private_custom_fields, :weighted_proposal_voting)
117
+ Decidim::Proposals::ProposalSerializer.include(Decidim::DecidimAwesome::Proposals::ProposalSerializerOverride)
118
+ Decidim::AdminLog::ComponentPresenter.include(Decidim::DecidimAwesome::AdminLog::ComponentPresenterOverride)
119
+ end
89
120
 
90
121
  if DecidimAwesome.enabled?(:weighted_proposal_voting)
91
122
  Decidim::Proposals::ProposalVotesController.include(Decidim::DecidimAwesome::Proposals::ProposalVotesControllerOverride)
92
123
  end
93
124
 
125
+ Decidim::AmendmentsController.include(Decidim::DecidimAwesome::LimitPendingAmendments) if DecidimAwesome.enabled?(:allow_limiting_amendments)
126
+
94
127
  Decidim::Proposals::ProposalsController.include(Decidim::DecidimAwesome::Proposals::OrderableOverride) if DecidimAwesome.enabled?(:additional_proposal_sortings)
95
128
  end
96
129
  end
@@ -99,14 +132,61 @@ module Decidim
99
132
  app.config.middleware.insert_after Decidim::Middleware::CurrentOrganization, Decidim::DecidimAwesome::CurrentConfig
100
133
  end
101
134
 
102
- initializer "decidim_decidim_awesome.additional_proposal_sortings" do |_app|
103
- if DecidimAwesome.enabled?(:additional_proposal_sortings)
104
- Decidim.component_registry.find(:proposals).tap do |component|
105
- component.settings(:global) do |settings|
106
- settings.attribute :default_sort_order, type: :select, default: "default", choices: -> { ["default"] + DecidimAwesome.possible_additional_proposal_sortings }
135
+ initializer "decidim_decidim_awesome.additional_proposal_options" do |_app|
136
+ Decidim.component_registry.find(:proposals).tap do |component|
137
+ component.settings(:global) do |settings|
138
+ if DecidimAwesome.enabled?(:additional_proposal_sortings)
139
+ settings.attribute(
140
+ :default_sort_order,
141
+ type: :select,
142
+ default: "default",
143
+ choices: -> { (POSSIBLE_SORT_ORDERS + DecidimAwesome.possible_additional_proposal_sortings).uniq }
144
+ )
107
145
  end
146
+ if DecidimAwesome.enabled?(:allow_limiting_amendments)
147
+ DecidimAwesome.hash_append!(
148
+ settings.attributes,
149
+ :amendments_enabled,
150
+ :limit_pending_amendments,
151
+ Decidim::SettingsManifest::Attribute.new(type: :boolean, default: DecidimAwesome.allow_limiting_amendments)
152
+ )
153
+ end
154
+ end
155
+
156
+ if DecidimAwesome.enabled?(:additional_proposal_sortings)
108
157
  component.settings(:step) do |settings|
109
- settings.attribute :default_sort_order, type: :select, include_blank: true, choices: -> { ["default"] + DecidimAwesome.possible_additional_proposal_sortings }
158
+ settings.attribute(
159
+ :default_sort_order,
160
+ type: :select,
161
+ include_blank: true,
162
+ choices: -> { (POSSIBLE_SORT_ORDERS + DecidimAwesome.possible_additional_proposal_sortings).uniq }
163
+ )
164
+ end
165
+ end
166
+
167
+ if DecidimAwesome.enabled?(:proposal_private_custom_fields)
168
+ # Add to the "proposals" component an exporter that is not
169
+ # included in open-data to be able to export all private fields
170
+ # from the administration without exposing data to the frontend.
171
+ component.exports :awesome_private_proposals do |exports|
172
+ exports.collection do |component_instance, user|
173
+ space = component_instance.participatory_space
174
+
175
+ collection = Decidim::Proposals::Proposal
176
+ .published
177
+ .not_hidden
178
+ .where(component: component_instance)
179
+ .includes(:scope, :category, :component)
180
+
181
+ if space.user_roles(:valuator).where(user:).any?
182
+ collection.with_valuation_assigned_to(user, space)
183
+ else
184
+ collection
185
+ end
186
+ end
187
+
188
+ exports.include_in_open_data = false
189
+ exports.serializer Decidim::DecidimAwesome::Proposals::PrivateProposalSerializer
110
190
  end
111
191
  end
112
192
  end
@@ -117,9 +197,9 @@ module Decidim
117
197
  # register available processors
118
198
  Decidim::DecidimAwesome.voting_registry.register(:voting_cards) do |voting|
119
199
  voting.show_vote_button_view = "decidim/decidim_awesome/voting/voting_cards/show_vote_button"
120
- voting.show_votes_count_view = "decidim/decidim_awesome/voting/voting_cards/show_votes_count"
121
- voting.show_votes_count_view = "" # hide votes count if needed
122
- voting.proposal_m_cell_footer = "decidim/decidim_awesome/voting/voting_cards/proposal_m_cell_footer"
200
+ # voting.show_votes_count_view = "decidim/decidim_awesome/voting/voting_cards/show_votes_count"
201
+ voting.show_votes_count_view = "" # hide votes count if not needed (in this case is integrated in the show_vote_button_view)
202
+ voting.proposal_metadata_cell = "decidim/decidim_awesome/voting/proposal_metadata"
123
203
  voting.weight_validator do |weight, context|
124
204
  allowed = [1, 2, 3]
125
205
  allowed << 0 if context[:proposal]&.component&.settings&.voting_cards_show_abstain
@@ -132,26 +212,43 @@ module Decidim
132
212
  next unless component
133
213
 
134
214
  component.settings(:global) do |settings|
135
- settings.attribute :awesome_voting_manifest,
136
- type: :select,
137
- default: "",
138
- choices: -> { ["default"] + Decidim::DecidimAwesome.voting_registry.manifests.map(&:name) },
139
- readonly: lambda { |context|
140
- Decidim::Proposals::Proposal.where(component: context[:component]).where.not(proposal_votes_count: 0).any?
141
- }
142
- settings.attribute :voting_cards_box_title,
143
- type: :string,
144
- translated: true
145
- settings.attribute :voting_cards_show_modal_help,
146
- type: :boolean,
147
- default: true
148
- settings.attribute :voting_cards_show_abstain,
149
- type: :boolean,
150
- default: false
151
- settings.attribute :voting_cards_instructions,
152
- type: :text,
153
- translated: true,
154
- editor: true
215
+ DecidimAwesome.hash_append!(
216
+ settings.attributes,
217
+ :can_accumulate_supports_beyond_threshold,
218
+ :awesome_voting_manifest,
219
+ Decidim::SettingsManifest::Attribute.new(
220
+ type: :select,
221
+ default: "",
222
+ choices: -> { ["default"] + Decidim::DecidimAwesome.voting_registry.manifests.map(&:name) },
223
+ readonly: lambda { |context|
224
+ Decidim::Proposals::Proposal.where(component: context[:component]).where.not(proposal_votes_count: -Float::INFINITY..0).any?
225
+ }
226
+ )
227
+ )
228
+ DecidimAwesome.hash_append!(
229
+ settings.attributes,
230
+ :awesome_voting_manifest,
231
+ :voting_cards_box_title,
232
+ Decidim::SettingsManifest::Attribute.new(type: :string, translated: true)
233
+ )
234
+ DecidimAwesome.hash_append!(
235
+ settings.attributes,
236
+ :voting_cards_box_title,
237
+ :voting_cards_show_modal_help,
238
+ Decidim::SettingsManifest::Attribute.new(type: :boolean, default: true)
239
+ )
240
+ DecidimAwesome.hash_append!(
241
+ settings.attributes,
242
+ :voting_cards_show_modal_help,
243
+ :voting_cards_show_abstain,
244
+ Decidim::SettingsManifest::Attribute.new(type: :boolean, default: false)
245
+ )
246
+ DecidimAwesome.hash_append!(
247
+ settings.attributes,
248
+ :voting_cards_show_abstain,
249
+ :voting_cards_instructions,
250
+ Decidim::SettingsManifest::Attribute.new(type: :text, translated: true, editor: true)
251
+ )
155
252
  end
156
253
  end
157
254
  end
@@ -166,6 +263,18 @@ module Decidim
166
263
  Cell::ViewModel.view_paths << File.expand_path("#{Decidim::DecidimAwesome::Engine.root}/app/cells")
167
264
  Cell::ViewModel.view_paths << File.expand_path("#{Decidim::DecidimAwesome::Engine.root}/app/views")
168
265
  end
266
+
267
+ initializer "decidim_decidim_awesome.register_icons" do
268
+ Decidim.icons.register(name: "editors-text", icon: "text", category: "system", description: "", engine: :decidim_awesome)
269
+ Decidim.icons.register(name: "surveys", icon: "survey-line", category: "system", description: "", engine: :decidim_awesome)
270
+ Decidim.icons.register(name: "brush", icon: "brush-line", category: "system", description: "", engine: :decidim_awesome)
271
+ Decidim.icons.register(name: "layers", icon: "stack-line", category: "system", description: "", engine: :decidim_awesome)
272
+ Decidim.icons.register(name: "pulse", icon: "pulse-line", category: "system", description: "", engine: :decidim_awesome)
273
+ Decidim.icons.register(name: "fire", icon: "fire-line", category: "system", description: "", engine: :decidim_awesome)
274
+ Decidim.icons.register(name: "line-chart-line", icon: "line-chart-line", category: "system", description: "", engine: :decidim_awesome)
275
+ Decidim.icons.register(name: "spy", icon: "spy-fill", category: "system", description: "", engine: :decidim_awesome)
276
+ Decidim.icons.register(name: "forbid-line", icon: "forbid-line", category: "system", description: "", engine: :decidim_awesome)
277
+ end
169
278
  end
170
279
  end
171
280
  end
@@ -17,7 +17,6 @@ Decidim::DecidimAwesome.register_component(:awesome_iframe) do |component|
17
17
  settings.attribute :announcement, type: :text, translated: true, editor: true
18
18
  settings.attribute :iframe, type: :text, default: ""
19
19
  settings.attribute :viewport_width, type: :boolean, default: false
20
- settings.attribute :no_margins, type: :boolean, default: false
21
20
  end
22
21
 
23
22
  component.settings(:step) do |settings|
@@ -41,7 +40,7 @@ Decidim::DecidimAwesome.register_component(:awesome_iframe) do |component|
41
40
  name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :awesome_iframe).i18n_name,
42
41
  manifest_name: :awesome_iframe,
43
42
  published_at: Time.current,
44
- participatory_space: participatory_space,
43
+ participatory_space:,
45
44
  settings: {
46
45
  announcement: { en: Faker::Lorem.paragraphs(number: 2).join("\n") },
47
46
  iframe: '<iframe src="https://picsum.photos/800/600" width="100%" height="700" frameborder="0"></iframe>'
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ class Lock
6
+ def initialize(organization, lock_time: DecidimAwesome.lock_time)
7
+ @organization = organization
8
+ @lock_time = lock_time
9
+ end
10
+
11
+ attr_reader :resource, :organization, :lock_time
12
+
13
+ def get!(resource)
14
+ @resource = resource
15
+ if config
16
+ config.update!(updated_at: Time.current)
17
+ else
18
+ AwesomeConfig.create!(var:, organization:)
19
+ end
20
+ end
21
+
22
+ def release!(resource)
23
+ @resource = resource
24
+ config.destroy! if config
25
+ end
26
+
27
+ def locked?(resource)
28
+ @resource = resource
29
+ return false unless config
30
+ return true if config.reload.updated_at > lock_time.ago
31
+
32
+ config.destroy!
33
+ false
34
+ end
35
+
36
+ def config
37
+ AwesomeConfig.find_by(var:, organization:)
38
+ end
39
+
40
+ private
41
+
42
+ def var
43
+ "lock-#{resource.class.name.underscore}_#{resource.id}"
44
+ end
45
+ end
46
+ end
47
+ end
@@ -52,7 +52,7 @@ Decidim::DecidimAwesome.register_component(:awesome_map) do |component|
52
52
  name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :awesome_map).i18n_name,
53
53
  manifest_name: :awesome_map,
54
54
  published_at: Time.current,
55
- participatory_space: participatory_space,
55
+ participatory_space:,
56
56
  settings: {
57
57
  announcement: { en: Faker::Lorem.paragraphs(number: 2).join("\n") }
58
58
  }
@@ -0,0 +1,165 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ class Menu
6
+ class << self
7
+ def register_awesome_admin_menu!
8
+ Decidim.menu :awesome_admin_menu do |menu|
9
+ menu.add_item :editors,
10
+ I18n.t("menu.editors", scope: "decidim.decidim_awesome.admin"),
11
+ decidim_admin_decidim_awesome.config_path(:editors),
12
+ position: 1,
13
+ icon_name: "editors-text",
14
+ if: menus[:editors]
15
+
16
+ menu.add_item :proposals,
17
+ I18n.t("menu.proposals", scope: "decidim.decidim_awesome.admin"),
18
+ decidim_admin_decidim_awesome.config_path(:proposals),
19
+ position: 2,
20
+ icon_name: "documents",
21
+ if: menus[:proposals]
22
+
23
+ menu.add_item :surveys,
24
+ I18n.t("menu.surveys", scope: "decidim.decidim_awesome.admin"),
25
+ decidim_admin_decidim_awesome.config_path(:surveys),
26
+ position: 3,
27
+ icon_name: "surveys",
28
+ if: menus[:surveys]
29
+
30
+ menu.add_item :styles,
31
+ I18n.t("menu.styles", scope: "decidim.decidim_awesome.admin"),
32
+ decidim_admin_decidim_awesome.config_path(:styles),
33
+ position: 4,
34
+ icon_name: "brush",
35
+ if: menus[:styles]
36
+
37
+ menu.add_item :proposal_custom_fields,
38
+ I18n.t("menu.proposal_custom_fields", scope: "decidim.decidim_awesome.admin"),
39
+ decidim_admin_decidim_awesome.config_path(:proposal_custom_fields),
40
+ position: 5,
41
+ icon_name: "layers",
42
+ if: menus[:proposal_custom_fields],
43
+ submenu: { target_menu: :custom_fields_submenu }
44
+
45
+ menu.add_item :admins,
46
+ I18n.t("menu.admins", scope: "decidim.decidim_awesome.admin"),
47
+ decidim_admin_decidim_awesome.config_path(:admins),
48
+ position: 6,
49
+ icon_name: "group-line",
50
+ if: menus[:admins]
51
+
52
+ menu.add_item :menu_hacks,
53
+ I18n.t("menu.menu_hacks", scope: "decidim.decidim_awesome.admin"),
54
+ decidim_admin_decidim_awesome.menu_hacks_path(menus[:menu_hacks_menu] ? :menu : :home_content_block_menu),
55
+ position: 7,
56
+ icon_name: "menu-line",
57
+ if: menus[:menu_hacks],
58
+ submenu: { target_menu: :menu_hacks_submenu }
59
+
60
+ menu.add_item :custom_redirects,
61
+ I18n.t("menu.custom_redirects", scope: "decidim.decidim_awesome.admin"),
62
+ decidim_admin_decidim_awesome.custom_redirects_path,
63
+ position: 8,
64
+ icon_name: "external-link-line",
65
+ if: menus[:custom_redirects]
66
+
67
+ menu.add_item :livechat,
68
+ I18n.t("menu.livechat", scope: "decidim.decidim_awesome.admin"),
69
+ decidim_admin_decidim_awesome.config_path(:livechat),
70
+ position: 9,
71
+ icon_name: "chat-1-line",
72
+ if: menus[:livechat]
73
+
74
+ menu.add_item :maintenance,
75
+ I18n.t("maintenance", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
76
+ decidim_admin_decidim_awesome.maintenance_path(:private_data),
77
+ position: 10,
78
+ icon_name: "tools-line",
79
+ submenu: { target_menu: :maintenance_submenu }
80
+ end
81
+ end
82
+
83
+ def register_custom_fields_submenu!
84
+ Decidim.menu :custom_fields_submenu do |menu|
85
+ menu.add_item :proposal_custom_fields,
86
+ I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"),
87
+ decidim_admin_decidim_awesome.config_path(:proposal_custom_fields),
88
+ position: 5.1,
89
+ icon_name: "draft-line",
90
+ if: menus[:proposal_custom_fields]
91
+
92
+ menu.add_item :proposal_private_custom_fields,
93
+ I18n.t("proposal_private_custom_fields", scope: "decidim.decidim_awesome.admin.proposal_custom_fields"),
94
+ decidim_admin_decidim_awesome.config_path(:proposal_private_custom_fields),
95
+ position: 5.2,
96
+ icon_name: "spy",
97
+ if: menus[:proposal_private_custom_fields]
98
+ end
99
+ end
100
+
101
+ def register_menu_hacks_submenu!
102
+ Decidim.menu :menu_hacks_submenu do |menu|
103
+ menu.add_item :main_menu,
104
+ I18n.t("menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"),
105
+ decidim_admin_decidim_awesome.menu_hacks_path(:menu),
106
+ position: 7.1,
107
+ icon_name: "global-line",
108
+ if: menus[:menu_hacks_menu]
109
+
110
+ menu.add_item :content_block_main_menu,
111
+ I18n.t("home_content_block_menu.title", scope: "decidim.decidim_awesome.admin.menu_hacks.index"),
112
+ decidim_admin_decidim_awesome.menu_hacks_path(:home_content_block_menu),
113
+ position: 7.2,
114
+ icon_name: "layout-masonry-line",
115
+ if: menus[:menu_hacks_home_content_block_menu]
116
+ end
117
+ end
118
+
119
+ def register_maintenance_admin_menu!
120
+ Decidim.menu :maintenance_submenu do |menu|
121
+ menu.add_item :private_data,
122
+ I18n.t("private_data", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
123
+ decidim_admin_decidim_awesome.maintenance_path(:private_data),
124
+ position: 10,
125
+ icon_name: "spy-line"
126
+
127
+ menu.add_item :checks,
128
+ I18n.t("checks", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
129
+ decidim_admin_decidim_awesome.checks_maintenance_index_path,
130
+ position: 10,
131
+ icon_name: "pulse"
132
+ end
133
+ end
134
+
135
+ def menus
136
+ @menus ||= {
137
+ editors: config_enabled?(:allow_images_in_editors, :allow_videos_in_editors),
138
+ proposals: config_enabled?(
139
+ :allow_images_in_proposals,
140
+ :validate_title_min_length, :validate_title_max_caps_percent,
141
+ :validate_title_max_marks_together, :validate_title_start_with_caps,
142
+ :validate_body_min_length, :validate_body_max_caps_percent,
143
+ :validate_body_max_marks_together, :validate_body_start_with_caps
144
+ ),
145
+ surveys: config_enabled?(:auto_save_forms),
146
+ styles: config_enabled?(:scoped_styles),
147
+ proposal_custom_fields: config_enabled?(:proposal_custom_fields),
148
+ proposal_private_custom_fields: config_enabled?(:proposal_private_custom_fields),
149
+ admins: config_enabled?(:scoped_admins),
150
+ menu_hacks: config_enabled?(:menu, :home_content_block_menu),
151
+ menu_hacks_menu: config_enabled?(:menu),
152
+ menu_hacks_home_content_block_menu: config_enabled?(:home_content_block_menu),
153
+ custom_redirects: config_enabled?(:custom_redirects),
154
+ livechat: config_enabled?(:intergram_for_admins, :intergram_for_public)
155
+ }
156
+ end
157
+
158
+ # ensure boolean value
159
+ def config_enabled?(*vars)
160
+ DecidimAwesome.enabled?(*vars)
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -21,6 +21,7 @@ module Decidim
21
21
  default = default_items.find { |i| i.url.gsub(/\?.*/, "") == item.url }
22
22
  if default
23
23
  item.send("overrided?=", true)
24
+ item[:original_active] = default.active
24
25
  @items.reject! { |i| i.url.gsub(/\?.*/, "") == item.url }
25
26
  end
26
27
  @items << item
@@ -36,10 +37,7 @@ module Decidim
36
37
  attr_reader :name, :view
37
38
 
38
39
  def default_items
39
- @default_items ||= build_menu.items.map do |item|
40
- item.instance_variable_set(:@active, method(:activate?)) unless item.active == :exact
41
- item
42
- end
40
+ @default_items ||= build_menu.items
43
41
  end
44
42
 
45
43
  def build_menu
@@ -48,7 +46,6 @@ module Decidim
48
46
  menu
49
47
  end
50
48
 
51
- # rubocop:disable Style/OpenStructUse
52
49
  def menu_overrides
53
50
  @menu_overrides ||= current_config.map do |item|
54
51
  OpenStruct.new(
@@ -65,7 +62,6 @@ module Decidim
65
62
  )
66
63
  end
67
64
  end
68
- # rubocop:enable Style/OpenStructUse
69
65
 
70
66
  def activate?(url, view)
71
67
  urls = @items.map(&:url).sort_by(&:length).reverse
@@ -83,14 +79,14 @@ module Decidim
83
79
  when "verified_user"
84
80
  # the cleaner version should be user.authorizations.any?
85
81
  # but there is not relationship between users and authorizations
86
- Decidim::Authorization.where(user: user).any? { |auth| auth.granted? && !auth.expired? }
82
+ Decidim::Authorization.where(user:).any? { |auth| auth.granted? && !auth.expired? }
87
83
  else
88
84
  true
89
85
  end
90
86
  end
91
87
 
92
88
  def current_config
93
- @current_config ||= (AwesomeConfig.find_by(var: name, organization: organization)&.value || []).filter { |i| i.is_a? Hash }
89
+ @current_config ||= (AwesomeConfig.find_by(var: name, organization:)&.value || []).filter { |i| i.is_a? Hash }
94
90
  end
95
91
  end
96
92
  end
@@ -24,8 +24,8 @@ module Decidim
24
24
 
25
25
  delegate :to_h, to: :overrides
26
26
 
27
- def each(&block)
28
- to_h.each(&block)
27
+ def each(&)
28
+ to_h.each(&)
29
29
  end
30
30
 
31
31
  def each_file
@@ -58,11 +58,9 @@ module Decidim
58
58
  Digest::MD5.hexdigest(File.read(file))
59
59
  end
60
60
 
61
- # rubocop:disable Style/OpenStructUse
62
61
  def to_struct(obj)
63
62
  OpenStruct.new obj
64
63
  end
65
- # rubocop:enable Style/OpenStructUse
66
64
  end
67
65
  end
68
66
  end