decidim-decidim_awesome 0.10.2 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -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/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -1
  42. data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +5 -3
  43. data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +1 -1
  44. data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +5 -4
  45. data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +30 -0
  46. data/app/packs/src/decidim/decidim_awesome/awesome_application.js +1 -0
  47. data/app/packs/src/decidim/decidim_awesome/editors/editor.js +1 -6
  48. data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +18 -9
  49. data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +35 -26
  50. data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +31 -15
  51. data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +12 -7
  52. data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +69 -25
  53. data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +34 -27
  54. data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +2 -2
  55. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +3 -3
  56. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +28 -0
  57. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +3 -2
  58. data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +15 -15
  59. data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +3 -3
  60. data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +3 -3
  61. data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +187 -0
  62. data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +47 -0
  63. data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +7 -7
  64. data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +14 -3
  65. data/app/presenters/concerns/decidim/decidim_awesome/proposals/proposal_presenter_override.rb +20 -0
  66. data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +30 -0
  67. data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +70 -0
  68. data/app/queries/decidim/decidim_awesome/private_data_finder.rb +19 -0
  69. data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +1 -0
  70. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +72 -0
  71. data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +38 -0
  72. data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +42 -0
  73. data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +59 -0
  74. data/app/types/concerns/decidim/decidim_awesome/{proposal_type_override.rb → add_proposal_type_vote_weights.rb} +3 -1
  75. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +52 -48
  76. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -2
  77. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +16 -8
  78. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +1 -1
  79. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +12 -16
  80. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +35 -15
  81. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_private_custom_fields.html.erb +1 -0
  82. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +22 -22
  83. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +1 -1
  84. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +1 -1
  85. data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +14 -13
  86. data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +44 -0
  87. data/app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb +44 -0
  88. data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +28 -29
  89. data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +8 -5
  90. data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +20 -0
  91. data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +16 -0
  92. data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +10 -2
  93. data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +21 -0
  94. data/app/views/layouts/decidim/decidim_awesome/admin/application.html.erb +1 -73
  95. data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +19 -0
  96. data/config/i18n-tasks.yml +22 -3
  97. data/config/locales/ca.yml +97 -9
  98. data/config/locales/cs.yml +109 -6
  99. data/config/locales/de.yml +92 -6
  100. data/config/locales/en.yml +102 -8
  101. data/config/locales/es.yml +96 -8
  102. data/config/locales/eu.yml +15 -1
  103. data/config/locales/fr.yml +94 -6
  104. data/config/locales/hu.yml +53 -4
  105. data/config/locales/it.yml +16 -6
  106. data/config/locales/ja.yml +94 -6
  107. data/config/locales/lt.yml +0 -2
  108. data/config/locales/nl.yml +9 -4
  109. data/config/locales/pt-BR.yml +16 -7
  110. data/config/locales/ro-RO.yml +11 -2
  111. data/config/locales/sv.yml +17 -6
  112. data/db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb +29 -0
  113. data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +20 -0
  114. data/lib/decidim/decidim_awesome/admin_engine.rb +22 -6
  115. data/lib/decidim/decidim_awesome/api/types/localized_custom_fields_type.rb +22 -0
  116. data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +52 -0
  117. data/lib/decidim/decidim_awesome/awesome.rb +45 -8
  118. data/lib/decidim/decidim_awesome/awesome_helpers.rb +5 -1
  119. data/lib/decidim/decidim_awesome/checksums.yml +23 -0
  120. data/lib/decidim/decidim_awesome/custom_fields.rb +8 -0
  121. data/lib/decidim/decidim_awesome/engine.rb +143 -52
  122. data/lib/decidim/decidim_awesome/lock.rb +47 -0
  123. data/lib/decidim/decidim_awesome/menu.rb +146 -0
  124. data/lib/decidim/decidim_awesome/test/initializer.rb +4 -1
  125. data/lib/decidim/decidim_awesome/test/shared_examples/{box_label_editor.rb → box_label_editor_examples.rb} +1 -1
  126. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +20 -2
  127. data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +155 -0
  128. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +24 -0
  129. data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +2 -2
  130. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +3 -5
  131. data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +78 -12
  132. data/lib/decidim/decidim_awesome/version.rb +1 -1
  133. data/package.json +2 -2
  134. metadata +52 -13
  135. data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +0 -78
  136. /data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_item_presenter_override.rb +0 -0
  137. /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