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
@@ -0,0 +1,18 @@
1
+ <%= decidim_modal id: "voting-cards-modal-help", class:"reveal vote_proposal_modal voting-voting_cards" do %>
2
+ <div data-dialog-container>
3
+ <div class="reveal__content">
4
+ <div class="instructions mb-4"><%= vote_instructions %></div>
5
+ <div class="current-choice voting-voting_cards mb-4">
6
+ <div class="vote-card"></div>
7
+ </div>
8
+ <div class="future-dismiss">
9
+ <%= check_box_tag "voting_cards-skip_help", current_component.id, false %>
10
+ <%= label_tag "voting_cards-skip_help", t("decidim.decidim_awesome.voting.voting_cards.modal.skip") %>
11
+ </div>
12
+ </div>
13
+ </div>
14
+ <div data-dialog-actions>
15
+ <button type="button" class="button button__lg button__primary hover:bg-secondary vote-action" style="background-color: #e02d2d;"><%= t("decidim.decidim_awesome.voting.voting_cards.modal.proceed") %></button>
16
+ <button type="button" class="button button__lg button__transparent-secondary cancel-action hollow secondary" data-dialog-close="voting-cards-modal-help"><%= t("decidim.decidim_awesome.voting.voting_cards.modal.cancel") %></button>
17
+ </div>
18
+ <% end %>
@@ -1,35 +1,40 @@
1
- <h4 class="heading4 vote-title"><%= title %></h4>
1
+ <div class="flex flex-col justify-center awesome-voting-card">
2
+ <h4 class="heading4 vote-title mb-2" style="font-size:1.375rem;"><%= title %></h4>
2
3
 
3
- <div class="flex--sbc">
4
- <%= vote_block_for(proposal, 3) %>
5
- <%= vote_block_for(proposal, 2) %>
6
- <%= vote_block_for(proposal, 1) %>
7
- </div>
4
+ <div class="flex flex-row gap-1.5 mt-4">
5
+ <%= vote_block_for(proposal, 3) %>
6
+ <%= vote_block_for(proposal, 2) %>
7
+ <%= vote_block_for(proposal, 1) %>
8
+ </div>
9
+
10
+ <% if component_settings.voting_cards_show_abstain? %>
11
+ <%= action_authorized_link_to :vote,
12
+ voted_for?(0) ? t("decidim.decidim_awesome.voting.voting_cards.abstained") : proposal.manifest.label_for(0),
13
+ proposal_vote_path(0),
14
+ link_options(0).merge({
15
+ title: t("decidim.decidim_awesome.voting.voting_cards.voting_for", proposal: sanitized_title, type: proposal.manifest.label_for(0)),
16
+ class: "button button__sm button__transparent-secondary mb-4 vote-action abstain-button #{classes_for(0)}"
17
+ }) %>
18
+ <% end %>
8
19
 
9
- <% if component_settings.voting_cards_show_abstain? %>
10
- <%= action_authorized_link_to :vote,
11
- voted_for?(0) ? t("decidim.decidim_awesome.voting.voting_cards.abstained") : proposal.manifest.label_for(0),
12
- proposal_vote_path(0),
13
- link_options(0).merge({
14
- title: t("decidim.decidim_awesome.voting.voting_cards.voting_for", proposal: sanitized_title, type: proposal.manifest.label_for(0)),
15
- class: "button expanded vote-action abstain-button small #{classes_for(0)}"
16
- }) %>
17
- <% end %>
20
+ <% if voted_for_any? && !current_settings.votes_blocked? %>
21
+ <p class="text-center" style="margin-bottom:1rem;">
22
+ <%= action_authorized_link_to :unvote,
23
+ t("decidim.decidim_awesome.voting.voting_cards.change_vote"),
24
+ proposal_vote_path(current_vote&.weight),
25
+ remote: true,
26
+ method: :delete,
27
+ id: "change-vote",
28
+ class: "change-vote-button vote-action font-semibold" %>
29
+ </p>
30
+ <% elsif proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
31
+ <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.maximum_votes_reached") %></p>
32
+ <% elsif vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0 %>
33
+ <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.no_votes_remaining") %></p>
34
+ <% elsif current_settings.votes_blocked? || !current_component.participatory_space.can_participate?(current_user) %>
35
+ <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.votes_blocked") %></p>
36
+ <% end %>
37
+
38
+ </div>
18
39
 
19
- <% if voted_for_any? && !current_settings.votes_blocked? %>
20
- <p class="text-center">
21
- <%= action_authorized_link_to :unvote,
22
- t("decidim.decidim_awesome.voting.voting_cards.change_vote"),
23
- proposal_vote_path(current_vote&.weight),
24
- remote: true,
25
- method: :delete,
26
- id: "change-vote",
27
- class: "change-vote-button vote-action" %>
28
- </p>
29
- <% elsif proposal.maximum_votes_reached? && !proposal.can_accumulate_supports_beyond_threshold && current_component.participatory_space.can_participate?(current_user) %>
30
- <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.maximum_votes_reached") %></p>
31
- <% elsif vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0 %>
32
- <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.no_votes_remaining") %></p>
33
- <% elsif current_settings.votes_blocked? || !current_component.participatory_space.can_participate?(current_user) %>
34
- <p class="text-center"><%= t("decidim.proposals.proposals.vote_button.votes_blocked") %></p>
35
- <% end %>
40
+ <%= render :modal if current_component.settings.voting_cards_show_modal_help %>
@@ -12,11 +12,16 @@ module Decidim
12
12
 
13
13
  def vote_block_for(proposal, weight)
14
14
  render partial: "vote_block", locals: {
15
- proposal: proposal,
16
- weight: weight
15
+ proposal:,
16
+ weight:
17
17
  }
18
18
  end
19
19
 
20
+ def vote_instructions
21
+ translated_attribute(current_component.settings.voting_cards_instructions).presence || t("decidim.decidim_awesome.voting.voting_cards.default_instructions_html",
22
+ organization: current_organization.name)
23
+ end
24
+
20
25
  def proposal_votes(weight)
21
26
  model.weight_count(weight)
22
27
  end
@@ -30,7 +35,7 @@ module Decidim
30
35
  end
31
36
 
32
37
  def proposal_vote_path(weight)
33
- proposal_proposal_vote_path(proposal_id: proposal.id, from_proposals_list: from_proposals_list, weight: weight)
38
+ proposal_proposal_vote_path(proposal_id: proposal.id, from_proposals_list:, weight:)
34
39
  end
35
40
 
36
41
  def link_options(weight)
@@ -68,7 +73,7 @@ module Decidim
68
73
  return true
69
74
  end
70
75
 
71
- return true if vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0
76
+ true if vote_limit_enabled? && remaining_votes_count_for(current_user) <= 0
72
77
  end
73
78
 
74
79
  def voted_for_any?
@@ -11,7 +11,7 @@ module Decidim
11
11
  subconfig = AwesomeConfig.find_or_initialize_by(var: "#{var}_#{@ident}", organization: @organization)
12
12
  @constraint = ConfigConstraint.create!(
13
13
  awesome_config: subconfig,
14
- settings: settings
14
+ settings:
15
15
  )
16
16
  end
17
17
 
@@ -20,7 +20,7 @@ module Decidim
20
20
  return true if constraint.awesome_config.constraints.count > 1
21
21
 
22
22
  case constraint.awesome_config.var.to_s
23
- when /^proposal_custom_field/
23
+ when /^proposal_(private_)?custom_field/
24
24
  false
25
25
  else
26
26
  true
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Proposals
6
+ module Admin
7
+ ##
8
+ # Decorates update draft and update proposal
9
+ # to avoid private field to be logged in PaperTrail.
10
+ module UpdateProposalOverride
11
+ extend ActiveSupport::Concern
12
+
13
+ included do
14
+ private
15
+
16
+ alias_method :decidim_original_update_proposal, :update_proposal
17
+
18
+ def update_proposal
19
+ decidim_original_update_proposal
20
+ update_private_field!
21
+ end
22
+
23
+ def update_private_field!
24
+ @proposal.update_private_body!(form.private_body) if form.private_body.present?
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Proposals
6
+ ##
7
+ # Decorate create_collaborative_draft to avoid
8
+ # private data to be in PaperTrail
9
+ module CreateCollaborativeDraftOverride
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ private
14
+
15
+ alias_method :decidim_original_create_collaborative_draft, :create_collaborative_draft
16
+
17
+ def create_collaborative_draft
18
+ created_draft = decidim_original_create_collaborative_draft
19
+ # Update the proposal with the private body, to
20
+ # avoid tracebility on private fields.
21
+ created_draft.update_private_body!(form.private_body) if form.private_body.present?
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Proposals
6
+ ##
7
+ # Decorate create_proposal to avoid
8
+ # private data to be in PaperTrail
9
+ module CreateProposalOverride
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ private
14
+
15
+ alias_method :decidim_original_create_proposal, :create_proposal
16
+
17
+ def create_proposal
18
+ created_proposal = decidim_original_create_proposal
19
+ # Update the proposal with the private body, to
20
+ # avoid tracebility on private fields.
21
+ created_proposal.update_private_body!(form.private_body) if form.private_body.present?
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Proposals
6
+ ##
7
+ # Decorates update draft and update proposal
8
+ # to avoid private field to be logged in PaperTrail.
9
+ module UpdateCollaborativeDraftOverride
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ private
14
+
15
+ alias_method :decidim_original_update_collaborative_draft, :update_collaborative_draft
16
+
17
+ def update_collaborative_draft
18
+ decidim_original_update_collaborative_draft
19
+ # Update the proposal with the private body, to
20
+ # avoid tracebility on private fields.
21
+ @collaborative_draft.update_private_body!(form.private_body) if form.private_body.present?
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Proposals
6
+ ##
7
+ # Decorates update draft and update proposal
8
+ # to avoid private field to be logged in PaperTrail.
9
+ module UpdateProposalOverride
10
+ extend ActiveSupport::Concern
11
+ include Admin::UpdateProposalOverride
12
+
13
+ included do
14
+ private
15
+
16
+ alias_method :decidim_original_update_draft, :update_draft
17
+
18
+ def update_draft
19
+ decidim_original_update_draft
20
+ update_private_field!
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -18,7 +18,7 @@ module Decidim
18
18
  #
19
19
  # Returns nothing.
20
20
  def call
21
- return broadcast(:invalid) if form.invalid?
21
+ return broadcast(:invalid, form.errors.full_messages.join(". ")) if form.invalid?
22
22
  return broadcast(:invalid) if attributes.blank?
23
23
 
24
24
  begin
@@ -8,9 +8,10 @@ module Decidim
8
8
 
9
9
  # Public: Initializes the command.
10
10
  #
11
- def initialize(organization)
11
+ def initialize(organization, config_var = :proposal_custom_fields)
12
12
  @organization = organization
13
13
  @ident = rand(36**8).to_s(36)
14
+ @config_var = config_var
14
15
  end
15
16
 
16
17
  # Executes the command. Broadcasts these events:
@@ -20,13 +21,13 @@ module Decidim
20
21
  #
21
22
  # Returns nothing.
22
23
  def call
23
- fields = AwesomeConfig.find_or_initialize_by(var: :proposal_custom_fields, organization: @organization)
24
+ fields = AwesomeConfig.find_or_initialize_by(var: @config_var, organization: @organization)
24
25
  fields.value = {} unless fields.value.is_a? Hash
25
26
  # TODO: prevent (unlikely) colisions with exisiting values
26
27
  fields.value[@ident] = default_definition
27
28
  fields.save!
28
29
 
29
- create_constraint_never(:proposal_custom_field)
30
+ create_constraint_never(@config_var == :proposal_custom_fields ? :proposal_custom_field : :proposal_private_custom_field)
30
31
 
31
32
  broadcast(:ok, @ident)
32
33
  rescue StandardError => e
@@ -11,7 +11,7 @@ module Decidim
11
11
  def initialize(item, organization)
12
12
  @item = item
13
13
  @organization = organization
14
- @redirections = AwesomeConfig.find_by(var: :custom_redirects, organization: organization)
14
+ @redirections = AwesomeConfig.find_by(var: :custom_redirects, organization:)
15
15
  end
16
16
 
17
17
  # Executes the command. Broadcasts these events:
@@ -11,7 +11,7 @@ module Decidim
11
11
  def initialize(item, menu_name, organization)
12
12
  @item = item
13
13
  @organization = organization
14
- @menu = AwesomeConfig.find_by(var: menu_name, organization: organization)
14
+ @menu = AwesomeConfig.find_by(var: menu_name, organization:)
15
15
  end
16
16
 
17
17
  # Executes the command. Broadcasts these events:
@@ -8,9 +8,10 @@ module Decidim
8
8
  #
9
9
  # key - the key to destroy inise proposal_custom_fields
10
10
  # organization
11
- def initialize(key, organization)
11
+ def initialize(key, organization, config_var = :proposal_custom_fields)
12
12
  @key = key
13
13
  @organization = organization
14
+ @config_var = config_var
14
15
  end
15
16
 
16
17
  # Executes the command. Broadcasts these events:
@@ -20,14 +21,16 @@ module Decidim
20
21
  #
21
22
  # Returns nothing.
22
23
  def call
23
- fields = AwesomeConfig.find_by(var: :proposal_custom_fields, organization: @organization)
24
+ fields = AwesomeConfig.find_by(var: @config_var, organization: @organization)
24
25
  return broadcast(:invalid, "Not a hash") unless fields&.value.is_a? Hash
25
26
  return broadcast(:invalid, "#{key} key invalid") unless fields.value.has_key?(@key)
26
27
 
27
28
  fields.value.except!(@key)
28
29
  fields.save!
30
+
29
31
  # remove constrains associated (a new config var is generated automatically, by removing it, it will trigger destroy on dependents)
30
- constraint = AwesomeConfig.find_by(var: "proposal_custom_field_#{@key}", organization: @organization)
32
+ constraint = @config_var == :proposal_custom_fields ? :proposal_custom_field : :proposal_private_custom_field
33
+ constraint = AwesomeConfig.find_by(var: "#{constraint}_#{@key}", organization: @organization)
31
34
  constraint.destroy! if constraint.present?
32
35
 
33
36
  broadcast(:ok, @key)
@@ -34,7 +34,7 @@ module Decidim
34
34
  end
35
35
  end
36
36
 
37
- broadcast(:ok, { scope: scope, key: @text })
37
+ broadcast(:ok, { scope:, key: @text })
38
38
  rescue StandardError => e
39
39
  broadcast(:invalid, e.message)
40
40
  end
@@ -18,7 +18,7 @@ module Decidim
18
18
  #
19
19
  # Returns nothing.
20
20
  def call
21
- return broadcast(:invalid) if form.invalid?
21
+ return broadcast(:invalid, form.errors.full_messages.join(". ")) if form.invalid?
22
22
  return broadcast(:invalid) if attributes.blank?
23
23
 
24
24
  begin
@@ -38,8 +38,8 @@ module Decidim
38
38
  delegate :to_params, to: :form
39
39
 
40
40
  def url_exists?
41
- return unless redirects
42
- return unless redirects.value.is_a? Hash
41
+ return false unless redirects
42
+ return false unless redirects.value.is_a? Hash
43
43
 
44
44
  redirects.value[item.origin].present?
45
45
  end
@@ -2,13 +2,7 @@
2
2
 
3
3
  module Decidim
4
4
  module DecidimAwesome
5
- # maintains compatibility with v0.26 which uses Rectify
6
- if defined? ::Decidim::Command
7
- class Command < ::Decidim::Command
8
- end
9
- else
10
- class Command < ::Rectify::Command
11
- end
5
+ class Command < ::Decidim::Command
12
6
  end
13
7
  end
14
8
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module Admin
6
+ module MaintenanceContext
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ layout "decidim/decidim_awesome/admin/maintenance"
11
+ helper_method :current_view, :available_views, :present_private_data
12
+
13
+ private
14
+
15
+ def present_private_data(model)
16
+ PrivateDataPresenter.new(model)
17
+ end
18
+
19
+ def current_view
20
+ return params[:id] if available_views.include?(params[:id])
21
+
22
+ available_views.keys.first
23
+ end
24
+
25
+ def available_views
26
+ {
27
+ "private_data" => {
28
+ title: I18n.t("private_data", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
29
+ icon: "spy-line",
30
+ path: decidim_admin_decidim_awesome.maintenance_path("private_data")
31
+ },
32
+ "checks" => {
33
+ title: I18n.t("checks", scope: "decidim.decidim_awesome.admin.menu.maintenance"),
34
+ icon: "pulse",
35
+ path: decidim_admin_decidim_awesome.checks_maintenance_index_path
36
+ }
37
+ }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -13,12 +13,13 @@ module Decidim
13
13
  end
14
14
 
15
15
  def applied_filters_tags(i18n_ctx)
16
- if global? && params[:admin_role_type].present?
16
+ admin_role_type = PaperTrailVersion.safe_admin_role_type(params[:admin_role_type])
17
+ if global? && admin_role_type.present?
17
18
  content_tag(:span, class: "label secondary") do
18
19
  concat "#{i18n_filter_label(:admin_role_type, filterable_i18n_scope_from_ctx(i18n_ctx))}: "
19
- concat t("decidim.decidim_awesome.admin.admin_accountability.admin_roles.#{params[:admin_role_type]}", default: params[:admin_role_type])
20
+ concat t("decidim.decidim_awesome.admin.admin_accountability.admin_roles.#{admin_role_type}", default: admin_role_type)
20
21
  concat icon_link_to(
21
- "circle-x",
22
+ "close-circle-line",
22
23
  url_for(export_params.except(:admin_role_type)),
23
24
  t("decidim.admin.actions.cancel"),
24
25
  class: "action-icon--remove"
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module ContentSecurityPolicy
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ after_action :append_awesome_csp_directives
10
+ end
11
+
12
+ private
13
+
14
+ def append_awesome_csp_directives
15
+ # this is necessary for custom fields
16
+ content_security_policy.append_csp_directive("font-src", "data:") if DecidimAwesome.enabled?(:proposal_custom_fields)
17
+ append_awesome_intergram_directives
18
+ end
19
+
20
+ def append_awesome_intergram_directives
21
+ return unless DecidimAwesome.enabled?(:intergram_for_admins) || DecidimAwesome.enabled?(:intergram_for_public)
22
+
23
+ intergram = URI.parse(DecidimAwesome.intergram_url)
24
+ if intergram.host && intergram.scheme
25
+ content_security_policy.append_csp_directive("script-src", "#{intergram.scheme}://#{intergram.host}")
26
+ content_security_policy.append_csp_directive("frame-src", "#{intergram.scheme}://#{intergram.host}")
27
+ # this script is in the intergram code, but does not look necessary to work
28
+ # content_security_policy.append_csp_directive("frame-src", "http://www.loadmill.com")
29
+ # content_security_policy.append_csp_directive("frame-src", "http://app.loadmill.com")
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DecidimAwesome
5
+ module LimitPendingAmendments
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ # rubocop:disable Rails/LexicallyScopedActionFilter
10
+ before_action :limit_pending_amendments, only: [:new, :create]
11
+ # rubocop:enable Rails/LexicallyScopedActionFilter
12
+
13
+ private
14
+
15
+ def limit_pending_amendments
16
+ return unless amendable&.amendments && amendable&.component&.settings.try(:limit_pending_amendments)
17
+ return unless amendable.component.settings.try(:amendments_enabled)
18
+ return unless amendable.component.current_settings.try(:amendment_creation_enabled)
19
+
20
+ return unless existing_emendations.any?
21
+
22
+ flash[:alert] = t("pending_limit_reached", scope: "decidim.decidim_awesome.amendments", emendation: translated_attribute(existing_emendations.first.title))
23
+ redirect_back(fallback_location: Decidim::ResourceLocatorPresenter.new(amendable).path)
24
+ end
25
+
26
+ def existing_emendations
27
+ @existing_emendations ||= begin
28
+ existing = amendable.amendments.where(state: :evaluating)
29
+ existing.filter_map { |amendment| !amendment.emendation&.hidden? && amendment.emendation }
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -50,7 +50,7 @@ module Decidim
50
50
  destination = "#{destination}#{union}#{query}"
51
51
  end
52
52
 
53
- return destination.strip if destination.present?
53
+ destination.strip if destination.present?
54
54
  end
55
55
  end
56
56
  end
@@ -14,6 +14,8 @@ module Decidim
14
14
 
15
15
  private
16
16
 
17
+ alias_method :decidim_original_reorder, :reorder
18
+
17
19
  # read order from session if available
18
20
  def order
19
21
  @order ||= detect_order(session[:order]) || default_order
@@ -31,38 +33,23 @@ module Decidim
31
33
  end
32
34
  end
33
35
 
34
- # rubocop:disable Metrics/CyclomaticComplexity
35
36
  def reorder(proposals)
37
+ title_by_locale = Arel.sql(proposals.sanitize_sql(["decidim_proposals_proposals.title->>? #{collation}", locale]))
38
+ title_by_machine_translation = Arel.sql(proposals.sanitize_sql(["decidim_proposals_proposals.title->'machine_translations'->>? #{collation}", locale]))
39
+ title_by_default_locale = Arel.sql(proposals.sanitize_sql(["decidim_proposals_proposals.title->>? #{collation}", default_locale]))
36
40
  case order
37
41
  when "az"
38
- proposals.order(Arel.sql("CONCAT(decidim_proposals_proposals.title->>'#{locale}',
39
- decidim_proposals_proposals.title->'machine_translations'->>'#{locale}',
40
- decidim_proposals_proposals.title->>'#{default_locale}') #{collation} ASC"))
42
+ proposals.order(title_by_locale => :asc, title_by_machine_translation => :asc, title_by_default_locale => :asc)
41
43
  when "za"
42
- proposals.order(Arel.sql("CONCAT(decidim_proposals_proposals.title->>'#{locale}',
43
- decidim_proposals_proposals.title->'machine_translations'->>'#{locale}',
44
- decidim_proposals_proposals.title->>'#{default_locale}') #{collation} DESC"))
44
+ proposals.order(title_by_locale => :desc, title_by_machine_translation => :desc, title_by_default_locale => :desc)
45
45
  when "supported_first"
46
46
  proposals.joins(my_votes_join).group(:id).order(Arel.sql("COUNT(decidim_proposals_proposal_votes.id) DESC"))
47
47
  when "supported_last"
48
48
  proposals.joins(my_votes_join).group(:id).order(Arel.sql("COUNT(decidim_proposals_proposal_votes.id) ASC"))
49
- when "most_commented"
50
- proposals.left_joins(:comments).group(:id).order(Arel.sql("COUNT(decidim_comments_comments.id) DESC"))
51
- when "most_endorsed"
52
- proposals.order(endorsements_count: :desc)
53
- when "most_followed"
54
- proposals.left_joins(:follows).group(:id).order(Arel.sql("COUNT(decidim_follows.id) DESC"))
55
- when "most_voted"
56
- proposals.order(proposal_votes_count: :desc)
57
- when "random"
58
- proposals.order_randomly(random_seed)
59
- when "recent"
60
- proposals.order(published_at: :desc)
61
- when "with_more_authors"
62
- proposals.order(coauthorships_count: :desc)
49
+ else
50
+ decidim_original_reorder(proposals)
63
51
  end
64
52
  end
65
- # rubocop:enable Metrics/CyclomaticComplexity
66
53
 
67
54
  def collation
68
55
  @collation ||= begin