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
@@ -13,7 +13,7 @@ module Decidim
13
13
  # rubocop:enable Rails/LexicallyScopedActionFilter
14
14
 
15
15
  def create
16
- enforce_permission_to :vote, :proposal, proposal: proposal
16
+ enforce_permission_to(:vote, :proposal, proposal:)
17
17
  @from_proposals_list = params[:from_proposals_list] == "true"
18
18
 
19
19
  Decidim::Proposals::VoteProposal.call(proposal, current_user) do
@@ -27,7 +27,7 @@ module Decidim
27
27
  proposal: Decidim::Proposals::Proposal.where(component: current_component)
28
28
  ).map(&:proposal)
29
29
 
30
- expose(proposals: proposals)
30
+ expose(proposals:)
31
31
  render :update_buttons_and_counters
32
32
  end
33
33
 
@@ -47,7 +47,7 @@ module Decidim
47
47
  end
48
48
 
49
49
  def current_vote
50
- @current_vote ||= Decidim::Proposals::ProposalVote.find_by(author: current_user, proposal: proposal)
50
+ @current_vote ||= Decidim::Proposals::ProposalVote.find_by(author: current_user, proposal:)
51
51
  end
52
52
 
53
53
  def vote_manifest
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  class AdminAccountabilityController < DecidimAwesome::Admin::ApplicationController
7
7
  include NeedsAwesomeConfig
8
- include Decidim::DecidimAwesome::AdminAccountability::Admin::Filterable
8
+ include AdminAccountability::Admin::Filterable
9
9
 
10
10
  helper_method :admin_actions, :collection, :export_params, :global?, :global_users_missing_date
11
11
 
@@ -20,9 +20,9 @@ module Decidim
20
20
  def export
21
21
  filters = export_params[:q]
22
22
 
23
- Decidim::DecidimAwesome::ExportAdminActionsJob.perform_later(current_user,
24
- params[:format].to_s,
25
- admin_actions.ransack(filters).result.ids)
23
+ ExportAdminActionsJob.perform_later(current_user,
24
+ params[:format].to_s,
25
+ admin_actions.ransack(filters).result.ids)
26
26
 
27
27
  redirect_back fallback_location: decidim_admin_decidim_awesome.admin_accountability_path,
28
28
  notice: t("decidim.decidim_awesome.admin.admin_accountability.exports.notice")
@@ -39,11 +39,11 @@ module Decidim
39
39
  end
40
40
 
41
41
  def space_role_actions
42
- @space_role_actions ||= Decidim::DecidimAwesome::PaperTrailVersion.space_role_actions(current_organization)
42
+ @space_role_actions ||= PaperTrailVersion.space_role_actions(current_organization)
43
43
  end
44
44
 
45
45
  def admin_role_actions
46
- @admin_role_actions ||= Decidim::DecidimAwesome::PaperTrailVersion.in_organization(current_organization).admin_role_actions(params[:admin_role_type])
46
+ @admin_role_actions ||= PaperTrailVersion.in_organization(current_organization).admin_role_actions(PaperTrailVersion.safe_admin_role_type(params[:admin_role_type]))
47
47
  end
48
48
 
49
49
  def export_params
@@ -61,7 +61,7 @@ module Decidim
61
61
  return unless global?
62
62
 
63
63
  @global_users_missing_date ||= begin
64
- first_version = Decidim::DecidimAwesome::PaperTrailVersion.where(item_type: "Decidim::UserBaseEntity").last
64
+ first_version = PaperTrailVersion.where(item_type: "Decidim::UserBaseEntity").last
65
65
  first_user = Decidim::User.first
66
66
  first_version.created_at if first_user && first_version && (first_version.created_at > first_user.created_at + 1.second)
67
67
  end
@@ -9,6 +9,8 @@ module Decidim
9
9
  # Note that it inherits from `Decidim::Admin::Components::BaseController`, which
10
10
  # override its layout and provide all kinds of useful methods.
11
11
  class ApplicationController < Decidim::Admin::ApplicationController
12
+ layout "decidim/decidim_awesome/admin/application"
13
+
12
14
  def permission_class_chain
13
15
  [::Decidim::DecidimAwesome::Admin::Permissions] + super
14
16
  end
@@ -8,17 +8,17 @@ module Decidim
8
8
  # System compatibility analyzer
9
9
  class ChecksController < DecidimAwesome::Admin::ApplicationController
10
10
  include NeedsAwesomeConfig
11
+ include MaintenanceContext
12
+
11
13
  helper ConfigConstraintsHelpers
12
14
  helper SystemCheckerHelpers
13
15
 
14
- layout "decidim/decidim_awesome/admin/application"
15
-
16
16
  helper_method :head, :admin_head, :head_addons, :admin_addons
17
17
 
18
18
  def migrate_images
19
19
  Decidim::DecidimAwesome::MigrateLegacyImagesJob.perform_later(current_organization.id)
20
20
  flash[:notice] = I18n.t("image_migrations_started", scope: "decidim.decidim_awesome.admin.checks.index")
21
- redirect_to checks_path
21
+ redirect_to checks_maintenance_index_path
22
22
  end
23
23
 
24
24
  private
@@ -34,30 +34,34 @@ module Decidim
34
34
  def head_addons(part)
35
35
  case part
36
36
  when :CSS
37
- ['<%= stylesheet_pack_tag "decidim_decidim_awesome", media: "all" %>',
37
+ ['<%= append_stylesheet_pack_tag "decidim_decidim_awesome", media: "all" %>',
38
38
  '<%= render(partial: "layouts/decidim/decidim_awesome/custom_styles") if awesome_custom_styles %>'].join("\n")
39
39
  when :JavaScript
40
40
  ['<%= render partial: "layouts/decidim/decidim_awesome/awesome_config" %>',
41
- '<%= javascript_pack_tag "decidim_decidim_awesome" %>',
42
- '<%= javascript_pack_tag "decidim_decidim_awesome_custom_fields" if awesome_proposal_custom_fields %>'].join("\n")
41
+ '<%= append_javascript_pack_tag "decidim_decidim_awesome", defer: false %>',
42
+ '<%= append_javascript_pack_tag "decidim_decidim_awesome_custom_fields" if awesome_proposal_custom_fields %>'].join("\n")
43
43
  end
44
44
  end
45
45
 
46
46
  def admin_addons(part)
47
47
  case part
48
48
  when :CSS
49
- '<%= stylesheet_pack_tag "decidim_admin_decidim_awesome", media: "all" %>'
49
+ '<%= append_stylesheet_pack_tag "decidim_admin_decidim_awesome", media: "all" %>'
50
50
  when :JavaScript
51
- ['<%= javascript_pack_tag "decidim_admin_decidim_awesome", defer: false %>',
52
- '<%= javascript_pack_tag "decidim_decidim_awesome_custom_fields" if awesome_proposal_custom_fields %>'].join("\n")
51
+ ['<%= append_javascript_pack_tag "decidim_admin_decidim_awesome", defer: false %>',
52
+ '<%= append_javascript_pack_tag "decidim_decidim_awesome_custom_fields" if awesome_proposal_custom_fields %>'].join("\n")
53
53
  end
54
54
  end
55
55
 
56
56
  def render_template(partial)
57
- render_to_string(partial: partial)
57
+ render_to_string(partial:)
58
58
  rescue ActionView::Template::Error => e
59
59
  flash.now[:alert] = "Partial [#{partial}] has thrown an error: #{e.message}"
60
60
  end
61
+
62
+ def current_view
63
+ "checks"
64
+ end
61
65
  end
62
66
  end
63
67
  end
@@ -9,8 +9,6 @@ module Decidim
9
9
  include ConfigConstraintsHelpers
10
10
  helper ConfigConstraintsHelpers
11
11
 
12
- layout "decidim/decidim_awesome/admin/application"
13
-
14
12
  helper_method :constraints_for, :users_for, :config_var
15
13
  before_action do
16
14
  enforce_permission_to :edit_config, configs
@@ -19,7 +17,7 @@ module Decidim
19
17
  def show
20
18
  @form = form(ConfigForm).from_params(organization_awesome_config)
21
19
 
22
- redirect_to decidim_admin_decidim_awesome.checks_path unless config_var
20
+ redirect_to decidim_admin_decidim_awesome.checks_maintenance_index_path unless config_var
23
21
  end
24
22
 
25
23
  def update
@@ -43,8 +41,13 @@ module Decidim
43
41
  if (term = params[:term].to_s).present?
44
42
  query = current_organization.users.order(name: :asc)
45
43
  query = query.where("name ILIKE :term OR nickname ILIKE :term OR email ILIKE :term", term: "%#{term}%")
46
-
47
- render json: query.all.collect { |u| { id: u.id, text: format_user_name(u) } }
44
+ render json: query.all.collect { |u|
45
+ {
46
+ value: u.id,
47
+ text: format_user_name(u),
48
+ is_admin: u.read_attribute("admin")
49
+ }
50
+ }
48
51
  else
49
52
  render json: []
50
53
  end
@@ -88,14 +91,12 @@ module Decidim
88
91
  DecidimAwesome.config.keys
89
92
  end
90
93
 
91
- # rubocop:disable Style/OpenStructUse
92
94
  def users_for(ids_list)
93
- Decidim::User.where(id: ids_list).map { |user| OpenStruct.new(text: format_user_name(user), id: user.id) }
95
+ Decidim::User.where(id: ids_list).map { |user| [format_user_name(user), user.id, { data: { is_admin: user.read_attribute("admin") } }] }
94
96
  end
95
- # rubocop:enable Style/OpenStructUse
96
97
 
97
98
  def format_user_name(user)
98
- "<span class='#{"is-admin" if user.read_attribute("admin")}'>#{user.name} (@#{user.nickname} - #{user.email})</span>"
99
+ "#{user.name} (@#{user.nickname} - #{user.email})"
99
100
  end
100
101
  end
101
102
  end
@@ -6,21 +6,22 @@ module Decidim
6
6
  # Constraints configuration controller for config keys
7
7
  class ConstraintsController < DecidimAwesome::Admin::ApplicationController
8
8
  include NeedsAwesomeConfig
9
+ include Decidim::Headers::HttpCachingDisabler
9
10
  helper ConfigConstraintsHelpers
10
11
 
11
12
  layout false
12
13
  before_action do
13
- enforce_permission_to :edit_config, constraint_key
14
- end
15
-
16
- def new
17
- @form = form(ConstraintForm).from_params(filtered_params, setting: current_setting)
14
+ render plain: "no permissions for #{constraint_key}" unless allowed_to? :edit_config, constraint_key
18
15
  end
19
16
 
20
17
  def show
21
18
  @form = form(ConstraintForm).from_params(constraint.settings.merge(filtered_params))
22
19
  end
23
20
 
21
+ def new
22
+ @form = form(ConstraintForm).from_params(filtered_params, setting: current_setting)
23
+ end
24
+
24
25
  def create
25
26
  @form = form(ConstraintForm).from_params(params, setting: current_setting)
26
27
  CreateConstraint.call(@form) do
@@ -39,11 +40,11 @@ module Decidim
39
40
 
40
41
  on(:invalid) do |message|
41
42
  render json: {
42
- id: params[:id],
43
- key: current_setting.var,
44
- message: I18n.t("decidim_awesome.admin.constraints.create.error", scope: "decidim"),
45
- error: message
46
- },
43
+ id: params[:id],
44
+ key: current_setting.var,
45
+ message: I18n.t("decidim_awesome.admin.constraints.create.error", scope: "decidim"),
46
+ error: message
47
+ },
47
48
  status: :unprocessable_entity
48
49
  end
49
50
  end
@@ -67,11 +68,11 @@ module Decidim
67
68
 
68
69
  on(:invalid) do |message|
69
70
  render json: {
70
- id: params[:id],
71
- key: constraint.awesome_config.var,
72
- message: I18n.t("decidim_awesome.admin.constraints.update.error", scope: "decidim"),
73
- error: message
74
- },
71
+ id: params[:id],
72
+ key: constraint.awesome_config.var,
73
+ message: I18n.t("decidim_awesome.admin.constraints.update.error", scope: "decidim"),
74
+ error: message
75
+ },
75
76
  status: :unprocessable_entity
76
77
  end
77
78
  end
@@ -94,11 +95,11 @@ module Decidim
94
95
 
95
96
  on(:invalid) do |message|
96
97
  render json: {
97
- id: params[:id],
98
- key: constraint.awesome_config.var,
99
- message: I18n.t("decidim_awesome.admin.constraints.destroy.error", scope: "decidim"),
100
- error: message
101
- },
98
+ id: params[:id],
99
+ key: constraint.awesome_config.var,
100
+ message: I18n.t("decidim_awesome.admin.constraints.destroy.error", scope: "decidim"),
101
+ error: message
102
+ },
102
103
  status: :unprocessable_entity
103
104
  end
104
105
  end
@@ -131,6 +132,8 @@ module Decidim
131
132
  :scoped_admins
132
133
  when /^proposal_custom_field_/
133
134
  :proposal_custom_fields
135
+ when /^proposal_private_custom_field_/
136
+ :proposal_private_custom_fields
134
137
  else
135
138
  key
136
139
  end
@@ -8,8 +8,6 @@ module Decidim
8
8
  include NeedsAwesomeConfig
9
9
  include ConfigConstraintsHelpers
10
10
 
11
- layout "decidim/decidim_awesome/admin/application"
12
-
13
11
  before_action do
14
12
  enforce_permission_to :edit_config, :menu
15
13
  end
@@ -23,6 +21,10 @@ module Decidim
23
21
  @form = form(CustomRedirectForm).instance
24
22
  end
25
23
 
24
+ def edit
25
+ @form = form(CustomRedirectForm).from_model(redirect_item)
26
+ end
27
+
26
28
  def create
27
29
  @form = form(CustomRedirectForm).from_params(params)
28
30
  CreateCustomRedirect.call(@form) do
@@ -38,10 +40,6 @@ module Decidim
38
40
  end
39
41
  end
40
42
 
41
- def edit
42
- @form = form(CustomRedirectForm).from_model(redirect_item)
43
- end
44
-
45
43
  def update
46
44
  @form = form(CustomRedirectForm).from_params(params)
47
45
  UpdateCustomRedirect.call(@form, redirect_item) do
@@ -63,7 +61,7 @@ module Decidim
63
61
  flash[:notice] = I18n.t("custom_redirects.destroy.success", scope: "decidim.decidim_awesome.admin")
64
62
  end
65
63
  on(:invalid) do |error|
66
- flash[:alert] = I18n.t("custom_redirects.destroy.error", scope: "decidim.decidim_awesome.admin", error: error)
64
+ flash[:alert] = I18n.t("custom_redirects.destroy.error", scope: "decidim.decidim_awesome.admin", error:)
67
65
  end
68
66
  end
69
67
  redirect_to decidim_admin_decidim_awesome.custom_redirects_path
@@ -75,13 +73,11 @@ module Decidim
75
73
  origin, item = current_config.find { |origin, _| md5(origin) == params[:id] }
76
74
  raise ActiveRecord::RecordNotFound unless item
77
75
 
78
- # rubocop:disable Style/OpenStructUse
79
76
  OpenStruct.new(
80
- origin: origin,
77
+ origin:,
81
78
  destination: item["destination"],
82
79
  active: item["active"]
83
80
  )
84
- # rubocop:enable Style/OpenStructUse
85
81
  end
86
82
 
87
83
  def current_config
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/decidim_awesome/version"
4
+
5
+ module Decidim
6
+ module DecidimAwesome
7
+ module Admin
8
+ # System compatibility analyzer
9
+ class MaintenanceController < DecidimAwesome::Admin::ApplicationController
10
+ include NeedsAwesomeConfig
11
+ include MaintenanceContext
12
+ include Decidim::Admin::Filterable
13
+ include ActionView::Helpers::DateHelper
14
+
15
+ helper ConfigConstraintsHelpers
16
+ helper_method :collection, :resource, :present, :time_ago
17
+
18
+ before_action do
19
+ enforce_permission_to :edit_config, :private_data, private_data:
20
+ end
21
+
22
+ def show
23
+ respond_to do |format|
24
+ format.json do
25
+ render json: private_data_finder.for(params[:resources].to_s.split(",")).map { |resource| present(resource) }
26
+ end
27
+ format.all do
28
+ render :show
29
+ end
30
+ end
31
+ end
32
+
33
+ def destroy_private_data
34
+ if private_data && private_data.total.to_i.positive?
35
+ Decidim::ActionLogger.log("destroy_private_data", current_user, resource, nil, count: private_data.total)
36
+
37
+ Lock.new(current_organization).get!(resource)
38
+ DestroyPrivateDataJob.set(wait: 1.second).perform_later(resource)
39
+ end
40
+ redirect_to decidim_admin_decidim_awesome.maintenance_path("private_data"),
41
+ notice: I18n.t("destroying_private_data", scope: "decidim.decidim_awesome.admin.maintenance.private_data", title: present_private_data(resource).name)
42
+ end
43
+
44
+ private
45
+
46
+ def resource
47
+ @resource ||= Component.find_by(id: params[:resource_id])
48
+ end
49
+
50
+ def private_data
51
+ @private_data ||= present_private_data(resource) if resource
52
+ end
53
+
54
+ def collection
55
+ filtered_collection
56
+ end
57
+
58
+ def base_query
59
+ private_data_finder.query
60
+ end
61
+
62
+ def present(resource)
63
+ present_private_data(resource)
64
+ end
65
+
66
+ def private_data_finder
67
+ @private_data_finder ||= PrivateDataFinder.new
68
+ end
69
+
70
+ def time_ago
71
+ @time_ago ||= time_ago_in_words(Time.current - Decidim::DecidimAwesome.private_data_expiration_time)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -8,8 +8,6 @@ module Decidim
8
8
  include NeedsAwesomeConfig
9
9
  include ConfigConstraintsHelpers
10
10
 
11
- layout "decidim/decidim_awesome/admin/application"
12
-
13
11
  helper ConfigConstraintsHelpers
14
12
  helper_method :current_items, :visibility_options, :target_options
15
13
 
@@ -23,6 +21,10 @@ module Decidim
23
21
  @form = form(MenuForm).instance
24
22
  end
25
23
 
24
+ def edit
25
+ @form = form(MenuForm).from_model(menu_item)
26
+ end
27
+
26
28
  def create
27
29
  @form = form(MenuForm).from_params(params)
28
30
  CreateMenuHack.call(@form, current_menu_name) do
@@ -38,10 +40,6 @@ module Decidim
38
40
  end
39
41
  end
40
42
 
41
- def edit
42
- @form = form(MenuForm).from_model(menu_item)
43
- end
44
-
45
43
  def update
46
44
  @form = form(MenuForm).from_params(params)
47
45
  UpdateMenuHack.call(@form, current_menu_name) do
@@ -63,7 +61,7 @@ module Decidim
63
61
  flash[:notice] = I18n.t("menu_hacks.destroy.success", scope: "decidim.decidim_awesome.admin")
64
62
  end
65
63
  on(:invalid) do |error|
66
- flash[:alert] = I18n.t("menu_hacks.destroy.error", scope: "decidim.decidim_awesome.admin", error: error)
64
+ flash[:alert] = I18n.t("menu_hacks.destroy.error", scope: "decidim.decidim_awesome.admin", error:)
67
65
  end
68
66
  end
69
67
  redirect_to decidim_admin_decidim_awesome.menu_hacks_path
@@ -71,7 +69,6 @@ module Decidim
71
69
 
72
70
  private
73
71
 
74
- # rubocop:disable Style/OpenStructUse
75
72
  def menu_item
76
73
  item = current_items.find { |i| md5(i.url) == params[:id] }
77
74
  raise ActiveRecord::RecordNotFound unless item
@@ -85,7 +82,6 @@ module Decidim
85
82
  native?: !item.respond_to?(:overrided?)
86
83
  )
87
84
  end
88
- # rubocop:enable Style/OpenStructUse
89
85
 
90
86
  def current_items
91
87
  @current_items ||= current_menu.items(include_invisible: true)
@@ -96,7 +92,7 @@ module Decidim
96
92
  end
97
93
 
98
94
  def current_menu_name
99
- :menu
95
+ params[:menu_id].to_sym
100
96
  end
101
97
 
102
98
  def visibility_options
@@ -6,9 +6,9 @@ module Decidim
6
6
  # Global configuration controller
7
7
  class ProposalCustomFieldsController < DecidimAwesome::Admin::ConfigController
8
8
  def create
9
- CreateProposalCustomField.call(current_organization) do
9
+ CreateProposalCustomField.call(current_organization, config_var) do
10
10
  on(:ok) do |key|
11
- flash[:notice] = I18n.t("config.create_proposal_custom_field.success", key: key, scope: "decidim.decidim_awesome.admin")
11
+ flash[:notice] = I18n.t("config.create_proposal_custom_field.success", key:, scope: "decidim.decidim_awesome.admin")
12
12
  end
13
13
 
14
14
  on(:invalid) do |message|
@@ -16,13 +16,13 @@ module Decidim
16
16
  end
17
17
  end
18
18
 
19
- redirect_to decidim_admin_decidim_awesome.config_path(:proposal_custom_fields)
19
+ redirect_to decidim_admin_decidim_awesome.config_path(config_var)
20
20
  end
21
21
 
22
22
  def destroy
23
- DestroyProposalCustomField.call(params[:key], current_organization) do
23
+ DestroyProposalCustomField.call(params[:key], current_organization, config_var) do
24
24
  on(:ok) do |key|
25
- flash[:notice] = I18n.t("config.destroy_proposal_custom_field.success", key: key, scope: "decidim.decidim_awesome.admin")
25
+ flash[:notice] = I18n.t("config.destroy_proposal_custom_field.success", key:, scope: "decidim.decidim_awesome.admin")
26
26
  end
27
27
 
28
28
  on(:invalid) do |message|
@@ -30,7 +30,15 @@ module Decidim
30
30
  end
31
31
  end
32
32
 
33
- redirect_to decidim_admin_decidim_awesome.config_path(:proposal_custom_fields)
33
+ redirect_to decidim_admin_decidim_awesome.config_path(config_var)
34
+ end
35
+
36
+ private
37
+
38
+ def config_var
39
+ return :proposal_private_custom_fields if params[:private] == "true"
40
+
41
+ :proposal_custom_fields
34
42
  end
35
43
  end
36
44
  end
@@ -8,7 +8,7 @@ module Decidim
8
8
  def create
9
9
  CreateScopedAdmin.call(current_organization) do
10
10
  on(:ok) do |key|
11
- flash[:notice] = I18n.t("config.create_scoped_admin.success", key: key, scope: "decidim.decidim_awesome.admin")
11
+ flash[:notice] = I18n.t("config.create_scoped_admin.success", key:, scope: "decidim.decidim_awesome.admin")
12
12
  end
13
13
 
14
14
  on(:invalid) do |message|
@@ -22,7 +22,7 @@ module Decidim
22
22
  def destroy
23
23
  DestroyScopedAdmin.call(params[:key], current_organization) do
24
24
  on(:ok) do |key|
25
- flash[:notice] = I18n.t("config.destroy_scoped_admin.success", key: key, scope: "decidim.decidim_awesome.admin")
25
+ flash[:notice] = I18n.t("config.destroy_scoped_admin.success", key:, scope: "decidim.decidim_awesome.admin")
26
26
  end
27
27
 
28
28
  on(:invalid) do |message|
@@ -8,7 +8,7 @@ module Decidim
8
8
  def create
9
9
  CreateScopedStyle.call(current_organization) do
10
10
  on(:ok) do |key|
11
- flash[:notice] = I18n.t("config.create_scoped_style.success", key: key, scope: "decidim.decidim_awesome.admin")
11
+ flash[:notice] = I18n.t("config.create_scoped_style.success", key:, scope: "decidim.decidim_awesome.admin")
12
12
  end
13
13
 
14
14
  on(:invalid) do |message|
@@ -22,7 +22,7 @@ module Decidim
22
22
  def destroy
23
23
  DestroyScopedStyle.call(params[:key], current_organization) do
24
24
  on(:ok) do |key|
25
- flash[:notice] = I18n.t("config.destroy_scoped_style.success", key: key, scope: "decidim.decidim_awesome.admin")
25
+ flash[:notice] = I18n.t("config.destroy_scoped_style.success", key:, scope: "decidim.decidim_awesome.admin")
26
26
  end
27
27
 
28
28
  on(:invalid) do |message|
@@ -6,13 +6,18 @@ module Decidim
6
6
  class BlankComponentController < Decidim::Components::BaseController
7
7
  # just redirects to settings
8
8
  def settings
9
- redirect_to EngineRouter.admin_proxy(component.participatory_space).edit_component_path(id: component)
9
+ redirect_to EngineRouter.admin_proxy(current_component.participatory_space).edit_component_path(id: current_component)
10
10
  end
11
11
 
12
12
  private
13
13
 
14
- def component
15
- Decidim::Component.find(params[:component_id])
14
+ def set_component_breadcrumb_item
15
+ context_breadcrumb_items << {
16
+ label: current_component.name,
17
+ url: EngineRouter.admin_proxy(current_component.participatory_space).edit_component_path(id: current_component),
18
+ active: false,
19
+ resource: current_component
20
+ }
16
21
  end
17
22
  end
18
23
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module DecidimAwesome
5
- # This controller handles image uploads for the hacked Quill editor
5
+ # This controller handles image uploads for the Tiptap editor
6
6
  class EditorImagesController < DecidimAwesome::ApplicationController
7
7
  include FormFactory
8
8
  include NeedsAwesomeConfig
@@ -11,14 +11,14 @@ module Decidim
11
11
  rescue_from Decidim::ActionForbidden, with: :ajax_user_has_no_permission
12
12
 
13
13
  def create
14
- enforce_permission_to :create, :editor_image, awesome_config: awesome_config
14
+ enforce_permission_to(:create, :editor_image, awesome_config:)
15
15
 
16
16
  @form = form(EditorImageForm).from_params(form_values)
17
17
  CreateEditorImage.call(@form) do
18
18
  on(:ok) do |image|
19
19
  url = image.attached_uploader(:file).path
20
20
  url = "#{request.base_url}#{url}" unless url&.start_with?("http")
21
- render json: { url: url, message: I18n.t("decidim_awesome.editor_images.create.success", scope: "decidim") }
21
+ render json: { url:, message: I18n.t("decidim_awesome.editor_images.create.success", scope: "decidim") }
22
22
  end
23
23
 
24
24
  on(:invalid) do |_message|
@@ -5,7 +5,8 @@ module Decidim
5
5
  module IframeComponent
6
6
  class IframeController < DecidimAwesome::BlankComponentController
7
7
  ALLOWED_ATTRIBUTES = %w(src width height frameborder title allow allowpaymentrequest name referrerpolicy sandbox srcdoc allowfullscreen).freeze
8
- helper_method :iframe, :remove_margins?, :viewport_width?
8
+ helper_method :iframe, :viewport_width?
9
+ before_action :add_additional_csp_directives, only: :show
9
10
 
10
11
  def show; end
11
12
 
@@ -17,16 +18,28 @@ module Decidim
17
18
 
18
19
  def sanitize(html)
19
20
  sanitizer = Rails::Html::SafeListSanitizer.new
20
- sanitizer.sanitize(html, tags: %w(iframe), attributes: ALLOWED_ATTRIBUTES)
21
- end
21
+ partially_sanitized_html = sanitizer.sanitize(html, tags: %w(iframe), attributes: ALLOWED_ATTRIBUTES)
22
+
23
+ document = Nokogiri::HTML::DocumentFragment.parse(partially_sanitized_html)
24
+ document.css("iframe").each do |iframe|
25
+ iframe["srcdoc"] = Loofah.fragment(iframe["srcdoc"]).scrub!(:prune).to_s if iframe["srcdoc"]
26
+ end
22
27
 
23
- def remove_margins?
24
- current_component.settings.no_margins
28
+ document.to_s
25
29
  end
26
30
 
27
31
  def viewport_width?
28
32
  current_component.settings.viewport_width
29
33
  end
34
+
35
+ def add_additional_csp_directives
36
+ iframe_urls = Nokogiri::HTML::DocumentFragment.parse(iframe).children.select { |x| x.name == "iframe" }.filter_map { |x| x.attribute("src")&.value }
37
+ return if iframe_urls.blank?
38
+
39
+ iframe_urls.each do |url|
40
+ content_security_policy.append_csp_directive("frame-src", url)
41
+ end
42
+ end
30
43
  end
31
44
  end
32
45
  end