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
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module DecidimAwesome
5
- module Proposals
6
- module ApplicationHelperOverride
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- alias_method :decidim_text_editor_for_proposal_body, :text_editor_for_proposal_body
11
- alias_method :decidim_safe_content?, :safe_content?
12
-
13
- # replace safe content to consider all custom fields save (then embeded html will be rendered)
14
- def safe_content?
15
- awesome_proposal_custom_fields.present? || decidim_safe_content?
16
- end
17
-
18
- # replace normal method to draw the editor
19
- def text_editor_for_proposal_body(form)
20
- custom_fields = awesome_proposal_custom_fields
21
-
22
- return decidim_text_editor_for_proposal_body(form) if custom_fields.blank?
23
-
24
- render_proposal_custom_fields_override(custom_fields, form, :body)
25
- end
26
-
27
- # replace admin method to draw the editor (multi lang)
28
- def admin_editor_for_proposal_body(form)
29
- custom_fields = awesome_proposal_custom_fields
30
-
31
- return form.translated(:editor, :body, hashtaggable: true) if custom_fields.blank?
32
-
33
- locales = form.send(:locales)
34
-
35
- return render_proposal_custom_fields_override(custom_fields, form, "body_#{locales.first}", locales.first) if locales.length == 1
36
-
37
- tabs_id = form.send(:sanitize_tabs_selector, form.options[:tabs_id] || "#{form.object_name}-body-tabs")
38
-
39
- label_tabs = form.content_tag(:div, class: "label--tabs") do
40
- field_label = form.send(:label_i18n, "body", form.label_for("proposal_custom_fields"))
41
-
42
- language_selector = "".html_safe
43
- language_selector = form.create_language_selector(locales, tabs_id, "body") if form.options[:label] != false
44
-
45
- safe_join [field_label, language_selector]
46
- end
47
-
48
- tabs_content = form.content_tag(:div, class: "tabs-content", data: { tabs_content: tabs_id }) do
49
- locales.each_with_index.inject("".html_safe) do |string, (locale, index)|
50
- tab_content_id = "#{tabs_id}-body-panel-#{index}"
51
- string + content_tag(:div, class: form.send(:tab_element_class_for, "panel", index), id: tab_content_id) do
52
- render_proposal_custom_fields_override(custom_fields, form, "body_#{locale}", locale)
53
- end
54
- end
55
- end
56
-
57
- safe_join [label_tabs, tabs_content]
58
- end
59
-
60
- def render_proposal_custom_fields_override(fields, form, name, locale = nil)
61
- custom_fields = Decidim::DecidimAwesome::CustomFields.new(fields)
62
- custom_fields.translate!
63
-
64
- body = if form_presenter.proposal.body.is_a?(Hash) && locale.present?
65
- form_presenter.body(extras: false, all_locales: true).with_indifferent_access[locale]
66
- else
67
- form_presenter.body(extras: false)
68
- end
69
-
70
- custom_fields.apply_xml(body) if body.present?
71
- form.object.errors.add(name, custom_fields.errors) if custom_fields.errors
72
- render partial: "decidim/decidim_awesome/custom_fields/form_render", locals: { spec: custom_fields.to_json, form: form, name: name }
73
- end
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Deface::Override.new(virtual_path: "layouts/decidim/_head",
4
- name: "legacy_awesome_scripts",
5
- insert_after: 'erb[loud]:contains(\'javascript_pack_tag "decidim_core"\')') do
6
- # NOTE THAT THIS ONLY APPLIES TO DECIDIM 0.26. This will be ignored in 0.27
7
- '
8
- <%= javascript_pack_tag "decidim_decidim_awesome", defer: false %>
9
- <%= javascript_pack_tag("decidim_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %>
10
- <% if show_public_intergram? %>
11
- <%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_public_settings] } %>
12
- <% end %>
13
- '
14
- end
@@ -1,3 +0,0 @@
1
- <!-- replace "erb[loud]:contains('stylesheet_pack_tag')" -->
2
-
3
- <%= stylesheet_pack_tag "decidim_admin_decidim_awesome", media: "all" %>
@@ -1,2 +0,0 @@
1
- import "src/decidim/decidim_awesome/proposals/custom_fields"
2
- import "src/decidim/decidim_awesome/admin/custom_fields_builder"
@@ -1 +0,0 @@
1
- import "src/decidim/decidim_awesome/admin/form_exit_warn"
@@ -1,55 +0,0 @@
1
- $(() => {
2
- const $modal = $("#constraintsModal");
3
- if (!$modal.length) {
4
- return;
5
- }
6
-
7
- $(".decidim_awesome-form").on("click", ".constraints-editor .add-condition,.constraints-editor .edit-condition", (evt) => {
8
- evt.preventDefault();
9
- const $this = $(evt.target)
10
- const url = $this.attr("href");
11
- const $callout = $this.closest(".constraints-editor").find(".callout");
12
- $callout.hide();
13
- $callout.removeClass("alert success");
14
- $modal.find(".modal-content").html("");
15
- $modal.addClass("loading");
16
- $modal.data("url", url);
17
- $modal.foundation("open");
18
- $modal.find(".modal-content").load(url, () => {
19
- $modal.removeClass("loading");
20
- });
21
- });
22
-
23
- // Custom event listener to reload the modal if needed
24
- document.body.addEventListener("constraint:change", (evt) => {
25
- const vars = evt.detail.map((setting) => `${setting.key}=${setting.value}`);
26
- const url = `${$modal.data("url")}&${vars.join("&")}`;
27
- // console.log("constraint:change vars:", vars, "url:", url)
28
- $modal.addClass("loading");
29
- $modal.find(".modal-content").load(url, () => {
30
- $modal.removeClass("loading");
31
- });
32
- });
33
-
34
- // Rails AJAX events
35
- document.body.addEventListener("ajax:error", (responseText) => {
36
- // console.log("ajax:error", responseText)
37
- const $container = $(`.constraints-editor[data-key="${responseText.detail[0].key}"]`)
38
- const $callout = $container.find(".callout");
39
- $callout.show();
40
- $callout.contents("p").html(`${responseText.detail[0].message}: <strong>${responseText.detail[0].error}</strong>`);
41
- $callout.addClass("alert");
42
- });
43
-
44
- document.body.addEventListener("ajax:success", (responseText) => {
45
- // console.log("ajax:success", responseText)
46
- const $container = $(`.constraints-editor[data-key="${responseText.detail[0].key}"]`)
47
- const $callout = $container.find(".callout");
48
- $modal.foundation("close");
49
- $callout.show();
50
- $callout.contents("p").html(responseText.detail[0].message);
51
- $callout.addClass("success");
52
- // reconstruct list
53
- $container.replaceWith(responseText.detail[0].html);
54
- });
55
- });
@@ -1,218 +0,0 @@
1
- /* eslint-disable require-jsdoc, func-style */
2
-
3
- /*
4
- * Since version 0.25 we follow a different strategy and opt to destroy and override completely the original editor
5
- * That's because editors are instantiated directly instead of creating a global function to instantiate them
6
- */
7
-
8
- import lineBreakButtonHandler from "src/decidim/editor/linebreak_module"
9
- import InscrybMDE from "inscrybmde"
10
- import Europa from "europa"
11
- import "inline-attachment/src/inline-attachment";
12
- import "inline-attachment/src/codemirror-4.inline-attachment";
13
- import "inline-attachment/src/jquery.inline-attachment";
14
- import hljs from "highlight.js";
15
- import "highlight.js/styles/github.css";
16
- import "src/decidim/editor/clipboard_override"
17
- import "src/decidim/vendor/image-resize.min"
18
- import "src/decidim/vendor/image-upload.min"
19
- import { marked } from "marked";
20
-
21
- const DecidimAwesome = window.DecidimAwesome || {};
22
- const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video", "image", "alt", "break", "width", "style", "code", "blockquote", "indent"];
23
-
24
- // A tricky way to destroy the quill editor
25
- export function destroyQuillEditor(container) {
26
- if (container) {
27
- const content = $(container).find(".ql-editor").html();
28
- $(container).html(content);
29
- $(container).siblings(".ql-toolbar").remove();
30
- $(container).find("*[class*='ql-']").removeClass((index, className) => (className.match(/(^|\s)ql-\S+/g) || []).join(" "));
31
- $(container).removeClass((index, className) => (className.match(/(^|\s)ql-\S+/g) || []).join(" "));
32
- if ($(container).next().is("p.help-text")) {
33
- $(container).next().remove();
34
- }
35
- }
36
- else {
37
- console.error(`editor [${container}] not exists`);
38
- }
39
- }
40
-
41
- export function createQuillEditor(container) {
42
- const toolbar = $(container).data("toolbar");
43
- const disabled = $(container).data("disabled");
44
- const allowedEmptyContentSelector = "iframe";
45
-
46
- let quillToolbar = [
47
- ["bold", "italic", "underline", "linebreak"],
48
- [{ list: "ordered" }, { list: "bullet" }],
49
- ["link", "clean"],
50
- ["code", "blockquote"],
51
- [{ "indent": "-1"}, { "indent": "+1" }]
52
- ];
53
-
54
- let addImage = false;
55
-
56
- if (toolbar === "full") {
57
- quillToolbar = [
58
- [{ header: [2, 3, 4, 5, 6, false] }],
59
- ...quillToolbar
60
- ];
61
- if (DecidimAwesome.allow_images_in_full_editor) {
62
- quillToolbar.push(["video", "image"]);
63
- addImage = true;
64
- } else {
65
- quillToolbar.push(["video"]);
66
- }
67
- } else if (toolbar === "basic") {
68
- if (DecidimAwesome.allow_images_in_small_editor) {
69
- quillToolbar.push(["video", "image"]);
70
- addImage = true;
71
- } else {
72
- quillToolbar.push(["video"]);
73
- }
74
- } else if (DecidimAwesome.allow_images_in_small_editor) {
75
- quillToolbar.push(["image"]);
76
- addImage = true;
77
- }
78
-
79
- let modules = {
80
- linebreak: {},
81
- toolbar: {
82
- container: quillToolbar,
83
- handlers: {
84
- "linebreak": lineBreakButtonHandler
85
- }
86
- }
87
- };
88
-
89
- const $input = $(container).siblings('input[type="hidden"]');
90
- container.innerHTML = $input.val() || "";
91
- const token = $('meta[name="csrf-token"]').attr("content");
92
- if (addImage) {
93
- modules.imageResize = {
94
- modules: ["Resize", "DisplaySize"]
95
- }
96
- modules.imageUpload = {
97
- url: DecidimAwesome.editor_uploader_path,
98
- method: "POST",
99
- name: "image",
100
- withCredentials: false,
101
- headers: { "X-CSRF-Token": token },
102
- callbackOK: (serverResponse, next) => {
103
- $("div.ql-toolbar").last().removeClass("editor-loading")
104
- next(serverResponse.url);
105
- },
106
- callbackKO: (serverError) => {
107
- $("div.ql-toolbar").last().removeClass("editor-loading")
108
- let msg = serverError && serverError.body;
109
- try {
110
- msg = JSON.parse(msg).message;
111
- } catch (evt) { console.error("Parsing error", evt); }
112
- console.error(`Image upload error: ${msg}`);
113
- let $p = $(`<p class="text-alert help-text">${msg}</p>`);
114
- $(container).after($p)
115
- setTimeout(() => {
116
- $p.fadeOut(1000, () => {
117
- $p.destroy();
118
- });
119
- }, 3000);
120
- },
121
- checkBeforeSend: (file, next) => {
122
- $("div.ql-toolbar").last().addClass("editor-loading")
123
- next(file);
124
- }
125
- }
126
- }
127
- const quill = new Quill(container, {
128
- modules: modules,
129
- formats: quillFormats,
130
- theme: "snow"
131
- });
132
-
133
- if (disabled) {
134
- quill.disable();
135
- }
136
-
137
- quill.on("text-change", () => {
138
- const text = quill.getText();
139
-
140
- // Triggers CustomEvent with the cursor position
141
- // It is required in input_mentions.js
142
- let event = new CustomEvent("quill-position", {
143
- detail: quill.getSelection()
144
- });
145
- container.dispatchEvent(event);
146
-
147
- if (text === "\n" || text === "\n\n") {
148
- $input.val("");
149
- } else {
150
- $input.val(quill.root.innerHTML);
151
- }
152
- if ((text === "\n" || text === "\n\n") && quill.root.querySelectorAll(allowedEmptyContentSelector).length === 0) {
153
- $input.val("");
154
- } else {
155
- const emptyParagraph = "<p><br></p>";
156
- const cleanHTML = quill.root.innerHTML.replace(
157
- new RegExp(`^${emptyParagraph}|${emptyParagraph}$`, "g"),
158
- ""
159
- );
160
- $input.val(cleanHTML);
161
- }
162
- });
163
- // After editor is ready, linebreak_module deletes two extraneous new lines
164
- quill.emitter.emit("editor-ready");
165
-
166
- if (addImage) {
167
- const text = $(container).data("dragAndDropHelpText") || DecidimAwesome.texts.drag_and_drop_image;
168
- $(container).after(`<p class="help-text" style="margin-top:-1.5rem;">${text}</p>`);
169
- }
170
-
171
- // After editor is ready, linebreak_module deletes two extraneous new lines
172
- quill.emitter.emit("editor-ready");
173
-
174
- return quill;
175
- }
176
-
177
- export function createMarkdownEditor(container) {
178
- const text = DecidimAwesome.texts.drag_and_drop_image;
179
- const token = $('meta[name="csrf-token"]').attr("content");
180
- const $input = $(container).siblings('input[type="hidden"]');
181
- const $faker = $('<textarea name="faker-inscrybmde"/>');
182
- const $form = $(container).closest("form");
183
- const europa = new Europa();
184
- $faker.val(europa.convert($input.val()));
185
- $faker.insertBefore($(container));
186
- $(container).hide();
187
- const inscrybmde = new InscrybMDE({
188
- element: $faker[0],
189
- spellChecker: false,
190
- renderingConfig: {
191
- codeSyntaxHighlighting: true,
192
- hljs: hljs
193
- }
194
- });
195
- $faker[0].InscrybMDE = inscrybmde;
196
-
197
- // Allow image upload
198
- if (DecidimAwesome.allow_images_in_markdown_editor) {
199
- $(inscrybmde.gui.statusbar).prepend(`<span class="help-text" style="float:left;margin:0;text-align:left;">${text}</span>`);
200
- window.inlineAttachment.editors.codemirror4.attach(inscrybmde.codemirror, {
201
- uploadUrl: DecidimAwesome.editor_uploader_path,
202
- uploadFieldName: "image",
203
- jsonFieldName: "url",
204
- extraHeaders: { "X-CSRF-Token": token }
205
- });
206
- }
207
-
208
- // Allow linebreaks
209
- marked.setOptions({
210
- breaks: true
211
- });
212
-
213
- // convert to html on submit
214
- $form.on("submit", () => {
215
- // e.preventDefault();
216
- $input.val(marked(inscrybmde.value()));
217
- });
218
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * When switching tabs in i18n fields, autofocus on the markdown if exists
3
- */
4
- $(() => {
5
- // Event launched by foundation
6
- $("[data-tabs]").on("change.zf.tabs", (event) => {
7
- const $container = $(event.target).closest(".label--tabs").next(".tabs-content").find(".tabs-panel.is-active");
8
- // fix inscrybmde if present
9
- let $input = $container.find('[name="faker-inscrybmde"]');
10
- if ($input.length > 0) {
11
- $input[0].InscrybMDE.codemirror.refresh();
12
- }
13
- // fix custom fields if present
14
- $input = $container.find(".proposal_custom_field:first");
15
- if ($input.length > 0) {
16
- // saves current data to the hidden field for the lang
17
- window.DecidimAwesome.CustomFieldsRenderer.storeData();
18
- // init the current language
19
- window.DecidimAwesome.CustomFieldsRenderer.init($input);
20
- }
21
- });
22
- });
@@ -1,19 +0,0 @@
1
- @import "inscrybmde/src/css/inscrybmde";
2
-
3
- // editor tweaks
4
- //
5
- .editor .CodeMirror {
6
- color: #333;
7
- font-weight: normal;
8
- line-height: 1.45;
9
-
10
- code {
11
- border: none;
12
- }
13
-
14
- .CodeMirror-code {
15
- span {
16
- color: #333 !important;
17
- }
18
- }
19
- }
@@ -1,58 +0,0 @@
1
- @import "stylesheets/decidim/variables";
2
- @import "stylesheets/decidim/utils/settings";
3
- @import "stylesheets/decidim/utils/mixins";
4
-
5
- .editor-loading {
6
- &::before {
7
- @include spinner(25px, $medium-gray, var(--primary), 800ms);
8
-
9
- float: right;
10
- content: "";
11
- vertical-align: middle;
12
- }
13
- }
14
- // some fix for the admin
15
- .form-group {
16
- .ql-container {
17
- background-color: white;
18
- }
19
- }
20
-
21
- // some fix for the public part
22
- .editor-container {
23
- overflow: hidden;
24
- }
25
-
26
- .editor.hashtags__container {
27
- >p.help-text {
28
- margin-top: -1rem;
29
- margin-bottom: 1.5rem;
30
- }
31
- }
32
-
33
- // For quill editors in custom fields
34
- .form-control[type="richtext"] {
35
- >p.help-text {
36
- margin-top: .2rem !important;
37
- }
38
-
39
- .ql-snow.ql-toolbar {
40
- button {
41
- width: 22px;
42
- margin: 1px 0;
43
- }
44
-
45
- + .ql-container.ql-snow {
46
- border-radius: 0;
47
- }
48
- }
49
- }
50
-
51
- .proposal_custom_fields_editor {
52
- .form-wrap.form-builder {
53
- .form-group > .form-control[type="richtext"] {
54
- padding: 0;
55
- border: none;
56
- }
57
- }
58
- }