decidim-decidim_awesome 0.10.3 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-decidim_awesome might be problematic. Click here for more details.

Files changed (232) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -5
  3. data/README.md +65 -67
  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 +44 -0
  6. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +5 -12
  7. data/app/cells/decidim/decidim_awesome/voting/proposal_metadata_cell.rb +54 -0
  8. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/modal.erb +18 -0
  9. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +37 -32
  10. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb +9 -4
  11. data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +1 -1
  12. data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +2 -2
  13. data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +2 -2
  14. data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +1 -1
  15. data/app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb +1 -1
  16. data/app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb +1 -1
  17. data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +1 -1
  18. data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +1 -1
  19. data/app/commands/decidim/decidim_awesome/admin/update_custom_redirect.rb +2 -2
  20. data/app/commands/decidim/decidim_awesome/command.rb +1 -7
  21. data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +1 -1
  22. data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +3 -4
  23. data/app/controllers/concerns/decidim/decidim_awesome/content_security_policy.rb +34 -0
  24. data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +1 -1
  25. data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +22 -9
  26. data/app/controllers/concerns/decidim/decidim_awesome/proposals/proposal_votes_controller_override.rb +3 -3
  27. data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
  28. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +7 -7
  29. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +8 -10
  30. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +20 -19
  31. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +6 -8
  32. data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +2 -2
  33. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +6 -8
  34. data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +2 -2
  35. data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +2 -2
  36. data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +2 -2
  37. data/app/controllers/decidim/decidim_awesome/blank_component_controller.rb +8 -3
  38. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +3 -3
  39. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +11 -5
  40. data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +1 -1
  41. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +13 -25
  42. data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +2 -2
  43. data/app/forms/decidim/decidim_awesome/admin/intergram_form.rb +4 -0
  44. data/app/forms/decidim/decidim_awesome/admin/menu_form.rb +4 -4
  45. data/app/helpers/concerns/decidim/decidim_awesome/amendments_helper_override.rb +8 -1
  46. data/app/helpers/concerns/decidim/decidim_awesome/breadcrumb_helper_override.rb +23 -0
  47. data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +23 -39
  48. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +2 -2
  49. data/app/helpers/decidim/decidim_awesome/map_helper.rb +8 -27
  50. data/app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb +5 -4
  51. data/app/middleware/decidim/decidim_awesome/current_config.rb +3 -5
  52. data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +1 -1
  53. data/app/models/decidim/decidim_awesome/awesome_config.rb +1 -1
  54. data/app/models/decidim/decidim_awesome/paper_trail_version.rb +4 -8
  55. data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +1 -1
  56. data/app/models/decidim/decidim_awesome/vote_weight.rb +2 -2
  57. data/app/overrides/decidim/proposals/proposals/{show → _proposal_aside}/limit_amendments_modal.html.erb.deface +1 -1
  58. data/app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface +1 -1
  59. data/app/overrides/layouts/decidim/_decidim_javascript/add_awesome_tags.html.erb.deface +6 -0
  60. data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +4 -11
  61. data/app/overrides/layouts/decidim/admin/_header/{replace_scripts.html.erb.deface → add_awesome_tags.html.erb.deface} +4 -4
  62. data/app/packs/entrypoints/decidim_admin_decidim_awesome.js +1 -2
  63. data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.js +4 -0
  64. data/app/packs/entrypoints/decidim_admin_decidim_awesome_global.scss +1 -0
  65. data/app/packs/entrypoints/decidim_decidim_awesome.js +2 -2
  66. data/app/packs/entrypoints/decidim_editor.js +14 -0
  67. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +95 -70
  68. data/app/packs/src/decidim/decidim_awesome/admin/check_redirections.js +46 -41
  69. data/app/packs/src/decidim/decidim_awesome/admin/codemirror.js +3 -3
  70. data/app/packs/src/decidim/decidim_awesome/admin/constraint_form_events.js +115 -0
  71. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +4 -1
  72. data/app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js +22 -11
  73. data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +26 -8
  74. data/app/packs/src/decidim/decidim_awesome/admin/user_picker.js +34 -21
  75. data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +20 -22
  76. data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +5 -16
  77. data/app/packs/src/decidim/decidim_awesome/awesome_admin_global.js +1 -0
  78. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +0 -15
  79. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/fetcher.js +33 -11
  80. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher.js +9 -12
  81. data/app/packs/src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher.js +28 -0
  82. data/app/packs/src/decidim/decidim_awesome/awesome_map/awesome_map.js +3 -4
  83. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +12 -12
  84. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/meetings_controller.js +11 -7
  85. data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/proposals_controller.js +6 -13
  86. data/app/packs/src/decidim/decidim_awesome/awesome_map/controls_ui.js +51 -20
  87. data/app/packs/src/decidim/decidim_awesome/awesome_map/load_map.js +27 -18
  88. data/app/packs/src/decidim/decidim_awesome/editor/index.js +94 -0
  89. data/app/packs/src/decidim/decidim_awesome/forms/autosave.js +28 -23
  90. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +9 -14
  91. data/app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js +27 -32
  92. data/app/packs/src/decidim/decidim_awesome/proposals/images.js +16 -10
  93. data/app/packs/src/decidim/decidim_awesome/voting/voting_cards.js +47 -38
  94. data/app/packs/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +11 -12
  95. data/app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss +15 -0
  96. data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +19 -12
  97. data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +8 -32
  98. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +28 -78
  99. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_styles.scss +48 -0
  100. data/app/packs/stylesheets/decidim/decidim_awesome/admin/intergram_fixes.scss +11 -0
  101. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +15 -24
  102. data/app/packs/stylesheets/decidim/decidim_awesome/amendments/modal.scss +5 -0
  103. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +9 -47
  104. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +3 -12
  105. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +3 -19
  106. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +1 -1
  107. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +27 -21
  108. data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +6 -6
  109. data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +32 -101
  110. data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +5 -26
  111. data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +34 -52
  112. data/app/permissions/decidim/decidim_awesome/permissions.rb +3 -4
  113. data/app/presenters/concerns/decidim/decidim_awesome/breadcrumb_root_menu_item_presenter_override.rb +23 -0
  114. data/app/presenters/concerns/decidim/decidim_awesome/menu_item_presenter_override.rb +10 -2
  115. data/app/presenters/concerns/decidim/decidim_awesome/menu_presenter_override.rb +8 -0
  116. data/app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb +1 -1
  117. data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +11 -11
  118. data/app/presenters/decidim/decidim_awesome/user_entity_presenter.rb +1 -1
  119. data/app/queries/decidim/decidim_awesome/private_data_finder.rb +1 -1
  120. data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +0 -8
  121. data/app/views/decidim/decidim_awesome/admin/admin_accountability/index.html.erb +23 -17
  122. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +1 -3
  123. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +3 -3
  124. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +20 -21
  125. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +6 -5
  126. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +2 -2
  127. data/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb +39 -23
  128. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +4 -6
  129. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +64 -76
  130. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +15 -11
  131. data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +8 -6
  132. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +22 -12
  133. data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +1 -49
  134. data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +14 -9
  135. data/app/views/decidim/decidim_awesome/admin/constraints/show.html.erb +14 -9
  136. data/app/views/decidim/decidim_awesome/admin/custom_redirects/_form.html.erb +20 -5
  137. data/app/views/decidim/decidim_awesome/admin/custom_redirects/edit.html.erb +5 -5
  138. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +15 -15
  139. data/app/views/decidim/decidim_awesome/admin/custom_redirects/new.html.erb +5 -5
  140. data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +4 -4
  141. data/app/views/decidim/decidim_awesome/admin/menu_hacks/_form.html.erb +6 -6
  142. data/app/views/decidim/decidim_awesome/admin/menu_hacks/edit.html.erb +21 -12
  143. data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +16 -18
  144. data/app/views/decidim/decidim_awesome/admin/menu_hacks/new.html.erb +21 -12
  145. data/app/views/decidim/decidim_awesome/admin/shared/_filters_with_date.html.erb +14 -18
  146. data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +18 -11
  147. data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +3 -5
  148. data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +7 -12
  149. data/app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb +53 -37
  150. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +14 -5
  151. data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_vote_button.html.erb +0 -3
  152. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +9 -7
  153. data/app/views/layouts/decidim/decidim_awesome/_intergram_widget.html.erb +9 -6
  154. data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +3 -12
  155. data/config/assets.rb +3 -33
  156. data/config/i18n-tasks.yml +1 -0
  157. data/config/locales/ca.yml +17 -94
  158. data/config/locales/cs.yml +15 -93
  159. data/config/locales/de.yml +15 -91
  160. data/config/locales/en.yml +24 -28
  161. data/config/locales/es.yml +18 -96
  162. data/config/locales/eu.yml +8 -18
  163. data/config/locales/fr.yml +15 -94
  164. data/config/locales/hu.yml +4 -18
  165. data/config/locales/it.yml +9 -26
  166. data/config/locales/ja.yml +16 -93
  167. data/config/locales/lt.yml +2 -4
  168. data/config/locales/nl.yml +8 -18
  169. data/config/locales/pt-BR.yml +11 -25
  170. data/config/locales/ro-RO.yml +2 -14
  171. data/config/locales/sv.yml +10 -21
  172. data/config/rubocop/disabled.yml +11 -0
  173. data/config/rubocop/faker.yml +480 -0
  174. data/config/rubocop/rails.yml +88 -0
  175. data/config/rubocop/rspec.yml +65 -0
  176. data/config/rubocop/ruby.yml +1210 -0
  177. data/db/migrate/20240306175331_rename_editor_images_awesome_config.rb +18 -0
  178. data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +1 -1
  179. data/db/seeds.rb +3 -3
  180. data/lib/decidim/decidim_awesome/admin_engine.rb +4 -1
  181. data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +2 -3
  182. data/lib/decidim/decidim_awesome/awesome.rb +42 -28
  183. data/lib/decidim/decidim_awesome/awesome_helpers.rb +1 -1
  184. data/lib/decidim/decidim_awesome/checksums.yml +39 -60
  185. data/lib/decidim/decidim_awesome/config.rb +1 -1
  186. data/lib/decidim/decidim_awesome/custom_fields.rb +5 -5
  187. data/lib/decidim/decidim_awesome/engine.rb +24 -6
  188. data/lib/decidim/decidim_awesome/iframe_component/component.rb +1 -2
  189. data/lib/decidim/decidim_awesome/lock.rb +2 -2
  190. data/lib/decidim/decidim_awesome/map_component/component.rb +1 -1
  191. data/lib/decidim/decidim_awesome/menu.rb +33 -14
  192. data/lib/decidim/decidim_awesome/menu_hacker.rb +4 -8
  193. data/lib/decidim/decidim_awesome/system_checker.rb +2 -4
  194. data/lib/decidim/decidim_awesome/test/factories.rb +10 -10
  195. data/lib/decidim/decidim_awesome/test/initializer.rb +3 -11
  196. data/lib/decidim/decidim_awesome/test/layouts/decidim/_head.html.erb +2 -2
  197. data/lib/decidim/decidim_awesome/test/layouts/decidim/admin/_header.html.erb +2 -2
  198. data/lib/decidim/decidim_awesome/test/shared_examples/box_label_editor_examples.rb +18 -18
  199. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +3 -3
  200. data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +11 -11
  201. data/lib/decidim/decidim_awesome/test/shared_examples/custom_redirects_contexts.rb +7 -7
  202. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +26 -66
  203. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +10 -9
  204. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +30 -20
  205. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +19 -10
  206. data/lib/decidim/decidim_awesome/version.rb +2 -2
  207. data/lib/decidim/decidim_awesome/voting_manifest.rb +5 -10
  208. data/lib/decidim/decidim_awesome.rb +1 -2
  209. data/lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake +1 -1
  210. data/lib/tasks/decidim_awesome_upgrade_tasks.rake +4 -0
  211. data/package.json +19 -28
  212. metadata +40 -56
  213. data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +0 -18
  214. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/show.erb +0 -15
  215. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/vote_button.erb +0 -15
  216. data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter_cell.rb +0 -21
  217. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal/show.erb +0 -16
  218. data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal_cell.rb +0 -20
  219. data/app/cells/decidim/proposals/proposal_m/footer.erb +0 -13
  220. data/app/overrides/layouts/decidim/_head/add_awesome_legacy_scripts.rb +0 -14
  221. data/app/overrides/layouts/decidim/admin/_header/replace_styles.html.erb.deface +0 -3
  222. data/app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js +0 -2
  223. data/app/packs/entrypoints/decidim_decidim_awesome_admin_form_exit_warn.js +0 -1
  224. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +0 -55
  225. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +0 -213
  226. data/app/packs/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +0 -19
  227. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +0 -58
  228. data/app/packs/stylesheets/vendor/select2-foundation-theme.scss +0 -348
  229. data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +0 -65
  230. data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +0 -11
  231. data/app/views/decidim/decidim_awesome/voting/voting_cards/_proposal_m_cell_footer.erb +0 -15
  232. /data/app/packs/src/decidim/decidim_awesome/{editors/tabs_focus.js → admin/tabs_change.js} +0 -0
@@ -1,13 +1,31 @@
1
- import "select2"
1
+ /* eslint-disable no-new */
2
2
 
3
- $(() => {
4
- const $select = $("#config_additional_proposal_sortings");
5
- $select.select2({
6
- theme: "foundation"
3
+ import TomSelect from "tom-select/dist/cjs/tom-select.popular";
4
+
5
+ document.addEventListener("DOMContentLoaded", () => {
6
+ const selectContainer = document.getElementById("config_additional_proposal_sortings");
7
+
8
+ if (!selectContainer) {
9
+ return;
10
+ }
11
+
12
+ new TomSelect(selectContainer, {
13
+ plugins: ["remove_button", "dropdown_input"],
14
+ create: false,
15
+ render: {
16
+ option: function (data, escape) {
17
+ return `<div>${escape(data.text)}</div>`;
18
+ },
19
+ item: function (data, escape) {
20
+ return Boolean(data.is_admin) || data.isAdmin === "true"
21
+ ? `<div class="is-admin">${escape(data.text)}</div>`
22
+ : `<div>${escape(data.text)}</div>`;
23
+ }
24
+ }
7
25
  });
8
- $("#additional_proposal_sortings-enable-all").on("click", (evt) => {
26
+
27
+ document.getElementById("additional_proposal_sortings-enable-all").addEventListener("click", (evt) => {
9
28
  evt.preventDefault();
10
- $select.find("option").prop("selected", true);
11
- $select.trigger("change");
29
+ selectContainer.tomselect.setValue(Array.from(document.getElementById("config_additional_proposal_sortings").children).map((el) => el.value))
12
30
  });
13
31
  });
@@ -1,25 +1,38 @@
1
- /* eslint-disable no-invalid-this */
2
- import "select2"
3
- import "stylesheets/decidim/decidim_awesome/admin/user_picker.scss"
1
+ import TomSelect from "tom-select/dist/cjs/tom-select.popular";
4
2
 
5
- $(() => {
6
- $("select.multiusers-select").each(function() {
7
- const url = $(this).attr("data-url");
8
- $(this).select2({
9
- ajax: {
10
- url: url,
11
- delay: 100,
12
- dataType: "json",
13
- processResults: (data) => {
14
- return {
15
- results: data
16
- }
17
- }
3
+ document.addEventListener("DOMContentLoaded", () => {
4
+ const tagContainers = document.querySelectorAll(".multiusers-select");
5
+ const config = (element) => ({
6
+ plugins: ["remove_button", "dropdown_input"],
7
+ create: false,
8
+ render: {
9
+ option: function (data, escape) {
10
+ return `<div>${escape(data.text)}</div>`;
18
11
  },
19
- escapeMarkup: (markup) => markup,
20
- templateSelection: (item) => `${item.text}`,
21
- minimumInputLength: 1,
22
- theme: "foundation"
23
- });
12
+ item: function (data, escape) {
13
+ return Boolean(data.is_admin) || data.isAdmin === "true"
14
+ ? `<div class="is-admin">${escape(data.text)}</div>`
15
+ : `<div>${escape(data.text)}</div>`;
16
+ }
17
+ },
18
+ shouldLoad: function (query) {
19
+ return query.length > 1;
20
+ },
21
+ load: function (query, callback) {
22
+ const { url } = element.dataset;
23
+ const join = url.includes("?")
24
+ ? "&"
25
+ : "?";
26
+ const params = new URLSearchParams({
27
+ term: query
28
+ });
29
+
30
+ fetch(`${url}${join}${params}`).
31
+ then((response) => response.json()).
32
+ then((json) => callback(json)).
33
+ catch(() => callback());
34
+ }
24
35
  });
36
+
37
+ tagContainers.forEach((container) => new TomSelect(container, config(container)));
25
38
  });
@@ -1,30 +1,28 @@
1
- $(() => {
2
- const $modal = $("#LimitAmendmentsModal");
3
- if ($modal.length === 0 || $(".sign-out-link").length === 0) {
1
+ document.addEventListener("DOMContentLoaded", () => {
2
+ const modalId = "LimitAmendmentsModal";
3
+ const modalEl = document.getElementById(modalId);
4
+ const amendButton = document.getElementById("amend-button");
5
+ const limitAmendments = modalEl && JSON.parse(modalEl.dataset.limitAmendments);
6
+
7
+ if (!amendButton || !limitAmendments || document.querySelector('a[href^="/users/sign_in"]')) {
4
8
  return;
5
9
  }
6
10
 
7
- const showModal = () => {
8
- if ($modal.is(":visible")) {
9
- return false;
10
- }
11
-
12
- if ($modal.data("limitAmendments")) {
13
- return true;
14
- }
15
-
16
- return false;
17
- };
18
-
19
- $modal.find("a").on("click", () => {
20
- $modal.foundation("close");
11
+ modalEl.querySelectorAll("a").forEach((aEl) => {
12
+ aEl.addEventListener("click", () => {
13
+ window.Decidim.currentDialogs[modalId].close();
14
+ });
21
15
  });
22
16
 
23
- $(".card__amend-button").on("click", ".amend_button_card_cell", (evt) => {
24
- if (showModal()) {
25
- evt.preventDefault();
26
- evt.stopPropagation();
27
- $modal.foundation("open");
17
+ /**
18
+ * Determines if the modal should be displayed based on its current state and data attributes.
19
+ */
20
+ amendButton.addEventListener("click", (event) => {
21
+ const modal = window.Decidim.currentDialogs[modalId];
22
+ if (modal) {
23
+ event.preventDefault();
24
+ event.stopPropagation();
25
+ modal.open();
28
26
  }
29
27
  });
30
28
  });
@@ -1,24 +1,13 @@
1
- // Webpack seems to "forgget" about certain libraries already being loaded
2
- // if javascript_pack_tag is called two times, let's include the whole Decidim admin here instead
3
- import "entrypoints/decidim_admin"
4
1
  // Custom scripts for awesome
5
- import "src/decidim/decidim_awesome/admin/constraints"
2
+ import "src/decidim/decidim_awesome/admin/constraint_form_events"
6
3
  import "src/decidim/decidim_awesome/admin/auto_edit"
7
4
  import "src/decidim/decidim_awesome/admin/user_picker"
8
5
  import "src/decidim/decidim_awesome/admin/proposal_sortings"
9
- import "src/decidim/decidim_awesome/editors/tabs_focus"
10
6
  import "src/decidim/decidim_awesome/admin/codemirror"
11
7
  import "src/decidim/decidim_awesome/admin/check_redirections"
8
+ import "src/decidim/decidim_awesome/admin/form_exit_warn"
12
9
 
13
- import {destroyQuillEditor, createQuillEditor, createMarkdownEditor} from "src/decidim/decidim_awesome/editors/editor"
10
+ import "src/decidim/decidim_awesome/proposals/custom_fields"
11
+ import "src/decidim/decidim_awesome/admin/custom_fields_builder"
14
12
 
15
- $(() => {
16
- $(".editor-container").each((_idx, container) => {
17
- destroyQuillEditor(container);
18
- if (window.DecidimAwesome.use_markdown_editor) {
19
- createMarkdownEditor(container);
20
- } else {
21
- createQuillEditor(container);
22
- }
23
- });
24
- });
13
+ window.DecidimAwesome = window.DecidimAwesome || {};
@@ -0,0 +1 @@
1
+ import "src/decidim/decidim_awesome/admin/tabs_change"
@@ -2,18 +2,3 @@ import "src/decidim/decidim_awesome/proposals/images"
2
2
  import "src/decidim/decidim_awesome/forms/autosave"
3
3
  import "src/decidim/decidim_awesome/voting/voting_cards"
4
4
  import "src/decidim/decidim_awesome/amendments/show_modal_on_limits"
5
- import {destroyQuillEditor, createQuillEditor, createMarkdownEditor} from "src/decidim/decidim_awesome/editors/editor"
6
-
7
- $(() => {
8
- // rebuild editors
9
- if (window.DecidimAwesome.allow_images_in_full_editor || window.DecidimAwesome.allow_images_in_small_editor || window.DecidimAwesome.use_markdown_editor) {
10
- $(".editor-container").each((_idx, container) => {
11
- destroyQuillEditor(container);
12
- if (window.DecidimAwesome.use_markdown_editor) {
13
- createMarkdownEditor(container);
14
- } else {
15
- createQuillEditor(container);
16
- }
17
- });
18
- }
19
- });
@@ -30,7 +30,7 @@ export default class Fetcher {
30
30
  api.fetchAll((result) => {
31
31
  if (result) {
32
32
  const collection = result.component[this.collection];
33
- // console.log("collection",collection)
33
+ // console.log("collection", collection)
34
34
 
35
35
  collection.edges.forEach((element) => {
36
36
  let node = element.node;
@@ -56,14 +56,15 @@ export default class Fetcher {
56
56
  }
57
57
 
58
58
  decorateNode(node) {
59
- const body = this.findTranslation(node.body.translations);
59
+ const body = this.findTranslation(node.body.translations)
60
60
  const title = this.findTranslation(node.title.translations);
61
61
  node.hashtags = this.collectHashtags(title);
62
62
  node.hashtags = node.hashtags.concat(this.collectHashtags(body));
63
63
  // hashtags in the title look ugly, lets replace the gid:... structure with the tag #name
64
64
  node.title.translation = this.replaceHashtags(title, node.hashtags);
65
- node.body.translation = this.appendHtmlHashtags(this.truncate(this.removeHashtags(body)).replace(/\n/g, "<br>"), node.hashtags);
66
- node.link = `${this.controller.component.url}/${this.collection}/${node.id}`;
65
+ node.body.translation = this.appendHtmlHashtags(this.truncate(this.removeHashtags(body)), node.hashtags);
66
+ // console.log("decorateNode", node.title.translation, "BODY", body, "translation", node.body.translation, node.hashtags)
67
+ node.link = `${this.controller.component.url}/${node.id}`;
67
68
  }
68
69
 
69
70
  findTranslation(translations) {
@@ -83,7 +84,7 @@ export default class Fetcher {
83
84
  collectHashtags(text) {
84
85
  let tags = [];
85
86
  if (text) {
86
- const gids = text.match(/gid:\/\/[^\s<&]+/g)
87
+ const gids = text.match(/gid:\/\/[^\s<&,;]+/g)
87
88
  if (gids) {
88
89
  tags = gids.filter((gid) => gid.indexOf("/Decidim::Hashtag/") !== -1).map((gid) => {
89
90
  const parts = gid.split("/");
@@ -117,18 +118,39 @@ export default class Fetcher {
117
118
  }
118
119
 
119
120
  removeHashtags(text) {
120
- return text.replace(/gid:\/\/[^\s<&]+/g, "");
121
+ return text.replace(/gid:\/\/[^\s<&,;]+/g, "");
121
122
  }
122
123
 
123
124
  appendHtmlHashtags(txt, tags) {
124
- let text = txt;
125
- tags.forEach((tag) => {
126
- text += ` ${tag.html}`;
127
- });
128
- return text;
125
+ let string = tags.reduce((accumulator, tag) => (accumulator
126
+ ? `${accumulator} ${tag.html}`
127
+ : tag.html), "");
128
+ if (string) {
129
+ return `${txt}<p>${string}</p>`;
130
+ }
131
+ return txt;
132
+
129
133
  }
130
134
 
131
135
  truncate(html) {
132
136
  return $.truncate(html, this.config);
133
137
  }
138
+
139
+ formatDateRange(startDate, endDate) {
140
+ // Check if either startDate or endDate is blank
141
+ if (!startDate || !endDate) {
142
+ return "";
143
+ }
144
+
145
+ // Convert startDate and endDate to JavaScript Date objects
146
+ const start = new Date(startDate);
147
+ const end = new Date(endDate);
148
+
149
+ const date = Intl.DateTimeFormat(window.DecidimAwesome.currentLocale, { // eslint-disable-line new-cap
150
+ year: "numeric",
151
+ month: "short",
152
+ day: "numeric"
153
+ });
154
+ return date.formatRange(start, end);
155
+ }
134
156
  }
@@ -29,23 +29,13 @@ export default class MeetingsFetcher extends Fetcher {
29
29
  }
30
30
  }
31
31
  startTime
32
- location {
33
- translations {
34
- text
35
- locale
36
- }
37
- }
32
+ endTime
38
33
  address
39
- locationHints {
40
- translations {
41
- text
42
- locale
43
- }
44
- }
45
34
  coordinates {
46
35
  latitude
47
36
  longitude
48
37
  }
38
+ typeOfMeeting
49
39
  category {
50
40
  id
51
41
  }
@@ -56,4 +46,11 @@ export default class MeetingsFetcher extends Fetcher {
56
46
  }
57
47
  }`;
58
48
  }
49
+
50
+ decorateNode(node) {
51
+ super.decorateNode(node);
52
+ node.icon = window.AwesomeMapMeetingTypes[node.typeOfMeeting];
53
+ node.meetingType = window.AwesomeMapMeetingTexts[node.typeOfMeeting];
54
+ node.dateRange = this.formatDateRange(node.startTime, node.endTime);
55
+ }
59
56
  }
@@ -23,12 +23,18 @@ export default class ProposalsFetcher extends Fetcher {
23
23
  locale
24
24
  }
25
25
  }
26
+ author {
27
+ id
28
+ name
29
+ }
26
30
  body {
27
31
  translations {
28
32
  text
29
33
  locale
30
34
  }
31
35
  }
36
+ totalCommentsCount
37
+ endorsementsCount
32
38
  address
33
39
  coordinates {
34
40
  latitude
@@ -49,4 +55,26 @@ export default class ProposalsFetcher extends Fetcher {
49
55
  }
50
56
  }`;
51
57
  }
58
+
59
+ decorateNode(node) {
60
+ super.decorateNode(node);
61
+ node.authorName = node.author && node.author.name || window.DecidimAwesome.texts.officialAuthor;
62
+ node.humanState = window.AwesomeMapProposalTexts[node.state];
63
+ switch (node.state) {
64
+ case "accepted":
65
+ node.stateClass = "success";
66
+ break;
67
+ case "rejected":
68
+ case "withdrawn":
69
+ node.stateClass = "alert";
70
+ break;
71
+ case "evaluating":
72
+ node.stateClass = "warning";
73
+ break;
74
+ default:
75
+ node.stateClass = "muted";
76
+ }
77
+
78
+ node.isAmendment = () => (Boolean(this.controller.amendments[node.id]));
79
+ }
52
80
  }
@@ -1,11 +1,10 @@
1
1
  import * as L from "leaflet";
2
2
  // comes with Decidim
3
- import "src/decidim/map/icon.js"
4
3
  import "src/decidim/vendor/leaflet-tilelayer-here"
5
4
  // Comes with Decidim
6
- import "leaflet.markercluster";
5
+ import "leaflet.markercluster";
7
6
  // included in this package.json
8
- import "leaflet.featuregroup.subgroup"
7
+ import "leaflet.featuregroup.subgroup"
9
8
  import "src/vendor/jquery.truncate"
10
9
  import "jsrender"
11
10
 
@@ -64,7 +63,7 @@ export default class AwesomeMap {
64
63
  this.autoResize();
65
64
 
66
65
  if (this.loading.length === 0) {
67
- this.controls.$loading.hide();
66
+ this.controls.loading.style.display = "none";
68
67
  // call trigger as all loads are finished
69
68
  this.onFinished();
70
69
  }
@@ -14,8 +14,8 @@ export default class Controller {
14
14
  }
15
15
 
16
16
  getLabel() {
17
- let text = this.awesomeMap.config.menu.mergeComponents || this.component.name;
18
- if (!text) {
17
+ let text = this.component.name;
18
+ if (!text || this.awesomeMap.config.menu.mergeComponents) {
19
19
  text = window.DecidimAwesome.texts[this.component.type];
20
20
  }
21
21
  return `<span class="awesome_map-component" id="awesome_map-component_${this.component.id}" title="0" data-layer="${this.component.type}">${text}</span>`
@@ -96,6 +96,7 @@ export default class Controller {
96
96
 
97
97
  }).setLatLng(marker.getLatLng()).setContent(dom);
98
98
  this.awesomeMap.map.addLayer(pop);
99
+ // console.log("marker click", node, "pop", pop, "marker", marker, "dom", dom, "templateId", this.templateId)
99
100
  });
100
101
  node.marker = marker;
101
102
  node.component = this.component;
@@ -110,7 +111,7 @@ export default class Controller {
110
111
  this.awesomeMap.layers[cat.id].group.addLayer(marker);
111
112
  this.awesomeMap.controls.showCategory(cat);
112
113
  } catch (evt) {
113
- console.error("Failed category marker assignation", marker, evt.message);
114
+ console.error("Failed category marker assignation. category:", category, "marker:", marker, evt.message);
114
115
  }
115
116
  }
116
117
  }
@@ -121,7 +122,7 @@ export default class Controller {
121
122
  try {
122
123
  this.awesomeMap.controls.addHashtagsControls(hashtags, marker);
123
124
  } catch (evt) {
124
- console.error("Failed hashtags marker assignation", marker, evt.message);
125
+ console.error("Failed hashtags marker assignation. hashtags:", hashtags, "marker:", marker, evt.message);
125
126
  }
126
127
  }
127
128
  }
@@ -132,14 +133,13 @@ export default class Controller {
132
133
  this.onFinished();
133
134
  }
134
135
 
135
- createIcon(Builder, color) {
136
- return new Builder({
137
- color: "#000000",
138
- fillColor: color,
139
- circleFillColor: color,
140
- weight: 1,
141
- stroke: color,
142
- fillOpacity: 0.9
136
+ createIcon(color) {
137
+ const size = 36;
138
+ return L.divIcon({
139
+ html: `
140
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="${size}px" height="${size}px" class="text-secondary" style="color: ${color}"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M18.364 17.364L12 23.728l-6.364-6.364a9 9 0 1 1 12.728 0zM12 15a4 4 0 1 0 0-8 4 4 0 0 0 0 8zm0-2a2 2 0 1 1 0-4 2 2 0 0 1 0 4z"/></svg>`,
141
+ iconAnchor: [0.5 * size, size],
142
+ popupAnchor: [0, -0.5 * size]
143
143
  });
144
144
  }
145
145
  }
@@ -2,12 +2,6 @@ import * as L from "leaflet";
2
2
  import Controller from "src/decidim/decidim_awesome/awesome_map/controllers/controller";
3
3
  import MeetingsFetcher from "src/decidim/decidim_awesome/awesome_map/api/meetings_fetcher";
4
4
 
5
- const MeetingIcon = L.DivIcon.SVGIcon.DecidimIcon.extend({
6
- _createPathDescription: function() {
7
- return "M 15.991543,4 C 7.3956015,4 2.9250351,10.5 3.000951,16.999999 3.1063486,26.460968 12.747693,30.000004 15.991543,43 19.242091,30.000004 29,26.255134 29,16.999999 29,10.5 23.951131,4 15.996007,4 m -0.153508,2.6000001 a 2.1720294,2.1076698 0 0 1 2.330514,2.1124998 2.177008,2.1125006 0 0 1 -4.354016,0 2.1720294,2.1076698 0 0 1 2.023502,-2.1124998 m -2.651707,4.8056679 h 5.610202 l 3.935584,7.569899 -1.926038,0.934266 -2.009546,-3.859265 v 14.557403 h -2.484243 v -9.126003 h -0.642162 v 9.126003 H 13.190347 V 16.050568 l -2.009545,3.859265 -1.926036,-0.934266 3.935581,-7.569899";
8
- }
9
- });
10
-
11
5
  export default class MeetingsController extends Controller {
12
6
  constructor(awesomeMap, component) {
13
7
  super(awesomeMap, component)
@@ -19,7 +13,7 @@ export default class MeetingsController extends Controller {
19
13
  // for each meeting, create a marker with an associated popup
20
14
  this.fetcher.onNode = (meeting) => {
21
15
  let marker = new L.Marker([meeting.coordinates.latitude, meeting.coordinates.longitude], {
22
- icon: this.createIcon(MeetingIcon, this.awesomeMap.getCategory(meeting.category).color),
16
+ icon: this.createIcon(this.awesomeMap.getCategory(meeting.category).color),
23
17
  title: meeting.title.translation
24
18
  });
25
19
  // console.log("new meeting", meeting, marker)
@@ -28,4 +22,14 @@ export default class MeetingsController extends Controller {
28
22
 
29
23
  this.fetcher.fetch();
30
24
  }
25
+
26
+ createIcon(color) {
27
+ const size = 36;
28
+ return L.divIcon({
29
+ html: `
30
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36" width="${size}px" height="${size}px" class="text-primary" style="color: ${color}"><path fill="none" d="M0 0h24v24H0z"/><path fill="currentColor" d="M 15.991543,4 C 7.3956015,4 2.9250351,10.5 3.000951,16.999999 3.1063486,26.460968 12.747693,30.000004 15.991543,43 19.242091,30.000004 29,26.255134 29,16.999999 29,10.5 23.951131,4 15.996007,4 m -0.153508,2.6000001 a 2.1720294,2.1076698 0 0 1 2.330514,2.1124998 2.177008,2.1125006 0 0 1 -4.354016,0 2.1720294,2.1076698 0 0 1 2.023502,-2.1124998 m -2.651707,4.8056679 h 5.610202 l 3.935584,7.569899 -1.926038,0.934266 -2.009546,-3.859265 v 14.557403 h -2.484243 v -9.126003 h -0.642162 v 9.126003 H 13.190347 V 16.050568 l -2.009545,3.859265 -1.926036,-0.934266 3.935581,-7.569899"/></svg>`,
31
+ iconAnchor: [0.5 * size, size],
32
+ popupAnchor: [0, -0.5 * size]
33
+ });
34
+ }
31
35
  }
@@ -2,14 +2,6 @@ import * as L from "leaflet";
2
2
  import Controller from "src/decidim/decidim_awesome/awesome_map/controllers/controller";
3
3
  import ProposalsFetcher from "src/decidim/decidim_awesome/awesome_map/api/proposals_fetcher";
4
4
 
5
- const ProposalIcon = L.DivIcon.SVGIcon.DecidimIcon.extend({
6
- options: {
7
- fillColor: "#ef604d",
8
- fillOpacity: 0.8,
9
- strokeWidth: 1,
10
- strokeOpcacity: 1
11
- }
12
- });
13
5
  export default class ProposalsController extends Controller {
14
6
  constructor(awesomeMap, component) {
15
7
  super(awesomeMap, component)
@@ -36,12 +28,13 @@ export default class ProposalsController extends Controller {
36
28
  // for each proposal, create a marker with an associated popup
37
29
  this.fetcher.onNode = (proposal) => {
38
30
  let marker = new L.Marker([proposal.coordinates.latitude, proposal.coordinates.longitude], {
39
- icon: this.createIcon(ProposalIcon, this.awesomeMap.getCategory(proposal.category).color),
31
+ icon: this.createIcon(this.awesomeMap.getCategory(proposal.category).color),
40
32
  title: proposal.title.translation
41
33
  });
42
34
 
43
35
  // Check if it has amendments, add it to a list
44
36
  // also assign parent's proposal categories to it
37
+ // console.log("onNode proposal", proposal, "amendment:", proposal.amendments)
45
38
  if (proposal.amendments && proposal.amendments.length) {
46
39
  proposal.amendments.forEach((amendment) => {
47
40
  this.amendments[amendment.emendation.id] = proposal;
@@ -67,16 +60,16 @@ export default class ProposalsController extends Controller {
67
60
  // console.log("marker", marker, "parent proposal", parent)
68
61
  // add marker to amendments layers and remove it from proposals
69
62
  if (marker) {
70
- try {
71
- marker.marker.removeFrom(this.controls.group)
72
- } catch (evt) {
63
+ try {
64
+ marker.marker.removeFrom(this.controls.group)
65
+ } catch (evt) {
73
66
  console.error("error removeFrom marker", marker, "layer", this.controls.group, evt);
74
67
  }
75
68
  if (this.awesomeMap.config.menu.amendments) {
76
69
  marker.marker.addTo(this.awesomeMap.layers.amendments.group);
77
70
  // mimic parent category (amendments doesn't have categories)
78
71
  if (parent.category) {
79
- marker.marker.setIcon(this.createIcon(ProposalIcon, this.awesomeMap.getCategory(parent.category).color));
72
+ marker.marker.setIcon(this.createIcon("text-secondary"));
80
73
  this.addMarkerCategory(marker.marker, parent.category)
81
74
  }
82
75
  }