decidim-core 0.31.5 → 0.31.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/amendable/amend_button_card/show.erb +2 -2
  3. data/app/cells/decidim/author_cell.rb +0 -4
  4. data/app/cells/decidim/content_blocks/cta_settings_form/show.erb +1 -1
  5. data/app/cells/decidim/content_blocks/hero_settings_form/show.erb +2 -2
  6. data/app/cells/decidim/content_blocks/highlighted_content_banner_cell.rb +1 -1
  7. data/app/cells/decidim/content_blocks/highlighted_content_banner_settings_form/show.erb +1 -1
  8. data/app/cells/decidim/content_blocks/highlighted_participatory_spaces_cell.rb +1 -1
  9. data/app/cells/decidim/content_blocks/participatory_space_hero_settings_form/show.erb +1 -1
  10. data/app/cells/decidim/content_blocks/static_page/section_settings_form/show.erb +3 -1
  11. data/app/cells/decidim/content_blocks/static_page/summary_settings_form/show.erb +3 -1
  12. data/app/cells/decidim/content_blocks/static_page/two_pane_section_settings_form/show.erb +4 -2
  13. data/app/cells/decidim/resource_types_filter/show.erb +2 -2
  14. data/app/commands/decidim/destroy_account.rb +12 -1
  15. data/app/commands/decidim/multiple_attachments_methods.rb +28 -27
  16. data/app/controllers/concerns/decidim/devise_controllers.rb +10 -0
  17. data/app/jobs/decidim/process_inactive_participant_job.rb +0 -7
  18. data/app/mailers/decidim/delete_user_mailer.rb +14 -0
  19. data/app/mailers/decidim/participants_account_mailer.rb +0 -16
  20. data/app/models/decidim/moderation.rb +1 -1
  21. data/app/models/decidim/participatory_space_private_user.rb +1 -1
  22. data/app/models/decidim/user_base_entity.rb +17 -2
  23. data/app/models/decidim/user_moderation.rb +1 -1
  24. data/app/packs/src/decidim/controllers/form_validator/form_validator.js +6 -6
  25. data/app/packs/src/decidim/controllers/form_validator/form_validator.test.js +23 -1
  26. data/app/packs/src/decidim/controllers/mention/controller.js +296 -140
  27. data/app/packs/src/decidim/controllers/mention/input_mentions.test.js +120 -457
  28. data/app/packs/src/decidim/controllers/multiple_mentions/controller.js +68 -32
  29. data/app/packs/src/decidim/controllers/multiple_mentions/input_multiple_mentions.test.js +30 -23
  30. data/app/packs/src/decidim/direct_uploads/upload_field.js +4 -4
  31. data/app/packs/src/decidim/direct_uploads/upload_modal.js +11 -7
  32. data/app/packs/src/decidim/geocoding/reverse_geocoding.js +15 -5
  33. data/app/packs/src/decidim/geocoding/reverse_geocoding.test.js +197 -0
  34. data/app/packs/src/decidim/index.js +4 -3
  35. data/app/packs/src/decidim/sw/sw.js +1 -1
  36. data/app/packs/src/decidim/utilities/text.js +6 -6
  37. data/app/packs/stylesheets/decidim/_conversations.scss +14 -0
  38. data/app/packs/stylesheets/decidim/_editor_suggestions.scss +49 -0
  39. data/app/packs/stylesheets/decidim/_floating_help.scss +1 -1
  40. data/app/packs/stylesheets/decidim/_tom_select.scss +23 -0
  41. data/app/packs/stylesheets/decidim/application.scss +2 -0
  42. data/app/packs/stylesheets/decidim/editor.scss +2 -33
  43. data/app/packs/stylesheets/decidim/geocoding_addons.scss +10 -2
  44. data/app/presenters/decidim/menu_item_presenter.rb +9 -3
  45. data/app/presenters/decidim/stats_presenter.rb +1 -1
  46. data/app/uploaders/decidim/image_uploader.rb +1 -1
  47. data/app/views/decidim/delete_user_mailer/delete.html.erb +6 -0
  48. data/app/views/decidim/gamification/badges/index.html.erb +1 -1
  49. data/app/views/decidim/homepage/show.html.erb +1 -1
  50. data/app/views/decidim/last_activities/index.html.erb +1 -1
  51. data/app/views/decidim/messaging/conversations/_error_modal.html.erb +11 -19
  52. data/app/views/decidim/messaging/conversations/error.js.erb +12 -7
  53. data/app/views/decidim/newsletters/unsubscribe.html.erb +1 -1
  54. data/app/views/decidim/offline/show.html.erb +1 -1
  55. data/app/views/decidim/pages/index.html.erb +1 -1
  56. data/app/views/decidim/profiles/show.html.erb +1 -1
  57. data/app/views/decidim/shared/_resource_actions.html.erb +4 -4
  58. data/app/views/decidim/user_activities/index.html.erb +1 -1
  59. data/app/views/layouts/decidim/_wrapper.html.erb +2 -2
  60. data/app/views/layouts/decidim/header/_menu_breadcrumb_mobile_tablet.html.erb +1 -1
  61. data/app/views/layouts/decidim/shared/_layout_center.html.erb +1 -1
  62. data/app/views/layouts/decidim/shared/_layout_item.html.erb +1 -1
  63. data/app/views/layouts/decidim/shared/_layout_two_col.html.erb +1 -1
  64. data/config/locales/ar.yml +0 -5
  65. data/config/locales/bg.yml +0 -6
  66. data/config/locales/ca-IT.yml +9 -10
  67. data/config/locales/ca.yml +9 -10
  68. data/config/locales/cs.yml +2 -13
  69. data/config/locales/de.yml +5 -17
  70. data/config/locales/el.yml +0 -4
  71. data/config/locales/en.yml +8 -9
  72. data/config/locales/es-MX.yml +8 -9
  73. data/config/locales/es-PY.yml +8 -9
  74. data/config/locales/es.yml +8 -9
  75. data/config/locales/eu.yml +48 -49
  76. data/config/locales/fi-plain.yml +9 -9
  77. data/config/locales/fi.yml +9 -9
  78. data/config/locales/fr-CA.yml +9 -9
  79. data/config/locales/fr.yml +9 -9
  80. data/config/locales/gl.yml +0 -3
  81. data/config/locales/hu.yml +0 -5
  82. data/config/locales/id-ID.yml +0 -3
  83. data/config/locales/it.yml +1 -3
  84. data/config/locales/ja.yml +24 -21
  85. data/config/locales/lb.yml +0 -5
  86. data/config/locales/lt.yml +0 -5
  87. data/config/locales/lv.yml +0 -3
  88. data/config/locales/nl.yml +0 -5
  89. data/config/locales/no.yml +0 -5
  90. data/config/locales/pl.yml +2 -8
  91. data/config/locales/pt-BR.yml +2 -15
  92. data/config/locales/pt.yml +0 -5
  93. data/config/locales/ro-RO.yml +1 -14
  94. data/config/locales/sk.yml +1 -14
  95. data/config/locales/sv.yml +2 -11
  96. data/config/locales/tr-TR.yml +0 -6
  97. data/config/locales/zh-CN.yml +0 -5
  98. data/config/locales/zh-TW.yml +0 -5
  99. data/lib/decidim/api/functions/user_entity_list.rb +2 -0
  100. data/lib/decidim/attachment_attributes.rb +58 -9
  101. data/lib/decidim/command.rb +1 -1
  102. data/lib/decidim/content_renderers/base_renderer.rb +112 -0
  103. data/lib/decidim/content_renderers/blob_renderer.rb +4 -7
  104. data/lib/decidim/content_renderers/mention_resource_renderer.rb +10 -6
  105. data/lib/decidim/content_renderers/resource_renderer.rb +16 -7
  106. data/lib/decidim/content_renderers/user_renderer.rb +11 -9
  107. data/lib/decidim/core/content_blocks/registry_manager.rb +4 -4
  108. data/lib/decidim/core/engine.rb +8 -0
  109. data/lib/decidim/core/test/factories.rb +3 -0
  110. data/lib/decidim/core/test/shared_examples/admin_resource_gallery_examples.rb +10 -10
  111. data/lib/decidim/core/test/shared_examples/comments_examples.rb +6 -6
  112. data/lib/decidim/core/version.rb +1 -1
  113. data/lib/decidim/map/autocomplete.rb +4 -3
  114. data/lib/decidim/searchable.rb +5 -0
  115. data/lib/decidim/view_model.rb +1 -1
  116. data/lib/tasks/decidim_mailers_tasks.rake +31 -9
  117. metadata +11 -10
  118. data/app/commands/decidim/gallery_methods.rb +0 -107
  119. data/app/packs/src/decidim/vendor/tribute.js +0 -1890
  120. data/app/packs/stylesheets/decidim/_tribute.scss +0 -36
  121. data/app/views/decidim/participants_account_mailer/removal_notification.html.erb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62bd053e6fd5eba91bd7b08d3c502accbe3a13d9045cab68091035b0c95b2964
4
- data.tar.gz: 1376e77830f2ec0e1f96c1503caa458f4c834d956f3e189e5d1176ad3403f430
3
+ metadata.gz: 1625dd1f860a4431caaae18f96ec93ee1751d8d135bde4da819eddbf4976e0d3
4
+ data.tar.gz: ff6293ab292f7c3a18d663a524a099754d63c59dbc4d15e81ca7664f6fc74bff
5
5
  SHA512:
6
- metadata.gz: 4beb29f27737221e77294185ea9b1d1fde88cb3296cd21691cc91ad2477117669b20b3f8369a80d7e9443594d516701462134ef77936433b4d372571ddaf414a
7
- data.tar.gz: 51aafb46408f1a5cb3067e73b9559661b10c8573a46d5fb3036b576e94a998d9f98952da18cb0330d67d1379c7d7e568b4e9f9c9c22a2c9e30a4a998e5484991
6
+ metadata.gz: 4403452ffb2df3d9ef2c5c1dd911321cffcfcfaa89ab1d4bf1b32542acc6a2a3e15ad6410a23538bd98cb33ec57496d58de2015022f3a1ce52f77a901d776d99
7
+ data.tar.gz: c385ae7331b4c38b6a2b3a0679340e4739ee9da30535daea878690279776b68e1b5652951bc2151b06959935343a56dd0cbd0d7e066ccc97329dcf4712694862
@@ -1,5 +1,5 @@
1
- <li role="menuitem" class="dropdown__item">
2
- <%= action_authorized_link_to :amend, new_amend_path, resource: model, data: { "redirect_url" => new_amend_path }, id: "amend-button", class: "dropdown__button" do %>
1
+ <li role="presentation" class="dropdown__item">
2
+ <%= action_authorized_link_to :amend, new_amend_path, resource: model, data: { "redirect_url" => new_amend_path }, id: "amend-button", class: "dropdown__button", role: "menuitem" do %>
3
3
  <span><%= t("button", scope: "decidim.amendments.amendable", model_name: nil) %></span>
4
4
  <%= icon "pencil-line" %>
5
5
  <% end %>
@@ -31,10 +31,6 @@ module Decidim
31
31
  render unless current_user == model
32
32
  end
33
33
 
34
- def perform_caching?
35
- true
36
- end
37
-
38
34
  def raw_model
39
35
  model.try(:__getobj__) || model
40
36
  end
@@ -4,6 +4,6 @@
4
4
  <%= settings_fields.translated :text_field, :description, label: t("decidim.content_blocks.cta_settings_form.description") %>
5
5
  <% end %>
6
6
 
7
- <% form.fields_for :images, form.object.images do |images_fields| %>
7
+ <% form.fields_for :images, content_block.images_container do |images_fields| %>
8
8
  <%= images_fields.upload :background_image, label: t("decidim.content_blocks.cta_settings_form.background_image") %>
9
9
  <% end %>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="row column" data-controller="slug">
7
7
  <%= settings_fields.translated :text_field, :cta_button_path, label: t(".cta_button_path") %>
8
- <p class="help-text"><%= t(".cta_button_path_help", url: decidim_form_slug_url("", translated_attribute(form.object.settings.cta_button_path))) %></p>
8
+ <p class="help-text"><%= t(".cta_button_path_help", url: decidim_form_slug_url("", translated_attribute(form.object.settings["cta_button_path"]))) %></p>
9
9
  </div>
10
10
 
11
11
  <div class="row column">
@@ -14,7 +14,7 @@
14
14
  </div>
15
15
  <% end %>
16
16
 
17
- <% form.fields_for :images, form.object.images do |images_fields| %>
17
+ <% form.fields_for :images, content_block.images_container do |images_fields| %>
18
18
  <div class="row column">
19
19
  <%= images_fields.upload :background_image, label: t(".background_image"), button_class: "button button__sm button__transparent-secondary" %>
20
20
  </div>
@@ -32,7 +32,7 @@ module Decidim
32
32
  private
33
33
 
34
34
  def render?
35
- required_keys = [:title, :short_description, :action_button_title, :action_button_subtitle, :action_button_url]
35
+ required_keys = [:title, :action_button_title, :action_button_subtitle, :action_button_url]
36
36
  required_keys.all? { |key| model.settings.public_send(key).present? }
37
37
  end
38
38
  end
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
  <% end %>
22
22
 
23
- <% form.fields_for :images, form.object.images do |images_fields| %>
23
+ <% form.fields_for :images, content_block.images_container do |images_fields| %>
24
24
  <div class="row column">
25
25
  <%= images_fields.upload :background_image, label: t(".background_image"), button_class: "button button__sm button__transparent-secondary" %>
26
26
  </div>
@@ -28,7 +28,7 @@ module Decidim
28
28
  private
29
29
 
30
30
  def cache_hash
31
- [I18n.locale, highlighted_spaces.map(&:cache_key_with_version)].join(Decidim.cache_key_separator)
31
+ [I18n.locale, model.cache_key_with_version, highlighted_spaces.map(&:cache_key_with_version)].join(Decidim.cache_key_separator)
32
32
  end
33
33
 
34
34
  def section_class
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
  <% end %>
10
10
 
11
- <% form.fields_for :images, form.object.images do |images_fields| %>
11
+ <% form.fields_for :images, content_block.images_container do |images_fields| %>
12
12
  <div class="row column">
13
13
  <%= images_fields.upload :background_image, label: t("decidim.content_blocks.cta_settings_form.background_image"), button_class: "button button__sm button__transparent-secondary" %>
14
14
  </div>
@@ -1,3 +1,5 @@
1
1
  <% form.fields_for :settings, form.object.settings do |settings_fields| %>
2
- <%= settings_fields.translated :editor, :content, label: %>
2
+ <div class="row column">
3
+ <%= settings_fields.translated :editor, :content, label: %>
4
+ </div>
3
5
  <% end %>
@@ -1,3 +1,5 @@
1
1
  <% form.fields_for :settings, form.object.settings do |settings_fields| %>
2
- <%= settings_fields.translated :editor, :summary, label: %>
2
+ <div class="row column">
3
+ <%= settings_fields.translated :editor, :summary, label: %>
4
+ </div>
3
5
  <% end %>
@@ -1,4 +1,6 @@
1
1
  <% form.fields_for :settings, form.object.settings do |settings_fields| %>
2
- <%= settings_fields.translated :editor, :left_column, label: label_left_column %>
3
- <%= settings_fields.translated :editor, :right_column, label: label_right_column %>
2
+ <div class="row column">
3
+ <%= settings_fields.translated :editor, :left_column, label: label_left_column %>
4
+ <%= settings_fields.translated :editor, :right_column, label: label_right_column %>
5
+ </div>
4
6
  <% end %>
@@ -10,8 +10,8 @@
10
10
  </button>
11
11
  <ul id="dropdown-menu-resource">
12
12
  <% resource_types.each do |resource_type| %>
13
- <li role="menuitem">
14
- <%= link_to filter_url(resource_type[0]), class: "filter#{" is-active" if filter_param == resource_type[0]}" do %>
13
+ <li role="presentation">
14
+ <%= link_to filter_url(resource_type[0]), class: "filter#{" is-active" if filter_param == resource_type[0]}", role: "menuitem" do %>
15
15
  <span class="sr-only"><%= resource_type[1] %></span>
16
16
  <%= text_with_resource_icon(*resource_type) %>
17
17
  <% end %>
@@ -15,7 +15,7 @@ module Decidim
15
15
  def call
16
16
  return broadcast(:invalid) unless @form.valid?
17
17
 
18
- Decidim::User.transaction do
18
+ with_events(with_transaction: true) do
19
19
  destroy_user_account!
20
20
  destroy_user_identities
21
21
  destroy_follows
@@ -110,5 +110,16 @@ module Decidim
110
110
  space_manifest.invoke_on_destroy_account(current_user)
111
111
  end
112
112
  end
113
+
114
+ # We use memoization in this particular email, as we want to have the data available before the actual anonymization
115
+ def event_arguments
116
+ @event_arguments ||= {
117
+ user_id: current_user.id,
118
+ user_email: current_user.email,
119
+ user_name: current_user.name,
120
+ locale: current_user.locale,
121
+ organization: current_user.organization
122
+ }
123
+ end
113
124
  end
114
125
  end
@@ -5,16 +5,16 @@ module Decidim
5
5
  private
6
6
 
7
7
  def build_attachments
8
- @documents = []
9
- @form.add_documents.compact_blank.each do |attachment|
8
+ @attachments = []
9
+ @form.add_attachments.compact_blank.each do |attachment|
10
10
  if attachment.is_a?(Hash) && attachment.has_key?(:id)
11
11
  update_attachment_title_for(attachment)
12
12
  next
13
13
  end
14
14
 
15
- @documents << Attachment.new(
15
+ @attachments << Attachment.new(
16
16
  title: title_for(attachment),
17
- attached_to: @attached_to || documents_attached_to,
17
+ attached_to: @attached_to || attachments_attached_to,
18
18
  file: signed_id_for(attachment),
19
19
  content_type: content_type_for(attachment)
20
20
  )
@@ -26,11 +26,11 @@ module Decidim
26
26
  end
27
27
 
28
28
  def attachments_invalid?
29
- @documents.each do |document|
30
- next if document.valid? || !document.errors.has_key?(:file)
29
+ @attachments.each do |attachment|
30
+ next if attachment.valid? || !attachment.errors.has_key?(:file)
31
31
 
32
- document.errors[:file].each do |error|
33
- @form.errors.add(:add_documents, error)
32
+ attachment.errors[:file].each do |error|
33
+ @form.errors.add(:add_attachments, error)
34
34
  end
35
35
 
36
36
  return true
@@ -41,37 +41,38 @@ module Decidim
41
41
 
42
42
  def create_attachments(first_weight: 0)
43
43
  weight = first_weight
44
- # Add the weights first to the old documents
45
- document_ids = keep_ids
46
- Decidim::Attachment.where(id: document_ids).each do |document|
47
- document.update!(weight:)
44
+ # Add the weights first to the old attachments
45
+ attachment_ids = keep_ids
46
+ Decidim::Attachment.where(id: attachment_ids).each do |attachment|
47
+ attachment.update!(weight:)
48
48
  weight += 1
49
49
  end
50
- @documents.map! do |document|
51
- document.weight = weight
52
- document.attached_to = documents_attached_to
53
- document.save!
50
+ @attachments.map! do |attachment|
51
+ attachment.weight = weight
52
+ attachment.attached_to = attachments_attached_to
53
+ attachment.save!
54
54
  weight += 1
55
- @form.documents << document
55
+ @form.attachments << attachment
56
56
  end
57
57
  end
58
58
 
59
- def document_cleanup!(include_all_attachments: false)
60
- documents = include_all_attachments ? documents_attached_to.attachments.with_attached_file : documents_attached_to.documents
59
+ def attachment_cleanup!(include_all_attachments: false)
60
+ attachments = include_all_attachments ? attachments_attached_to.attachments.with_attached_file : attachments_attached_to.attachments
61
61
 
62
- documents.each do |document|
63
- document.destroy! unless keep_ids.include?(document.id)
62
+ attachments.each do |attachment|
63
+ attachment.destroy! unless keep_ids.include?(attachment.id)
64
64
  end
65
65
 
66
- documents_attached_to.reload
67
- documents_attached_to.instance_variable_set(:@documents, nil)
66
+ attachments_attached_to.reload
67
+ attachments_attached_to.instance_variable_set(:@attachments, nil)
68
+ attachments_attached_to.instance_variable_set(:@photos, nil)
68
69
  end
69
70
 
70
71
  def process_attachments?
71
- @form.add_documents.any?
72
+ @form.add_attachments.any?
72
73
  end
73
74
 
74
- def documents_attached_to
75
+ def attachments_attached_to
75
76
  return @attached_to if @attached_to.present?
76
77
  return form.current_organization if form.respond_to?(:current_organization)
77
78
 
@@ -101,8 +102,8 @@ module Decidim
101
102
  end
102
103
 
103
104
  def keep_ids
104
- documents_array = Array(@form.documents)
105
- documents_array.map do |doc|
105
+ attachments_array = Array(@form.attachments)
106
+ attachments_array.map do |doc|
106
107
  case doc
107
108
  when Decidim::Attachment
108
109
  doc.id
@@ -41,6 +41,10 @@ module Decidim
41
41
 
42
42
  layout "layouts/decidim/application"
43
43
 
44
+ # Ensure locale is set before Devise's own prepended callbacks and reset
45
+ # after the request finishes.
46
+ prepend_around_action :set_current_locale
47
+
44
48
  # Saves the location before loading each page so we can return to the
45
49
  # right page.
46
50
  before_action :store_current_location
@@ -58,6 +62,12 @@ module Decidim
58
62
 
59
63
  store_location_for(:user, redirect_url)
60
64
  end
65
+
66
+ def set_current_locale(&)
67
+ locale = detect_locale
68
+ locale = default_locale unless available_locales.include?(locale)
69
+ I18n.with_locale(locale, &)
70
+ end
61
71
  end
62
72
  end
63
73
  end
@@ -31,13 +31,6 @@ module Decidim
31
31
  end
32
32
 
33
33
  def process_remove_user(user)
34
- email = user.email
35
- name = user.name
36
- locale = user.locale
37
- organization = user.organization
38
-
39
- ParticipantsAccountMailer.removal_notification(email, name, locale, organization).deliver_later
40
-
41
34
  Decidim::DestroyAccount.call(
42
35
  Decidim::DeleteAccountForm.from_params(
43
36
  delete_reason: I18n.t("decidim.account.destroy.inactive_account_removal_reason", inactivity_period: Decidim.delete_inactive_users_after_days)
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ class DeleteUserMailer < ApplicationMailer
5
+ # This email is being sent when a user deletes his own account, or when the user was inactive for too long.
6
+ def delete(user_email:, user_name:, locale:, organization:)
7
+ I18n.with_locale(locale) do
8
+ @user_name = user_name
9
+ @organization = organization
10
+ mail(to: user_email, subject: I18n.t("decidim.delete_user_mailer.subject"))
11
+ end
12
+ end
13
+ end
14
+ end
@@ -18,21 +18,5 @@ module Decidim
18
18
  mail(to: user.email, subject:)
19
19
  end
20
20
  end
21
-
22
- # Notify user about account removal due to inactivity
23
- def removal_notification(email, name, locale, organization)
24
- @email = email
25
- @user_name = name
26
- @organization = organization
27
-
28
- I18n.with_locale(locale) do
29
- subject = I18n.t(
30
- "decidim.participants_account_mailer.removal_notification.subject",
31
- organization_name: organization_name(@organization)
32
- )
33
-
34
- mail(to: email, subject:)
35
- end
36
- end
37
21
  end
38
22
  end
@@ -32,7 +32,7 @@ module Decidim
32
32
  end
33
33
 
34
34
  def self.ransackable_attributes(_auth_object = nil)
35
- %w(reported_id_string reported_content created_at)
35
+ %w(reported_id_string reported_content created_at report_count)
36
36
  end
37
37
 
38
38
  def self.ransackable_associations(_auth_object = nil)
@@ -39,7 +39,7 @@ module Decidim
39
39
  def self.ransackable_attributes(auth_object = nil)
40
40
  return [] unless auth_object&.admin?
41
41
 
42
- %w(name nickname email invitation_accepted_at last_sign_in_at invitation_sent_at role)
42
+ %w(name nickname email invitation_accepted_at last_sign_in_at invitation_sent_at role published)
43
43
  end
44
44
 
45
45
  def self.ransackable_associations(_auth_object = nil)
@@ -69,12 +69,27 @@ module Decidim
69
69
  Decidim::UserBaseEntity.joins(:follows).where(decidim_follows: { user: self }).blocked.exists?
70
70
  end
71
71
 
72
+ ransacker :role do
73
+ Arel.sql(%{CASE WHEN "decidim_users"."admin" = true THEN 'admin' ELSE cast("decidim_users"."roles" as text) END})
74
+ end
75
+
76
+ ransacker :user_moderation_report_count do
77
+ query = <<~SQL.squish
78
+ (
79
+ SELECT COALESCE(MAX(decidim_user_moderations.report_count), 0)
80
+ FROM decidim_user_moderations
81
+ WHERE decidim_user_moderations.decidim_user_id = decidim_users.id
82
+ )
83
+ SQL
84
+ Arel.sql(query)
85
+ end
86
+
72
87
  def self.ransackable_attributes(auth_object = nil)
73
- base = %w(name email nickname last_sign_in_at)
88
+ base = %w(name email nickname last_sign_in_at created_at)
74
89
 
75
90
  return base unless auth_object&.admin?
76
91
 
77
- base + %w(invitation_sent_at invitation_accepted_at officialized_at)
92
+ base + %w(invitation_sent_at invitation_accepted_at officialized_at role user_moderation_report_count)
78
93
  end
79
94
 
80
95
  def self.ransackable_associations(_auth_object = nil)
@@ -19,7 +19,7 @@ module Decidim
19
19
  end
20
20
 
21
21
  def self.ransackable_attributes(_auth_object = nil)
22
- []
22
+ %w(created_at report_count)
23
23
  end
24
24
 
25
25
  def self.ransackable_associations(_auth_object = nil)
@@ -419,13 +419,13 @@ class FormValidator {
419
419
  return true;
420
420
  }
421
421
 
422
- checkboxGroup.forEach((checkboxElement) => {
423
- if (isValid) {
424
- this.removeInputErrorClasses(checkboxElement);
425
- } else {
422
+ if (isValid) {
423
+ this.removeCheckboxGroupErrorClasses(groupName);
424
+ } else {
425
+ checkboxGroup.forEach((checkboxElement) => {
426
426
  this.addInputErrorClasses(checkboxElement, ["required"]);
427
- }
428
- });
427
+ });
428
+ }
429
429
 
430
430
  return isValid;
431
431
  }
@@ -1,4 +1,4 @@
1
- /* eslint max-lines: ["error", 690] */
1
+ /* eslint max-lines: ["error", 712] */
2
2
  /* global jest */
3
3
  /**
4
4
  * @jest-environment jsdom
@@ -253,6 +253,28 @@ describe("FormValidator", () => {
253
253
  const isValidTwo = validatorInstance.validateCheckboxGroup("multiCheckboxes");
254
254
  expect(isValidTwo).toBe(true);
255
255
  });
256
+
257
+ it("should remove error classes once for the group, not per checkbox", () => {
258
+ formElement.innerHTML = `
259
+ <fieldset>
260
+ <input type="checkbox" id="cb-1" name="largeGroup" value="1" required>
261
+ <input type="checkbox" id="cb-2" name="largeGroup" value="2" required>
262
+ <input type="checkbox" id="cb-3" name="largeGroup" value="3" required>
263
+ </fieldset>
264
+ <button type="submit">Submit</button>
265
+ `;
266
+ validatorInstance = new FormValidator(formElement);
267
+ formElement.querySelector("#cb-1").checked = true;
268
+
269
+ const removeGroupSpy = jest.spyOn(validatorInstance, "removeCheckboxGroupErrorClasses");
270
+ const removeInputSpy = jest.spyOn(validatorInstance, "removeInputErrorClasses");
271
+
272
+ const isValid = validatorInstance.validateCheckboxGroup("largeGroup");
273
+
274
+ expect(isValid).toBe(true);
275
+ expect(removeGroupSpy).toHaveBeenCalledTimes(1);
276
+ expect(removeInputSpy).not.toHaveBeenCalled();
277
+ });
256
278
  });
257
279
 
258
280
  describe("Custom Validators", () => {