decidim-decidim_awesome 0.10.1 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -1
  3. data/README.md +134 -15
  4. data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +4 -24
  5. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +9 -5
  6. data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +1 -1
  7. data/app/commands/concerns/decidim/decidim_awesome/proposals/admin/update_proposal_override.rb +31 -0
  8. data/app/commands/concerns/decidim/decidim_awesome/proposals/create_collaborative_draft_override.rb +27 -0
  9. data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +27 -0
  10. data/app/commands/concerns/decidim/decidim_awesome/proposals/update_collaborative_draft_override.rb +27 -0
  11. data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +26 -0
  12. data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +4 -3
  13. data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +6 -3
  14. data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +43 -0
  15. data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +3 -2
  16. data/app/controllers/concerns/decidim/decidim_awesome/limit_pending_amendments.rb +35 -0
  17. data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +9 -22
  18. data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
  19. data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +2 -0
  20. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +7 -3
  21. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +8 -5
  22. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +3 -1
  23. data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +0 -2
  24. data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +76 -0
  25. data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +0 -2
  26. data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +12 -4
  27. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +8 -1
  28. data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +21 -0
  29. data/app/forms/{decidim → concerns/decidim}/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +1 -0
  30. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +35 -9
  31. data/app/helpers/{decidim → concerns/decidim}/decidim_awesome/amendments_helper_override.rb +17 -7
  32. data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +126 -0
  33. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +5 -26
  34. data/app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb +22 -0
  35. data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +38 -9
  36. data/app/models/decidim/decidim_awesome/paper_trail_version.rb +5 -1
  37. data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +35 -1
  38. data/app/overrides/decidim/proposals/admin/proposals/show/add_private_body.html.erb.deface +7 -0
  39. data/app/overrides/decidim/proposals/admin/proposals/show/replace_body.html.erb.deface +5 -0
  40. data/app/overrides/decidim/proposals/proposals/show/limit_amendments_modal.html.erb.deface +5 -0
  41. data/app/overrides/layouts/decidim/admin/_header/replace_scripts.html.erb.deface +3 -0
  42. data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -1
  43. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +5 -3
  44. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +1 -1
  45. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +5 -4
  46. data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +30 -0
  47. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +1 -0
  48. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +1 -6
  49. data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +18 -9
  50. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +35 -26
  51. data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +31 -15
  52. data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +12 -7
  53. data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +69 -25
  54. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +34 -27
  55. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +2 -2
  56. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +3 -3
  57. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +28 -0
  58. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +3 -2
  59. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +15 -15
  60. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +3 -3
  61. data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +3 -3
  62. data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +187 -0
  63. data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +47 -0
  64. data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +7 -7
  65. data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +14 -3
  66. data/app/presenters/concerns/decidim/decidim_awesome/proposals/proposal_presenter_override.rb +20 -0
  67. data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +30 -0
  68. data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +70 -0
  69. data/app/queries/decidim/decidim_awesome/private_data_finder.rb +19 -0
  70. data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +1 -0
  71. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +72 -0
  72. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +38 -0
  73. data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +42 -0
  74. data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +59 -0
  75. data/app/types/concerns/decidim/decidim_awesome/{proposal_type_override.rb → add_proposal_type_vote_weights.rb} +3 -1
  76. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +52 -48
  77. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -2
  78. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +16 -8
  79. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +1 -1
  80. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +12 -16
  81. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +35 -15
  82. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_private_custom_fields.html.erb +1 -0
  83. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +22 -22
  84. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +1 -1
  85. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +1 -1
  86. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +14 -13
  87. data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +44 -0
  88. data/app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb +44 -0
  89. data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +28 -29
  90. data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +8 -5
  91. data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +20 -0
  92. data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +16 -0
  93. data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +10 -2
  94. data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +21 -0
  95. data/app/views/layouts/decidim/decidim_awesome/admin/application.html.erb +1 -73
  96. data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +19 -0
  97. data/config/i18n-tasks.yml +22 -3
  98. data/config/locales/ca.yml +97 -9
  99. data/config/locales/cs.yml +109 -6
  100. data/config/locales/de.yml +92 -6
  101. data/config/locales/en.yml +102 -8
  102. data/config/locales/es.yml +96 -8
  103. data/config/locales/eu.yml +15 -1
  104. data/config/locales/fr.yml +94 -6
  105. data/config/locales/hu.yml +53 -4
  106. data/config/locales/it.yml +16 -6
  107. data/config/locales/ja.yml +94 -6
  108. data/config/locales/lt.yml +0 -2
  109. data/config/locales/nl.yml +9 -4
  110. data/config/locales/pt-BR.yml +16 -7
  111. data/config/locales/ro-RO.yml +11 -2
  112. data/config/locales/sv.yml +17 -6
  113. data/db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb +29 -0
  114. data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +20 -0
  115. data/lib/decidim/decidim_awesome/admin_engine.rb +22 -6
  116. data/lib/decidim/decidim_awesome/api/types/localized_custom_fields_type.rb +22 -0
  117. data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +52 -0
  118. data/lib/decidim/decidim_awesome/awesome.rb +45 -8
  119. data/lib/decidim/decidim_awesome/awesome_helpers.rb +5 -1
  120. data/lib/decidim/decidim_awesome/checksums.yml +23 -0
  121. data/lib/decidim/decidim_awesome/custom_fields.rb +8 -0
  122. data/lib/decidim/decidim_awesome/engine.rb +143 -52
  123. data/lib/decidim/decidim_awesome/lock.rb +47 -0
  124. data/lib/decidim/decidim_awesome/menu.rb +146 -0
  125. data/lib/decidim/decidim_awesome/test/initializer.rb +4 -1
  126. data/lib/decidim/decidim_awesome/test/shared_examples/{box_label_editor.rb → box_label_editor_examples.rb} +1 -1
  127. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +20 -2
  128. data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +155 -0
  129. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +24 -0
  130. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +2 -2
  131. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +3 -5
  132. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +78 -12
  133. data/lib/decidim/decidim_awesome/version.rb +1 -1
  134. data/package.json +3 -3
  135. metadata +52 -14
  136. data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +0 -78
  137. data/app/overrides/layouts/decidim/admin/_application/add_intergram.html.erb.deface +0 -5
  138. /data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_item_presenter_override.rb +0 -0
  139. /data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_presenter_override.rb +0 -0
@@ -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,5 +0,0 @@
1
- <!-- insert_bottom "body" -->
2
-
3
- <% if awesome_config[:intergram_for_admins] %>
4
- <%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_admins_settings] } %>
5
- <% end %>