decidim-comments 0.30.2 → 0.31.0.rc1

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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/comments/comment/deletion_data.erb +1 -1
  3. data/app/cells/decidim/comments/comment/show.erb +12 -12
  4. data/app/cells/decidim/comments/comment_cell.rb +1 -3
  5. data/app/cells/decidim/comments/comment_form/comment_as.erb +5 -24
  6. data/app/cells/decidim/comments/comment_form/show.erb +3 -3
  7. data/app/cells/decidim/comments/comment_form_cell.rb +5 -20
  8. data/app/cells/decidim/comments/comments/order_control.erb +1 -1
  9. data/app/cells/decidim/comments/edit_comment_modal_form/show.erb +2 -2
  10. data/app/commands/decidim/comments/create_comment.rb +3 -5
  11. data/app/events/decidim/comments/comment_event.rb +3 -10
  12. data/app/forms/decidim/comments/comment_form.rb +0 -1
  13. data/app/models/decidim/comments/comment.rb +2 -2
  14. data/app/models/decidim/comments/seed.rb +4 -16
  15. data/app/packs/src/decidim/comments/comments.component.js +0 -7
  16. data/app/packs/src/decidim/comments/comments.component.test.js +4 -16
  17. data/app/packs/src/decidim/comments/comments.js +1 -1
  18. data/app/packs/src/decidim/comments/comments_mobile_modal.js +1 -1
  19. data/app/packs/stylesheets/comments.scss +1 -5
  20. data/app/queries/decidim/comments/sorted_comments.rb +1 -1
  21. data/app/services/decidim/comments/new_comment_notification_creator.rb +2 -27
  22. data/app/views/decidim/comments/admin/shared/_availability_fields.html.erb +1 -1
  23. data/app/views/decidim/comments/comments/delete.js.erb +4 -2
  24. data/app/views/decidim/comments/comments/reload.js.erb +0 -1
  25. data/app/views/decidim/comments/comments/update.js.erb +3 -1
  26. data/config/assets.rb +2 -2
  27. data/config/locales/ar.yml +0 -18
  28. data/config/locales/bg.yml +0 -18
  29. data/config/locales/bs-BA.yml +0 -8
  30. data/config/locales/ca-IT.yml +0 -20
  31. data/config/locales/ca.yml +0 -20
  32. data/config/locales/cs.yml +0 -20
  33. data/config/locales/de.yml +0 -20
  34. data/config/locales/el.yml +0 -18
  35. data/config/locales/en.yml +0 -20
  36. data/config/locales/es-MX.yml +0 -20
  37. data/config/locales/es-PY.yml +0 -20
  38. data/config/locales/es.yml +0 -20
  39. data/config/locales/eu.yml +0 -20
  40. data/config/locales/fi-plain.yml +0 -20
  41. data/config/locales/fi.yml +0 -20
  42. data/config/locales/fr-CA.yml +0 -23
  43. data/config/locales/fr.yml +0 -23
  44. data/config/locales/ga-IE.yml +0 -5
  45. data/config/locales/gl.yml +0 -11
  46. data/config/locales/hu.yml +0 -18
  47. data/config/locales/id-ID.yml +0 -11
  48. data/config/locales/is-IS.yml +0 -5
  49. data/config/locales/it.yml +0 -18
  50. data/config/locales/ja.yml +0 -20
  51. data/config/locales/lb.yml +0 -18
  52. data/config/locales/lt.yml +0 -18
  53. data/config/locales/lv.yml +0 -18
  54. data/config/locales/nl.yml +0 -18
  55. data/config/locales/no.yml +0 -18
  56. data/config/locales/pl.yml +0 -18
  57. data/config/locales/pt-BR.yml +0 -18
  58. data/config/locales/pt.yml +0 -18
  59. data/config/locales/ro-RO.yml +0 -20
  60. data/config/locales/ru.yml +0 -11
  61. data/config/locales/si-LK.yml +0 -2
  62. data/config/locales/sk.yml +0 -18
  63. data/config/locales/sq-AL.yml +0 -2
  64. data/config/locales/sr-CS.yml +0 -9
  65. data/config/locales/sv.yml +0 -20
  66. data/config/locales/tr-TR.yml +0 -18
  67. data/config/locales/uk.yml +0 -6
  68. data/config/locales/zh-CN.yml +0 -18
  69. data/config/locales/zh-TW.yml +0 -18
  70. data/db/migrate/20181003080320_fix_user_groups_ids_in_comments.rb +8 -1
  71. data/lib/decidim/api/comment_type.rb +1 -4
  72. data/lib/decidim/api/commentable_interface.rb +7 -13
  73. data/lib/decidim/api/commentable_mutation_type.rb +2 -3
  74. data/lib/decidim/comments/comment_serializer.rb +0 -4
  75. data/lib/decidim/comments/comment_vote_serializer.rb +0 -4
  76. data/lib/decidim/comments/commentable.rb +4 -0
  77. data/lib/decidim/comments/engine.rb +6 -20
  78. data/lib/decidim/comments/test/factories.rb +1 -1
  79. data/lib/decidim/comments/test/shared_examples/comment_event.rb +1 -10
  80. data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +0 -2
  81. data/lib/decidim/comments/version.rb +1 -1
  82. metadata +8 -12
  83. data/app/events/decidim/comments/comment_by_followed_user_group_event.rb +0 -9
  84. data/app/events/decidim/comments/user_group_mentioned_event.rb +0 -10
  85. data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +0 -50
  86. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 961d892e5bcb765e23c2fb3e827821b291ea82a7b739d9f53a0bf61e0b57d84e
4
- data.tar.gz: 9ee5a7bd9f898558f06cd3c151072708e228d35c77e60266e7040ee301c1ce23
3
+ metadata.gz: db61183a2914f1449e47ae59e79af732d2298593b617dccd1f729cdb84201957
4
+ data.tar.gz: b5822d26479e2a25527c45037210d4594fff730ed10f4ce0ef9e29a9e7c1377d
5
5
  SHA512:
6
- metadata.gz: bfe95d885027ac452b5b10801ab86dd2a9a631d8b82b81ac0209702425fb680fd8d80150c55f90fab652aa6e9a68bdb43b3653d59ca3b9c465392d8ef23daee6
7
- data.tar.gz: 38f9b191adf45e1876397a41e1e89942c864f3528b97c9d430a30c69f1852643b92685be1d574e98b8009a3833c1cd7e5d6ada1c628d2f81096bdb00b10cf8ed
6
+ metadata.gz: c414291891ac6ad8f8904d6e97599e9bbab52f7c07b4e93dfb60dace6abb80f2042834d82edf080a9cf365fbfdce35613edc8f76b831ae95746c6b11beb833dd
7
+ data.tar.gz: 53112244ce496b3920f0da1cf74ad31608c19b790d9085053bfbba4e56df39d8a3634f30203905d11c0208649e4d4d1b9d8749d78d4942f2bbbccd5608b38c26
@@ -1,6 +1,6 @@
1
1
  <%= render partial: "decidim/comments/comments/delete", formats: [:html], locals: { comment: model } %>
2
2
 
3
- <div data-comment-footer data-component="accordion" id="accordion-<%= model.id %>">
3
+ <div data-comment-footer data-controller="accordion" id="accordion-<%= model.id %>">
4
4
  <div id="comment-<%= model.id %>-replies" class="<%= "comment-reply" if has_replies_in_children? %>">
5
5
  <% if has_replies_in_children? %>
6
6
  <%= render :replies %>
@@ -31,34 +31,34 @@
31
31
  <% end %>
32
32
 
33
33
  <div class="relative ml-auto">
34
- <button id="dropdown-trigger-<%= context_menu_id %>" data-component="dropdown" data-target="dropdown-menu-<%= context_menu_id %>" aria-label="<%= t("decidim.components.comment.controls_label") %>">
34
+ <button id="dropdown-trigger-<%= context_menu_id %>" data-controller="dropdown" data-target="dropdown-menu-<%= context_menu_id %>" aria-label="<%= t("decidim.components.comment.controls_label") %>">
35
35
  <%# NOTE: having two times the icon call is intentional, as that is how the `dropdown` CSS code is done %>
36
36
  <%= icon "more-fill" %>
37
37
  <%= icon "more-fill" %>
38
38
  </button>
39
39
 
40
40
  <div id="dropdown-menu-<%= context_menu_id %>" aria-hidden="true">
41
- <ul class="dropdown dropdown__bottom divide-y divide-gray-3 px-4">
41
+ <ul class="dropdown dropdown__bottom divide-y divide-gray-3">
42
42
  <% unless reloaded? %>
43
- <li>
44
- <%= cell("decidim/report_button", model, only_button: true, button_classes: "dropdown__item flex-row-reverse", modal_id: "flagModalComment#{model.id}") %>
43
+ <li class="dropdown__item">
44
+ <%= cell("decidim/report_button", model, only_button: true, button_classes: "dropdown__button", modal_id: "flagModalComment#{model.id}") %>
45
45
  </li>
46
46
  <% end %>
47
- <li>
48
- <%= link_to "#{commentable_path("commentId" => model.id)}#comment_#{model.id}", target: "_blank", data: { "external-link": "text-only" }, class: "dropdown__item", title: t("decidim.components.comment.single_comment_link_title") do %>
47
+ <li class="dropdown__item">
48
+ <%= link_to "#{commentable_path("commentId" => model.id)}#comment_#{model.id}", class: "dropdown__button", target: "_blank", data: { "external-link": "text-only" }, title: t("decidim.components.comment.single_comment_link_title") do %>
49
49
  <%= icon "share-line" %>
50
50
  <span><%= t("decidim.components.comment.single_comment_link_title") %></span>
51
51
  <% end %>
52
52
  </li>
53
53
  <% if model.authored_by?(current_user) %>
54
- <li>
55
- <button type="button" class="dropdown__item" data-dialog-open="<%= "editCommentModal#{model.id}" %>" title="<%= t("decidim.components.comment.edit") %>" aria-controls="<%= "editCommentModal#{model.id}" %>" aria-haspopup="dialog">
54
+ <li class="dropdown__item">
55
+ <button type="button" data-dialog-open="<%= "editCommentModal#{model.id}" %>" class="dropdown__button" title="<%= t("decidim.components.comment.edit") %>" aria-controls="<%= "editCommentModal#{model.id}" %>" aria-haspopup="dialog">
56
56
  <%= icon "edit-line" %>
57
57
  <span><%= t("decidim.components.comment.edit") %></span>
58
58
  </button>
59
59
  </li>
60
- <li>
61
- <%= link_to comment_path, remote: true, method: :delete, class: "dropdown__item", data: { confirm: t("decidim.components.comment.confirm_destroy") } do %>
60
+ <li class="dropdown__item">
61
+ <%= link_to comment_path, remote: true, method: :delete, class: "dropdown__button", data: { confirm: t("decidim.components.comment.confirm_destroy") } do %>
62
62
  <%= icon "delete-bin-line" %>
63
63
  <span><%= t("decidim.components.comment.delete") %></span>
64
64
  <% end %>
@@ -66,7 +66,7 @@
66
66
  <% end %>
67
67
  <% if (extra_actions) %>
68
68
  <% extra_actions.each do |action| %>
69
- <li>
69
+ <li class="dropdown__item">
70
70
  <%= link_to(*action) %>
71
71
  </li>
72
72
  <% end %>
@@ -83,7 +83,7 @@
83
83
  </div>
84
84
  </div>
85
85
 
86
- <div data-comment-footer data-component="accordion" id="accordion-<%= model.id %>" class="relative">
86
+ <div data-comment-footer data-controller="accordion" id="accordion-<%= model.id %>" class="relative">
87
87
  <div class="comment__footer-grid">
88
88
  <div class="comment__votes-actions">
89
89
  <%= render :actions %>
@@ -105,7 +105,7 @@ module Decidim
105
105
  "#{icon(action[:icon]) if action[:icon].present?}#{action[:label]}",
106
106
  action[:url],
107
107
  {
108
- class: "dropdown__item"
108
+ class: "dropdown__button"
109
109
  }
110
110
  ].tap do |link|
111
111
  link[2][:method] = action[:method] if action[:method].present?
@@ -139,8 +139,6 @@ module Decidim
139
139
  def author_presenter
140
140
  if model.author.respond_to?(:official?) && model.author.official?
141
141
  Decidim::Core::OfficialAuthorPresenter.new
142
- elsif model.user_group
143
- model.user_group.presenter
144
142
  else
145
143
  model.author.presenter
146
144
  end
@@ -1,28 +1,9 @@
1
1
  <div class="comment__as">
2
- <button id="dropdown-trigger-<%= comment_as_id %>" data-component="dropdown" data-target="dropdown-menu-<%= comment_as_id %>" data-comments-dropdown>
3
- <div class="comment__as-author-selected">
4
- <label class="ml-10 text-left text-xs" for="<%= comment_as_id %>">
5
- <%= t("decidim.components.add_comment_form.form.user_group_id.your_profile") %>
6
- </label>
7
- <span class="flex items-center gap-2"></span>
2
+ <div class="comment__as-author-info">
3
+ <div class="author__avatar-container border border-white">
4
+ <%= image_tag author_presenter.avatar_url(:thumb), alt: t("decidim.author.avatar", name: author_presenter.name), class: "author__avatar" %>
8
5
  </div>
9
- <%= icon "arrow-down-s-line" %>
10
- <%= icon "arrow-up-s-line" %>
11
- </button>
12
6
 
13
- <ul id="dropdown-menu-<%= comment_as_id %>" class="gap-4">
14
- <% comment_as_options.each do |option| %>
15
- <li class="comment__as-author-container">
16
- <div class="comment__as-author-info">
17
- <div class="author__avatar-container border border-white">
18
- <%= image_tag option[0].avatar_url(:thumb), alt: t("decidim.author.avatar", name: option[0].name), class: "author__avatar" %>
19
- </div>
20
-
21
- <p class="comment__as-author-name"><%= option[0].name %></p>
22
- </div>
23
-
24
- <input type="radio" name="comment[user_group_id]" class="w-5 h-4" value="<%= option[1] %>">
25
- </li>
26
- <% end %>
27
- </ul>
7
+ <p class="comment__as-author-name"><%= author_presenter.name %></p>
8
+ </div>
28
9
  </div>
@@ -1,4 +1,4 @@
1
- <%= form_for(form_object, url: decidim_comments.comments_path(order:), method: :post, remote: true, html: { id: form_id }) do |form| %>
1
+ <%= decidim_form_for(form_object, url: decidim_comments.comments_path(order:), method: :post, remote: true, html: { id: form_id }) do |form| %>
2
2
  <% unless reply? %>
3
3
  <div class="comment__form-mobile-banner">
4
4
  <p class="font-semibold text-2xl"><%= t("decidim.components.add_comment_form.add_comment") %></p>
@@ -9,7 +9,7 @@
9
9
  <% end %>
10
10
  <%= form.hidden_field :commentable_gid, id: nil %>
11
11
  <%= form.hidden_field :alignment, id: nil, class: "alignment-input" %>
12
- <%= comment_as_for(form) %>
12
+ <%= comment_as %>
13
13
 
14
14
  <div class="px-4 md:p-0">
15
15
  <%= form.text_area(
@@ -20,7 +20,7 @@
20
20
  required: true,
21
21
  placeholder: t("decidim.components.add_comment_form.form.body.placeholder"),
22
22
  label: false,
23
- data: { remaining_characters: "##{add_comment_id}-remaining-characters", input_emoji: true }
23
+ data: { remaining_characters: "##{add_comment_id}-remaining-characters", controller: "emoji mention character-counter" }
24
24
  ) %>
25
25
  </div>
26
26
  <span id="<%= add_comment_id %>-remaining-characters" class="remaining-character-count"></span>
@@ -4,13 +4,10 @@ module Decidim
4
4
  module Comments
5
5
  # A cell to display a form for adding a new comment.
6
6
  class CommentFormCell < Decidim::ViewModel
7
- def comment_as_for(form)
8
- return if verified_user_groups.blank?
7
+ def comment_as
8
+ return if current_user.blank?
9
9
 
10
- # Note that the form.select does not seem to work correctly in the cell
11
- # context. The Rails form builder tries to call @template.select which
12
- # is not available for the cell objects.
13
- render view: :comment_as, locals: { form: }
10
+ render
14
11
  end
15
12
 
16
13
  def two_columns_layout?
@@ -57,10 +54,6 @@ module Decidim
57
54
  "add-comment-#{commentable_type.demodulize}-#{model.id}"
58
55
  end
59
56
 
60
- def comment_as_id
61
- "add-comment-#{commentable_type.demodulize}-#{model.id}-user-group-id"
62
- end
63
-
64
57
  def root_depth
65
58
  options[:root_depth] || 0
66
59
  end
@@ -72,16 +65,8 @@ module Decidim
72
65
  )
73
66
  end
74
67
 
75
- def verified_user_groups
76
- return [] unless current_user
77
-
78
- @verified_user_groups ||= Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
79
- end
80
-
81
- def comment_as_options
82
- [[UserPresenter.new(current_user), ""]] + verified_user_groups.map do |group|
83
- [UserGroupPresenter.new(group), group.id]
84
- end
68
+ def author_presenter
69
+ current_user&.presenter
85
70
  end
86
71
 
87
72
  def comments_max_length
@@ -1,5 +1,5 @@
1
1
  <div class="comment-order-by">
2
- <%= form_with url: "#" do %>
2
+ <%= form_with url: "#", data: { controller: :sort_comments } do %>
3
3
  <div class="md:hidden">
4
4
  <select id="order-mobile" aria-label="<%= t("decidim.components.comment.sort_by") %>" data-mobile-order-comment-select="true">
5
5
  <option class="input-hidden" value="" <%= "disabled selected hidden" %>> <%= t("decidim.components.comment.sort_by") %> </option>
@@ -1,5 +1,5 @@
1
1
  <%= decidim_modal id: "editCommentModal#{model.id}" do %>
2
- <%= form_for(form_object, url: decidim_comments.comment_path(comment), method: :put, remote: true, html: { id: nil }) do |form| %>
2
+ <%= decidim_form_for(form_object, url: decidim_comments.comment_path(comment), method: :put, remote: true, html: { id: nil }) do |form| %>
3
3
  <div data-dialog-container>
4
4
  <%= icon "edit-line" %>
5
5
  <h2 class="h2" id="dialog-title-budget-confirm" data-dialog-title>
@@ -19,7 +19,7 @@
19
19
  placeholder: t("decidim.components.edit_comment_modal_form.form.body.placeholder"),
20
20
  label: false,
21
21
  class: "w-full rounded border min-h-[160px] border-text-gray-2",
22
- data: { remaining_characters: "##{form_id}-remaining-characters", input_emoji: true }
22
+ data: { remaining_characters: "##{form_id}-remaining-characters", controller: "emoji mention character-counter" }
23
23
  ) %>
24
24
  </div>
25
25
  </div>
@@ -51,7 +51,6 @@ module Decidim
51
51
  root_commentable: root_commentable(form.commentable),
52
52
  body: { I18n.locale => parsed.rewrite },
53
53
  alignment: form.alignment,
54
- decidim_user_group_id: form.user_group_id,
55
54
  participatory_space: form.current_component.try(:participatory_space)
56
55
  }
57
56
 
@@ -63,13 +62,12 @@ module Decidim
63
62
  )
64
63
 
65
64
  mentioned_users = parsed.metadata[:user].users
66
- mentioned_groups = parsed.metadata[:user_group].groups
67
65
  CommentCreation.publish(@comment, parsed.metadata)
68
- send_notifications(mentioned_users, mentioned_groups)
66
+ send_notifications(mentioned_users)
69
67
  end
70
68
 
71
- def send_notifications(mentioned_users, mentioned_groups)
72
- NewCommentNotificationCreator.new(comment, mentioned_users, mentioned_groups).create
69
+ def send_notifications(mentioned_users)
70
+ NewCommentNotificationCreator.new(comment, mentioned_users).create
73
71
  end
74
72
 
75
73
  def root_commentable(commentable)
@@ -10,6 +10,8 @@ module Decidim
10
10
  include Decidim::Events::MachineTranslatedEvent
11
11
 
12
12
  included do
13
+ delegate :author, to: :comment
14
+
13
15
  def resource_text(override_translation = nil)
14
16
  comment.formatted_body(override_translation)
15
17
  end
@@ -18,19 +20,10 @@ module Decidim
18
20
  super || (comment.respond_to?(:hidden?) && comment.hidden?)
19
21
  end
20
22
 
21
- def author
22
- comment.normalized_author
23
- end
24
-
25
23
  def author_presenter
26
24
  return unless author
27
25
 
28
- @author_presenter ||= case author
29
- when Decidim::User
30
- Decidim::UserPresenter.new(author)
31
- when Decidim::UserGroup
32
- Decidim::UserGroupPresenter.new(author)
33
- end
26
+ @author_presenter ||= author.presenter
34
27
  end
35
28
 
36
29
  def translatable_resource
@@ -9,7 +9,6 @@ module Decidim
9
9
 
10
10
  attribute :body, Decidim::Attributes::CleanString
11
11
  attribute :alignment, Integer
12
- attribute :user_group_id, Integer
13
12
  attribute :commentable
14
13
  attribute :commentable_gid
15
14
 
@@ -156,7 +156,7 @@ module Decidim
156
156
 
157
157
  # Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
158
158
  def reported_searchable_content_extras
159
- [normalized_author.name]
159
+ [author.name]
160
160
  end
161
161
 
162
162
  def self.export_serializer
@@ -208,7 +208,7 @@ module Decidim
208
208
  end
209
209
 
210
210
  def edited?
211
- Decidim::ActionLog.where(resource: self).exists?(["extra @> ?", Arel.sql("{\"edit\":true}")])
211
+ Decidim::ActionLog.where(resource: self).exists?(["extra @> ?", { edit: true }.to_json])
212
212
  end
213
213
 
214
214
  def extra_actions_for(current_user)
@@ -22,11 +22,11 @@ module Decidim
22
22
 
23
23
  rand(0..6).times do
24
24
  comment1 = create_comment(resource)
25
- NewCommentNotificationCreator.new(comment1, [], []).create
25
+ NewCommentNotificationCreator.new(comment1, []).create
26
26
 
27
27
  if [true, false].sample
28
28
  comment2 = create_comment(comment1, resource)
29
- NewCommentNotificationCreator.new(comment2, [], []).create
29
+ NewCommentNotificationCreator.new(comment2, []).create
30
30
  end
31
31
 
32
32
  next if [true, false].sample
@@ -50,14 +50,12 @@ module Decidim
50
50
  # @return [Decidim::Comments::Comment]
51
51
  def create_comment(resource, root_commentable = nil)
52
52
  author = random_user
53
- user_group = random_user_group(author)
54
53
 
55
54
  params = {
56
55
  commentable: resource,
57
56
  root_commentable: root_commentable || resource,
58
57
  body: { en: ::Faker::Lorem.sentence(word_count: 50) },
59
- author:,
60
- user_group:
58
+ author:
61
59
  }
62
60
 
63
61
  Decidim.traceability.create!(
@@ -69,7 +67,6 @@ module Decidim
69
67
  end
70
68
 
71
69
  # Creates a random amount of votes for a given comment.
72
- # The votes can be from a user or a user group.
73
70
  #
74
71
  # @private
75
72
  #
@@ -78,9 +75,7 @@ module Decidim
78
75
  # @return nil
79
76
  def create_votes(comment)
80
77
  rand(0..12).times do
81
- user = random_user
82
- user_group = random_user_group(user)
83
- author = [user, user_group].compact.sample
78
+ author = random_user
84
79
  next if CommentVote.where(comment:, author:).any?
85
80
 
86
81
  CommentVote.create!(comment:, author:, weight: [1, -1].sample)
@@ -96,13 +91,6 @@ module Decidim
96
91
 
97
92
  user.valid? ? user : random_user
98
93
  end
99
-
100
- def random_user_group(user)
101
- user_group = Decidim::UserGroups::ManageableUserGroups.for(user).verified.sample
102
- return nil unless user_group&.valid?
103
-
104
- [true, false].sample ? user_group : nil
105
- end
106
94
  end
107
95
  end
108
96
  end
@@ -12,7 +12,6 @@
12
12
  // This is necessary for testing purposes
13
13
  const $ = window.$;
14
14
 
15
- import changeReportFormBehavior from "src/decidim/change_report_form_behavior";
16
15
  import { initializeCommentsDropdown } from "../../decidim/comments/comments_dropdown";
17
16
 
18
17
  export default class CommentsComponent {
@@ -158,8 +157,6 @@ export default class CommentsComponent {
158
157
  $opinionButtons.on("click.decidim-comments", this._onToggleOpinion);
159
158
  $text.on("input.decidim-comments", this._onTextInput);
160
159
 
161
- $(document).trigger("attach-mentions-element", [$text.get(0)]);
162
-
163
160
  $form.on("submit.decidim-comments", () => {
164
161
  const $submit = $("button[type='submit']", $form);
165
162
 
@@ -167,15 +164,11 @@ export default class CommentsComponent {
167
164
  this._stopPolling();
168
165
  });
169
166
 
170
- document.querySelectorAll(".new_report").forEach((container) => changeReportFormBehavior(container));
171
-
172
167
  const $dropdown = $add.find("[data-comments-dropdown]");
173
168
  if ($dropdown.length > 0) {
174
169
  initializeCommentsDropdown($dropdown[0]);
175
170
  }
176
171
 
177
- document.querySelectorAll(".new_report").forEach((container) => changeReportFormBehavior(container))
178
-
179
172
  if ($text.length && $text.get(0) !== null) {
180
173
  // Attach event to the DOM node, instead of the jQuery object
181
174
  $text.get(0).addEventListener("emoji.added", this._onTextInput);
@@ -18,8 +18,7 @@ window.Rails = Rails;
18
18
  // Fake timers for testing polling
19
19
  jest.useFakeTimers();
20
20
 
21
- import { createCharacterCounter } from "src/decidim/input_character_counter";
22
- import Configuration from "src/decidim/configuration";
21
+ import Configuration from "src/decidim/refactor/implementation/configuration";
23
22
  // Component is loaded with require because using import loads it before $ has been mocked
24
23
  // so tests are not able to check the spied behaviours
25
24
  const CommentsComponent = require("./comments.component_for_testing.js");
@@ -213,7 +212,7 @@ describe("CommentsComponent", () => {
213
212
  <summary class="button button__sm button__text-secondary" aria-controls="toggle-context-menu-${commentId}">
214
213
  <svg width="1em" height="1em" role="img" aria-hidden="true"><use href="/decidim-packs/media/images/remixicon.symbol-5540ed538fb6bd400d2a.svg#ri-more-line" tabindex="-1"></use></svg>
215
214
  </summary>
216
- <ul id="toggle-context-menu-${commentId}" class="dropdown dropdown__bottom divide-y divide-gray-3 px-4">
215
+ <ul id="toggle-context-menu-${commentId}" class="dropdown dropdown__bottom divide-y divide-gray-3">
217
216
  <li>
218
217
  <button type="button" class="dropdown__item" data-dialog-open="flagModalComment${commentId}" title="Report" aria-controls="flagModalComment${commentId}" aria-haspopup="dialog" tabindex="0">
219
218
  <svg width="1em" height="1em" role="img" aria-hidden="true"><use href="/decidim-packs/media/images/remixicon.symbol-5540ed538fb6bd400d2a.svg#ri-flag-line" tabindex="-1"></use></svg>
@@ -233,7 +232,7 @@ describe("CommentsComponent", () => {
233
232
  <div class="comment__content">
234
233
  <div><p>${content}</p></div>
235
234
  </div>
236
- <div data-comment-footer data-component="accordion" role="presentation">
235
+ <div data-comment-footer data-controller="accordion" role="presentation">
237
236
  <div class="comment__footer-grid">
238
237
  <div class="comment__actions">
239
238
  <button class="button button__sm button__text-secondary" data-controls="panel-comment${commentId}-reply" role="button" tabindex="0" aria-controls="panel-comment${commentId}-reply" aria-expanded="false" aria-disabled="false">
@@ -363,9 +362,6 @@ describe("CommentsComponent", () => {
363
362
  lastCommentId: 456,
364
363
  pollingInterval: 1000
365
364
  });
366
- $("textarea[maxlength]", $container).each((_i, elem) => {
367
- createCharacterCounter($(elem));
368
- });
369
365
 
370
366
  $doc = $(document);
371
367
  addComment = $(".add-comment", subject.$element);
@@ -447,6 +443,7 @@ describe("CommentsComponent", () => {
447
443
  spyOnAddComment("on");
448
444
  jest.spyOn(orderLinks, "on");
449
445
  jest.spyOn($doc, "trigger");
446
+ jest.spyOn(document, "dispatchEvent");
450
447
 
451
448
  subject.mountComponent();
452
449
  });
@@ -475,15 +472,6 @@ describe("CommentsComponent", () => {
475
472
  );
476
473
  });
477
474
  });
478
-
479
- it("attaches the mentions elements to the text fields", () => {
480
- addComment.each((i) => {
481
- expect($doc.trigger).toHaveBeenCalledWith(
482
- "attach-mentions-element",
483
- [addComment[i].commentTextarea[0]]
484
- );
485
- });
486
- });
487
475
  });
488
476
 
489
477
  describe("when interacting", () => {
@@ -100,4 +100,4 @@ const commentsInitializer = () => {
100
100
  };
101
101
 
102
102
  // If no jQuery is used the Tribute feature used in comments to autocomplete mentions stops working
103
- $(() => commentsInitializer());
103
+ document.addEventListener("turbo:load", commentsInitializer);
@@ -19,7 +19,7 @@ const closeAddComment = function (addCommentCard) {
19
19
  addCommentCard.classList.remove("fullscreen");
20
20
  }
21
21
 
22
- document.addEventListener("DOMContentLoaded", () => {
22
+ document.addEventListener("turbo:load", () => {
23
23
  // Add comment card for mobile
24
24
  const addCommentCard = document.getElementById("add-comment-anchor");
25
25
  if (addCommentCard) {
@@ -1,4 +1,4 @@
1
- @import "stylesheets/decidim/_tribute.scss";
1
+ @use "stylesheets/decidim/tribute";
2
2
 
3
3
  .comments {
4
4
  &__container {
@@ -109,10 +109,6 @@
109
109
  /* overwrite default dropdown styles */
110
110
  [data-target*="dropdown"] {
111
111
  @apply md:flex w-auto cursor-pointer text-sm text-secondary;
112
-
113
- > svg {
114
- @apply h-3 w-3;
115
- }
116
112
  }
117
113
 
118
114
  /* overwrite default dropdown styles */
@@ -31,7 +31,7 @@ module Decidim
31
31
  # level of nested replies.
32
32
  def query
33
33
  scope = base_scope
34
- .includes(:author, :user_group, :up_votes, :down_votes)
34
+ .includes(:author, :up_votes, :down_votes)
35
35
 
36
36
  case @options[:order_by]
37
37
  when "recent"
@@ -17,12 +17,9 @@ module Decidim
17
17
  # comment - the Comment from which to generate notifications.
18
18
  # mentioned_users - An ActiveRecord::Relation of the users that have been
19
19
  # mentioned
20
- # mentioned_groups - And ActiveRecord::Relation of the user_groups that have
21
- # been mentioned
22
- def initialize(comment, mentioned_users, mentioned_groups = nil)
20
+ def initialize(comment, mentioned_users)
23
21
  @comment = comment
24
22
  @mentioned_users = mentioned_users
25
- @mentioned_groups = mentioned_groups
26
23
  @already_notified_users = [comment.author]
27
24
  end
28
25
 
@@ -31,16 +28,14 @@ module Decidim
31
28
  # Returns nothing.
32
29
  def create
33
30
  notify_mentioned_users
34
- notify_mentioned_groups
35
31
  notify_parent_comment_author
36
32
  notify_author_followers
37
- notify_user_group_followers
38
33
  notify_commentable_recipients
39
34
  end
40
35
 
41
36
  private
42
37
 
43
- attr_reader :comment, :mentioned_users, :mentioned_groups, :already_notified_users
38
+ attr_reader :comment, :mentioned_users, :already_notified_users
44
39
 
45
40
  def notify_mentioned_users
46
41
  affected_users = mentioned_users - already_notified_users
@@ -49,17 +44,6 @@ module Decidim
49
44
  notify(:user_mentioned, affected_users:)
50
45
  end
51
46
 
52
- def notify_mentioned_groups
53
- return unless mentioned_groups
54
-
55
- mentioned_groups.each do |group|
56
- affected_users = group.accepted_users - already_notified_users
57
- @already_notified_users += affected_users
58
-
59
- notify(:user_group_mentioned, affected_users:, extra: { group_id: group.id })
60
- end
61
- end
62
-
63
47
  # Notifies the author of a comment that their comment has been replied.
64
48
  # Only applies if the comment is a reply.
65
49
  def notify_parent_comment_author
@@ -78,15 +62,6 @@ module Decidim
78
62
  notify(:comment_by_followed_user, followers:)
79
63
  end
80
64
 
81
- def notify_user_group_followers
82
- return if comment.user_group.blank?
83
-
84
- followers = comment.user_group.followers - already_notified_users
85
- @already_notified_users += followers
86
-
87
- notify(:comment_by_followed_user_group, followers:)
88
- end
89
-
90
65
  # Notifies the users the `comment.commentable` resource implements as necessary.
91
66
  def notify_commentable_recipients
92
67
  followers = comment.commentable.users_to_notify_on_comment_created - already_notified_users
@@ -1,5 +1,5 @@
1
1
  <div class="row column">
2
- <%= form.check_box :comments_enabled, label: t(".enabled"), "data-toggle": "customize_comments_times-div" %>
2
+ <%= form.check_box :comments_enabled, label: t(".enabled"), data: { controller: :toggle, "toggle-toggle-value": "customize_comments_times-div" } %>
3
3
  </div>
4
4
 
5
5
  <div id="customize_comments_times-div" data-toggler=".hide" class="row column <%= @form.comments_enabled ? nil : "hide" %>">
@@ -1,4 +1,4 @@
1
- $(() => {
1
+ document.addEventListener("turbo:load", () => {
2
2
  const deleteDataHtml = '<%== j(render partial: "delete", locals: { comment: @comment }).strip %>';
3
3
  const rootCommentableId = <%== "comments-for-#{@comment.root_commentable.commentable_type.demodulize}-#{@comment.root_commentable.id}".to_json %>;
4
4
  const commentId = <%= @comment.id.to_json %>;
@@ -11,7 +11,7 @@ $(() => {
11
11
  $(`#comment_${commentId} > [data-comment-footer] > .comment__${section}`).remove();
12
12
  });
13
13
  $(`#comment_${commentId} > .comment__header`).remove();
14
- $(`#comment_${commentId} > [data-additional-reply]`).remove();
14
+ $(`#comment_${commentId} > [data-comment-footer] > [data-additional-reply]`).remove();
15
15
 
16
16
  $commentReply.remove();
17
17
  $content.replaceWith(deleteDataHtml);
@@ -21,3 +21,5 @@ $(() => {
21
21
 
22
22
  $(".comments-count", $(`#${rootCommentableId}`)).text(<%== t("decidim.components.comments.title", count: @comment.root_commentable.comments_count).to_json %>);
23
23
  });
24
+
25
+ document.dispatchEvent(new CustomEvent("turbo:load"));
@@ -15,5 +15,4 @@
15
15
  // Update the comments count
16
16
  $(".comments-count", $comments).text(<%== t("decidim.components.comments.title", count: @comments_count).to_json %>);
17
17
 
18
- Decidim.addInputEmoji();
19
18
  }());
@@ -1,4 +1,4 @@
1
- $(() => {
1
+ document.addEventListener("turbo:load", () => {
2
2
  var rootCommentableId = <%== "comments-for-#{@commentable.class.name.demodulize}-#{@commentable.id}".to_json %>;
3
3
  var $comments = $("#" + rootCommentableId);
4
4
  var config = $comments.data("decidim-comments");
@@ -25,3 +25,5 @@ $(() => {
25
25
  commentsIds: [commentId]
26
26
  });
27
27
  });
28
+
29
+ document.dispatchEvent(new CustomEvent("turbo:load"));
data/config/assets.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  base_path = File.expand_path("..", __dir__)
4
4
 
5
- Decidim::Webpacker.register_path("#{base_path}/app/packs")
6
- Decidim::Webpacker.register_entrypoints(
5
+ Decidim::Shakapacker.register_path("#{base_path}/app/packs")
6
+ Decidim::Shakapacker.register_entrypoints(
7
7
  decidim_comments: "#{base_path}/app/packs/entrypoints/decidim_comments.js"
8
8
  )