decidim-comments 0.28.5 → 0.29.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/comments/comment/actions.erb +4 -3
  3. data/app/cells/decidim/comments/comment/deletion_data.erb +1 -1
  4. data/app/cells/decidim/comments/comment/show.erb +3 -3
  5. data/app/cells/decidim/comments/comment_cell.rb +0 -2
  6. data/app/cells/decidim/comments/comment_form/opinion.erb +4 -4
  7. data/app/cells/decidim/comments/comment_form_cell.rb +0 -2
  8. data/app/cells/decidim/comments/comment_metadata_cell.rb +1 -1
  9. data/app/cells/decidim/comments/comments_cell.rb +0 -3
  10. data/app/cells/decidim/comments/edit_comment_modal_form_cell.rb +0 -1
  11. data/app/commands/decidim/comments/create_comment.rb +6 -6
  12. data/app/commands/decidim/comments/update_comment.rb +3 -4
  13. data/app/controllers/decidim/comments/comments_controller.rb +5 -3
  14. data/app/helpers/decidim/comments/comment_cells_helper.rb +1 -1
  15. data/app/models/decidim/comments/seed.rb +55 -5
  16. data/app/packs/entrypoints/decidim_comments.js +1 -1
  17. data/app/packs/src/decidim/comments/comments.component.js +8 -8
  18. data/app/packs/src/decidim/comments/comments.component.test.js +14 -14
  19. data/app/views/decidim/comments/comments/create.js.erb +2 -2
  20. data/app/views/decidim/comments/comments/delete.js.erb +5 -2
  21. data/app/views/decidim/comments/comments/update.js.erb +0 -6
  22. data/app/views/decidim/comments/votes/create.js.erb +1 -1
  23. data/config/locales/bg.yml +0 -1
  24. data/config/locales/ca.yml +2 -2
  25. data/config/locales/cs.yml +0 -6
  26. data/config/locales/de.yml +1 -2
  27. data/config/locales/en.yml +1 -1
  28. data/config/locales/es-MX.yml +1 -1
  29. data/config/locales/es-PY.yml +1 -1
  30. data/config/locales/es.yml +2 -2
  31. data/config/locales/eu.yml +16 -19
  32. data/config/locales/fi-plain.yml +1 -1
  33. data/config/locales/fi.yml +9 -9
  34. data/config/locales/fr-CA.yml +1 -1
  35. data/config/locales/fr.yml +1 -1
  36. data/config/locales/ja.yml +1 -1
  37. data/config/locales/pl.yml +1 -1
  38. data/config/locales/pt-BR.yml +0 -3
  39. data/config/locales/ro-RO.yml +8 -16
  40. data/config/locales/sv.yml +24 -42
  41. data/config/locales/tr-TR.yml +0 -1
  42. data/db/seeds.rb +1 -0
  43. data/decidim-comments.gemspec +2 -2
  44. data/lib/decidim/api/comment_type.rb +0 -13
  45. data/lib/decidim/api/commentable_interface.rb +1 -7
  46. data/lib/decidim/api/commentable_mutation_type.rb +2 -1
  47. data/lib/decidim/comments/commentable.rb +2 -2
  48. data/lib/decidim/comments/commentable_with_component.rb +1 -3
  49. data/lib/decidim/comments/query_extensions.rb +1 -1
  50. data/lib/decidim/comments/test/factories.rb +1 -1
  51. data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +3 -2
  52. data/lib/decidim/comments/version.rb +1 -1
  53. data/lib/tasks/upgrade/decidim_comments.rake +28 -0
  54. metadata +14 -16
  55. data/config/locales/bn-BD.yml +0 -1
  56. data/config/locales/bs-BA.yml +0 -15
  57. data/lib/tasks/decidim_comments.rake +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8df268a35db56cb108b71a7442761c7a6c74a3a53a4849c93d42111defbceefd
4
- data.tar.gz: 4083707523af88229f93f3efa583a9fd35ebae7f40aea143696831ffb1c27f30
3
+ metadata.gz: 3d55828915033b2a2a4a6443c316df98042bbbdc627f70c2d4bcf4ef9c983131
4
+ data.tar.gz: 247c5198c406f27a1ca6de26bcb8c2b8621b6789a4fd6aa92c2b4df4705d885f
5
5
  SHA512:
6
- metadata.gz: e23b591dc87c94a3bcab34da91347b04ddb48a529affb366e33075f3bda1dac4af608f47b9ae4fd0d2e970767c9d9a884020773144c5ef53989fd6ee1bbf30b5
7
- data.tar.gz: 34e686b75054282b6dab8f754056eef7ed08daefc81daebf0c33a6f8d62968f6b0ed52a8dff5cbe0b76996159f158e9da733918ed34308235c10d5438cc2680c
6
+ metadata.gz: 4ff6042bb9daf77d523c9d6ef46a4bf20d34cb726c2e9cd5d959877ead8491c498d987b46e9a64b1e865a25c62b9c1fe0f1f6d6be69f35f7b7b22537fdaba84d
7
+ data.tar.gz: 1da79ef396ae8c7e7bd4ccb96f8fc0e7f75af9b861f618efe09e41f608d11e9d36829fb299d705dfcd1479eaa05b519d6206145f0df0e774d7fa09f2a636a137
@@ -1,9 +1,10 @@
1
1
  <div class="comment__actions">
2
2
  <% if depth.zero? && has_replies_in_children? %>
3
- <button class="button button__sm button__text-secondary comment__hide" data-controls="comment-<%= model.id %>-replies" data-open="true" id="comment-<%= model.id %>-replies-trigger">
4
- <span class="show-comment-replies font-normal"><%= t("decidim.components.comment.show_replies", count: replies.size) %></span>
3
+ <button class="button button__sm button__text-secondary" data-comment-hide data-controls="comment-<%= model.id %>-replies" data-open="true" id="comment-<%= model.id %>-replies-trigger">
4
+ <%= icon "arrow-down-s-line" %>
5
+ <span data-show-comment-reply class="font-normal"><%= t("decidim.components.comment.show_replies", count: replies.size) %></span>
5
6
  <%= icon "arrow-up-s-line" %>
6
- <span class="hide-comment-replies font-normal"><%= t("decidim.components.comment.hide_replies", count: replies.size) %></span>
7
+ <span data-hide-comment-reply class="font-normal"><%= t("decidim.components.comment.hide_replies", count: replies.size) %></span>
7
8
  </button>
8
9
  <% end %>
9
10
  <% if can_reply? %>
@@ -1,6 +1,6 @@
1
1
  <%= render partial: "decidim/comments/comments/delete", formats: [:html], locals: { comment: model } %>
2
2
 
3
- <div class="comment__footer" data-component="accordion" id="accordion-<%= model.id %>">
3
+ <div data-comment-footer data-component="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 %>
@@ -11,7 +11,7 @@
11
11
  <%== cell("decidim/author", author_presenter) %>
12
12
  </span>
13
13
  <span class="text-gray-2 text-sm">
14
- <%= time_tag created_at, format: :decidim_short %>
14
+ <%= time_tag created_at, time_ago_in_words(created_at) %>
15
15
  </span>
16
16
  <% if edited? %>
17
17
  <span class="label">
@@ -63,13 +63,13 @@
63
63
  </div>
64
64
  </div>
65
65
 
66
- <div class="comment__footer" data-component="accordion" id="accordion-<%= model.id %>">
66
+ <div data-comment-footer data-component="accordion" id="accordion-<%= model.id %>">
67
67
  <div class="comment__footer-grid">
68
68
  <%= render :actions %>
69
69
  <%= votes %>
70
70
  </div>
71
71
  <% if can_reply? %>
72
- <div id="panel-<%= reply_id %>" class="add-comment comment__additionalreply">
72
+ <div id="panel-<%= reply_id %>" class="add-comment" data-additional-reply>
73
73
  <%== cell("decidim/comments/comment_form", model, root_depth:, order:) %>
74
74
  </div>
75
75
  <% end %>
@@ -4,8 +4,6 @@ module Decidim
4
4
  module Comments
5
5
  # A cell to display a single comment.
6
6
  class CommentCell < Decidim::ViewModel
7
- include ActionView::Helpers::DateHelper
8
- include Decidim::IconHelper
9
7
  include Decidim::ResourceHelper
10
8
  include Cell::ViewModel::Partial
11
9
 
@@ -1,15 +1,15 @@
1
1
  <div>
2
2
  <span class="comment__opinion-label"><%= t("decidim.components.add_comment_form.opinion.label") %></span>
3
- <div class="opinion-toggle comment__opinion-container">
4
- <button type="button" aria-pressed="false" class="opinion-toggle--ok" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.positive_selected") %>">
3
+ <div data-opinion-toggle class="comment__opinion-container">
4
+ <button type="button" aria-pressed="false" data-toggle-ok="true" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.positive_selected") %>">
5
5
  <span><%= t("decidim.components.comment.alignment.in_favor") %></span>
6
6
  <%= icon "thumb-up-line" %>
7
7
  </button>
8
- <button type="button" aria-pressed="true" class="opinion-toggle--meh is-active" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.neutral_selected") %>">
8
+ <button type="button" aria-pressed="true" class="is-active" data-toggle-meh="true" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.neutral_selected") %>">
9
9
  <span><%= t("decidim.components.add_comment_form.opinion.neutral") %></span>
10
10
  <%= icon "loader-3-line" %>
11
11
  </button>
12
- <button type="button" aria-pressed="false" class="opinion-toggle--ko" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.negative_selected") %>">
12
+ <button type="button" aria-pressed="false" data-toggle-ko="true" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.negative_selected") %>">
13
13
  <span><%= t("decidim.components.comment.alignment.against") %></span>
14
14
  <%= icon "thumb-down-line" %>
15
15
  </button>
@@ -4,8 +4,6 @@ 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
- delegate :current_user, :user_signed_in?, to: :controller
8
-
9
7
  def comment_as_for(form)
10
8
  return if verified_user_groups.blank?
11
9
 
@@ -14,7 +14,7 @@ module Decidim
14
14
 
15
15
  def commentable_item
16
16
  {
17
- text: decidim_html_escape(translated_attribute(root_commentable.title)),
17
+ text: decidim_escape_translated(root_commentable.title),
18
18
  icon: resource_type_icon_key(root_commentable.class)
19
19
  }
20
20
  end
@@ -4,10 +4,7 @@ module Decidim
4
4
  module Comments
5
5
  # A cell to display a comments section for a commentable object.
6
6
  class CommentsCell < Decidim::ViewModel
7
- include Decidim::IconHelper
8
-
9
7
  delegate :user_signed_in?, to: :controller
10
-
11
8
  def add_comment
12
9
  return if single_comment?
13
10
  return if comments_blocked?
@@ -4,7 +4,6 @@ module Decidim
4
4
  module Comments
5
5
  # A cell to display a form for editing a comment.
6
6
  class EditCommentModalFormCell < Decidim::ViewModel
7
- delegate :current_user, :user_signed_in?, to: :controller
8
7
  alias comment model
9
8
 
10
9
  private
@@ -4,12 +4,12 @@ module Decidim
4
4
  module Comments
5
5
  # A command with all the business logic to create a new comment
6
6
  class CreateComment < Decidim::Command
7
+ delegate :current_user, to: :form
7
8
  # Public: Initializes the command.
8
9
  #
9
10
  # form - A form object with the params.
10
- def initialize(form, author)
11
+ def initialize(form)
11
12
  @form = form
12
- @author = author
13
13
  end
14
14
 
15
15
  # Executes the command. Broadcasts these events:
@@ -30,13 +30,13 @@ module Decidim
30
30
 
31
31
  private
32
32
 
33
- attr_reader :form, :comment, :author
33
+ attr_reader :form, :comment
34
34
 
35
35
  def event_arguments
36
36
  {
37
37
  resource: comment,
38
38
  extra: {
39
- event_author: form.current_user,
39
+ event_author: current_user,
40
40
  locale:
41
41
  }
42
42
  }
@@ -46,7 +46,7 @@ module Decidim
46
46
  parsed = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization)
47
47
 
48
48
  params = {
49
- author:,
49
+ author: current_user,
50
50
  commentable: form.commentable,
51
51
  root_commentable: root_commentable(form.commentable),
52
52
  body: { I18n.locale => parsed.rewrite },
@@ -57,7 +57,7 @@ module Decidim
57
57
 
58
58
  @comment = Decidim.traceability.create!(
59
59
  Comment,
60
- author,
60
+ current_user,
61
61
  params,
62
62
  visibility: "public-only"
63
63
  )
@@ -4,14 +4,13 @@ module Decidim
4
4
  module Comments
5
5
  # A command with all the business logic to update an existing comment
6
6
  class UpdateComment < Decidim::Command
7
+ delegate :current_user, to: :form
7
8
  # Public: Initializes the command.
8
9
  #
9
10
  # comment - Decidim::Comments::Comment
10
- # current_user - Decidim::User
11
11
  # form - A form object with the params.
12
- def initialize(comment, current_user, form)
12
+ def initialize(comment, form)
13
13
  @comment = comment
14
- @current_user = current_user
15
14
  @form = form
16
15
  end
17
16
 
@@ -33,7 +32,7 @@ module Decidim
33
32
 
34
33
  private
35
34
 
36
- attr_reader :form, :comment, :current_user
35
+ attr_reader :form, :comment
37
36
 
38
37
  def event_arguments
39
38
  {
@@ -53,10 +53,11 @@ module Decidim
53
53
  form = Decidim::Comments::CommentForm.from_params(
54
54
  params.merge(commentable: comment.commentable)
55
55
  ).with_context(
56
+ current_user:,
56
57
  current_organization:
57
58
  )
58
59
 
59
- Decidim::Comments::UpdateComment.call(comment, current_user, form) do
60
+ Decidim::Comments::UpdateComment.call(comment, form) do
60
61
  on(:ok) do
61
62
  respond_to do |format|
62
63
  format.js { render :update }
@@ -78,9 +79,10 @@ module Decidim
78
79
  params.merge(commentable:)
79
80
  ).with_context(
80
81
  current_organization:,
81
- current_component:
82
+ current_component:,
83
+ current_user:
82
84
  )
83
- Decidim::Comments::CreateComment.call(form, current_user) do
85
+ Decidim::Comments::CreateComment.call(form) do
84
86
  on(:ok) do |comment|
85
87
  handle_success(comment)
86
88
  respond_to do |format|
@@ -22,7 +22,7 @@ module Decidim
22
22
  delegate :root_commentable, to: :comment
23
23
 
24
24
  def root_commentable_title
25
- decidim_html_escape(translated_attribute(root_commentable.title))
25
+ decidim_escape_translated(root_commentable.title)
26
26
  end
27
27
 
28
28
  def url_params
@@ -9,7 +9,7 @@ module Decidim
9
9
  class << self
10
10
  # Adds a random amount of comments for a given resource.
11
11
  #
12
- # @param resource [Object] - the Decidim resource to add the coments to.
12
+ # @param resource [Object] - the Decidim resource to add the comments to.
13
13
  # examples: Decidim::Proposals::CollaborativeDraft, Decidim::Proposals::Proposal,
14
14
  #
15
15
  # @return nil
@@ -18,14 +18,28 @@ module Decidim
18
18
 
19
19
  Decidim::Comments::Comment.reset_column_information
20
20
 
21
+ @organization = resource.organization
22
+
21
23
  rand(0..6).times do
22
- comment = create_comment(resource)
23
- create_comment(comment, resource) if [true, false].sample
24
+ comment1 = create_comment(resource)
25
+ NewCommentNotificationCreator.new(comment1, [], []).create
26
+
27
+ if [true, false].sample
28
+ comment2 = create_comment(comment1, resource)
29
+ NewCommentNotificationCreator.new(comment2, [], []).create
30
+ end
31
+
32
+ next if [true, false].sample
33
+
34
+ create_votes(comment1) if comment1
35
+ create_votes(comment2) if comment2
24
36
  end
25
37
  end
26
38
 
27
39
  private
28
40
 
41
+ attr_reader :organization
42
+
29
43
  # Creates a comment for a given resource.
30
44
  #
31
45
  # @private
@@ -35,8 +49,8 @@ module Decidim
35
49
  #
36
50
  # @return [Decidim::Comments::Comment]
37
51
  def create_comment(resource, root_commentable = nil)
38
- author = Decidim::User.where(organization: resource.organization).all.sample
39
- user_group = [true, false].sample ? Decidim::UserGroups::ManageableUserGroups.for(author).verified.sample : nil
52
+ author = random_user
53
+ user_group = random_user_group(author)
40
54
 
41
55
  params = {
42
56
  commentable: resource,
@@ -53,6 +67,42 @@ module Decidim
53
67
  visibility: "public-only"
54
68
  )
55
69
  end
70
+
71
+ # Creates a random amount of votes for a given comment.
72
+ # The votes can be from a user or a user group.
73
+ #
74
+ # @private
75
+ #
76
+ # @param [Decidim::Comments::Comment]
77
+ #
78
+ # @return nil
79
+ def create_votes(comment)
80
+ rand(0..12).times do
81
+ user = random_user
82
+ user_group = random_user_group(user)
83
+ author = [user, user_group].compact.sample
84
+ next if CommentVote.where(comment:, author:).any?
85
+
86
+ CommentVote.create!(comment:, author:, weight: [1, -1].sample)
87
+ end
88
+
89
+ nil
90
+ rescue ActiveRecord::AssociationTypeMismatch
91
+ nil # in case there is a mismatch, we ignore the error as it is not important for the seeding
92
+ end
93
+
94
+ def random_user
95
+ user = Decidim::User.where(organization:).not_deleted.not_blocked.confirmed.sample
96
+
97
+ user.valid? ? user : random_user
98
+ 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
56
106
  end
57
107
  end
58
108
  end
@@ -1,5 +1,5 @@
1
1
  // CSS
2
2
  import "stylesheets/comments.scss"
3
3
 
4
- // Javacript
4
+ // JavaScript
5
5
  import "src/decidim/comments/comments"
@@ -2,7 +2,7 @@
2
2
  /* eslint max-lines: ["error", {"max": 350, "skipBlankLines": true}] */
3
3
 
4
4
  /**
5
- * A plain Javascript component that handles the comments.
5
+ * A plain JavaScript component that handles the comments.
6
6
  *
7
7
  * @class
8
8
  * @augments Component
@@ -56,7 +56,7 @@ export default class CommentsComponent {
56
56
  this.mounted = false;
57
57
  this._stopPolling();
58
58
 
59
- $(".add-comment .opinion-toggle button", this.$element).off("click.decidim-comments");
59
+ $(".add-comment [data-opinion-toggle] button", this.$element).off("click.decidim-comments");
60
60
  $(".add-comment textarea", this.$element).off("input.decidim-comments");
61
61
  $(".add-comment form", this.$element).off("submit.decidim-comments");
62
62
  $(".add-comment textarea", this.$element).each((_i, el) => el.removeEventListener("emoji.added", this._onTextInput));
@@ -117,7 +117,7 @@ export default class CommentsComponent {
117
117
  $(".add-comment", $parent).each((_i, el) => {
118
118
  const $add = $(el);
119
119
  const $form = $("form", $add);
120
- const $opinionButtons = $(".opinion-toggle button", $add);
120
+ const $opinionButtons = $("[data-opinion-toggle] button", $add);
121
121
  const $text = $("textarea", $form);
122
122
 
123
123
  $opinionButtons.on("click.decidim-comments", this._onToggleOpinion);
@@ -280,18 +280,18 @@ export default class CommentsComponent {
280
280
 
281
281
  const $add = $btn.closest(".add-comment");
282
282
  const $form = $("form", $add);
283
- const $opinionButtons = $(".opinion-toggle button", $add);
284
- const $selectedState = $(".opinion-toggle .selected-state", $add);
283
+ const $opinionButtons = $("[data-opinion-toggle] button", $add);
284
+ const $selectedState = $("[data-opinion-toggle] .selected-state", $add);
285
285
  const $alignment = $(".alignment-input", $form);
286
286
 
287
287
  $opinionButtons.removeClass("is-active").attr("aria-pressed", "false");
288
288
  $btn.addClass("is-active").attr("aria-pressed", "true");
289
289
 
290
- if ($btn.is(".opinion-toggle--ok")) {
290
+ if ($btn.data("toggleOk")) {
291
291
  $alignment.val(1);
292
- } else if ($btn.is(".opinion-toggle--meh")) {
292
+ } else if ($btn.data("toggleMeh")) {
293
293
  $alignment.val(0);
294
- } else if ($btn.is(".opinion-toggle--ko")) {
294
+ } else if ($btn.data("toggleKo")) {
295
295
  $alignment.val(-1);
296
296
  }
297
297
 
@@ -45,7 +45,7 @@ describe("CommentsComponent", () => {
45
45
  const spyOnAddComment = (methodToSpy) => {
46
46
  addComment.each((i) => {
47
47
  addComment[i].$ = $(addComment[i]);
48
- addComment[i].opinionToggles = $(".opinion-toggle button", addComment[i].$);
48
+ addComment[i].opinionToggles = $("[data-opinion-toggle] button", addComment[i].$);
49
49
  addComment[i].commentForm = $("form", addComment[i].$);
50
50
  addComment[i].commentTextarea = $("textarea", addComment[i].commentForm);
51
51
 
@@ -66,7 +66,7 @@ describe("CommentsComponent", () => {
66
66
  return orderLinks;
67
67
  } else if (jqSelector === ".add-comment" && parent.is(subject.$element)) {
68
68
  return addComment;
69
- } else if (jqSelector === ".add-comment .opinion-toggle button" && parent.is(subject.$element)) {
69
+ } else if (jqSelector === ".add-comment [data-opinion-toggle] button" && parent.is(subject.$element)) {
70
70
  return allToggles;
71
71
  } else if (jqSelector === ".add-comment textarea" && parent.is(subject.$element)) {
72
72
  return allTextareas;
@@ -75,7 +75,7 @@ describe("CommentsComponent", () => {
75
75
  }
76
76
  const addCommentsArray = addComment.toArray();
77
77
  for (let i = 0; i < addCommentsArray.length; i += 1) {
78
- if (jqSelector === ".opinion-toggle button" && parent.is(addCommentsArray[i].$)) {
78
+ if (jqSelector === "[data-opinion-toggle] button" && parent.is(addCommentsArray[i].$)) {
79
79
  return addCommentsArray[i].opinionToggles;
80
80
  } else if (jqSelector === "form" && parent.is(addCommentsArray[i].$)) {
81
81
  return addCommentsArray[i].commentForm;
@@ -102,7 +102,7 @@ describe("CommentsComponent", () => {
102
102
  </div>
103
103
 
104
104
  <div class="form__wrapper gap-2">
105
- <label class="show-for-sr" for="add-comment-${modelName}-${modelId}">
105
+ <label for="add-comment-${modelName}-${modelId}">
106
106
  Comment
107
107
  </label>
108
108
  <span class="emoji__container">
@@ -233,7 +233,7 @@ describe("CommentsComponent", () => {
233
233
  <div class="comment__content">
234
234
  <div><p>${content}</p></div>
235
235
  </div>
236
- <div class="comment__footer" data-component="accordion" role="presentation">
236
+ <div data-comment-footer data-component="accordion" role="presentation">
237
237
  <div class="comment__footer-grid">
238
238
  <div class="comment__actions">
239
239
  <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">
@@ -323,21 +323,21 @@ describe("CommentsComponent", () => {
323
323
  ${secondThread}
324
324
  </div>
325
325
  <div class="add-comment">
326
- <div class="opinion-toggle button-group comment__opinion-container">
327
- <span class="show-for-sr py-1.5">Your opinion about this topic</span>
328
- <button aria-pressed="false" class="button button__sm button__text-secondary opinion-toggle--ok" data-selected-label="Your opinion about this topic is positive">
326
+ <div data-opinion-toggle class="button-group comment__opinion-container">
327
+ <span class="py-1.5">Your opinion about this topic</span>
328
+ <button aria-pressed="false" class="button button__sm button__text-secondary" data-toggle-ok="true" data-selected-label="Your opinion about this topic is positive">
329
329
  <svg width="1em" height="1em" role="img" aria-hidden="true"><use href="/decidim-packs/media/images/remixicon.symbol-5540ed538fb6bd400d2a.svg#ri-thumb-up-line" tabindex="-1"></use></svg>
330
330
  <svg width="1em" height="1em" role="img" aria-hidden="true"><use href="/decidim-packs/media/images/remixicon.symbol-5540ed538fb6bd400d2a.svg#ri-thumb-up-fill" tabindex="-1"></use></svg>
331
- <span class="show-for-sr">Positive</span>
331
+ <span>Positive</span>
332
332
  </button>
333
- <button aria-pressed="true" class="button button__sm button__text-secondary opinion-toggle--meh is-active" data-selected-label="Your opinion about this topic is neutral">
334
- <span class="show-for-sr">Neutral
333
+ <button aria-pressed="true" class="button button__sm button__text-secondary is-active" data-toggle-meh="true" data-selected-label="Your opinion about this topic is neutral">
334
+ <span>Neutral
335
335
  </span>
336
336
  </button>
337
- <button aria-pressed="false" class="button button__sm button__text-secondary opinion-toggle--ko" data-selected-label="Your opinion about this topic is negative">
337
+ <button aria-pressed="false" class="button button__sm button__text-secondary" data-toggle-ko="true" data-selected-label="Your opinion about this topic is negative">
338
338
  <svg width="1em" height="1em" role="img" aria-hidden="true"><use href="/decidim-packs/media/images/remixicon.symbol-5540ed538fb6bd400d2a.svg#ri-thumb-down-line" tabindex="-1"></use></svg>
339
339
  <svg width="1em" height="1em" role="img" aria-hidden="true"><use href="/decidim-packs/media/images/remixicon.symbol-5540ed538fb6bd400d2a.svg#ri-thumb-down-fill" tabindex="-1"></use></svg>
340
- <span class="show-for-sr">Negative</span>
340
+ <span>Negative</span>
341
341
  </button>
342
342
  <div role="alert" aria-live="assertive" aria-atomic="true" class="selected-state sr-only"></div>
343
343
  </div>
@@ -371,7 +371,7 @@ describe("CommentsComponent", () => {
371
371
  addComment = $(".add-comment", subject.$element);
372
372
  orderLinks = $(".comment-order-by a.comment-order-by__item", subject.$element);
373
373
 
374
- allToggles = $(".add-comment .opinion-toggle .button", subject.$element);
374
+ allToggles = $(".add-comment [data-opinion-toggle] .button", subject.$element);
375
375
  allTextareas = $(".add-comment textarea", subject.$element);
376
376
  allForms = $(".add-comment form", subject.$element);
377
377
  });
@@ -8,8 +8,8 @@
8
8
  if (inReplyTo) {
9
9
  component.addReply(inReplyTo, commentHtml, true);
10
10
 
11
- var hideButton = $("#comment_" + <%= root_comment.id %>).find(".comment__hide").first();
12
- hideButton.find(".show-comment-replies").first().html('<%= t("decidim.components.comment.show_replies", count: Decidim::Comments::SortedComments.for(root_comment.reload).size) %>');
11
+ var hideButton = $("#comment_" + <%= root_comment.id %>).find("[data-comment-hide]").first();
12
+ hideButton.find("[data-show-comment-reply]").first().html('<%= t("decidim.components.comment.show_replies", count: Decidim::Comments::SortedComments.for(root_comment.reload).size) %>');
13
13
 
14
14
  } else {
15
15
  component.addThread(commentHtml, true);
@@ -5,11 +5,14 @@ $(() => {
5
5
  const $comment = $(`#comment_${commentId}`);
6
6
  const $commentReply = $(`#comment${commentId}-reply`);
7
7
  const $content = $("> .comment__content", $comment);
8
- const sectionsToDelete = ["header", "footer-grid", "reply", "additionalreply"];
8
+ const sectionsToDelete = ["footer-grid", "reply"];
9
9
 
10
10
  sectionsToDelete.forEach((section) => {
11
- $(`> .comment__${section}`, $comment).remove();
11
+ $(`#comment_${commentId} > [data-comment-footer] > .comment__${section}`).remove();
12
12
  });
13
+ $(`#comment_${commentId} > .comment__header`).remove();
14
+ $(`#comment_${commentId} > [data-additional-reply]`).remove();
15
+
13
16
  $commentReply.remove();
14
17
  $content.replaceWith(deleteDataHtml);
15
18
  Rails.fire(document, "comments:loaded", {
@@ -10,12 +10,6 @@ $(() => {
10
10
  var commentId = <%= @comment.id.to_json %>;
11
11
  var $comment = $("#comment_<%= @comment.id %>");
12
12
 
13
- var $edit_modal = document.getElementById(`editCommentModal${commentId}`)
14
-
15
- if ($edit_modal !== undefined) {
16
- $edit_modal.remove()
17
- }
18
-
19
13
  $comment.replaceWith(commentHtml);
20
14
 
21
15
  // Re-create the component
@@ -3,7 +3,7 @@
3
3
  var upVotes = <%= comment.up_votes.count.to_json %>;
4
4
  var downVotes = <%= comment.down_votes.count.to_json %>;
5
5
  var $comment = $("#comment_" + commentId);
6
- var $votes = $("> .comment__footer > .comment__footer-grid .comment__votes", $comment);
6
+ var $votes = $("> [data-comment-footer] > .comment__footer-grid .comment__votes", $comment);
7
7
  var $upVote = $(".js-comment__votes--up", $votes);
8
8
  var $downVote = $(".js-comment__votes--down", $votes);
9
9
 
@@ -39,7 +39,6 @@ bg:
39
39
  error: Възникна проблем с гласуването за коментара.
40
40
  components:
41
41
  add_comment_form:
42
- account_message: <a href="%{sign_in_url}">Влезте в профила си</a> или <a href="%{sign_up_url}">се регистрирайте</a>, за да добавите Вашия коментар.
43
42
  form:
44
43
  body:
45
44
  label: Коментар
@@ -39,7 +39,7 @@ ca:
39
39
  error: S'ha produït un error en votar el comentari.
40
40
  components:
41
41
  add_comment_form:
42
- account_message: Per afegir un comentari, <a href="%{sign_in_url}">inicia la teva sessió</a> o <a href="%{sign_up_url}">registra't</a>.
42
+ account_message: <a href="%{sign_in_url}">Inicia sessió</a> o <a href="%{sign_up_url}">crea un compte</a>per afegir el teu comentari.
43
43
  form:
44
44
  body:
45
45
  label: Comentari
@@ -137,7 +137,7 @@ ca:
137
137
  email_subject: Hi ha un nou comentari de %{author_name} en %{resource_title}
138
138
  notification_title: Hi ha un nou comentari per <a href="%{author_path}">%{author_name} %{author_nickname}</a> a <a href="%{resource_path}">%{resource_title}</a>.
139
139
  comment_created:
140
- email_intro: "Algú ha deixat un comentari a \"%{resource_title}\". Pots llegir el comentari a través del següent enllaç:"
140
+ email_intro: "S'ha comentat %{resource_title}. Pots llegir el comentari d'aquesta pàgina:"
141
141
  email_outro: Has rebut aquesta notificació perquè estàs seguint el comentari "%{resource_title}" o la seva autora. Pots deixar de seguir-la des de l'enllaç anterior.
142
142
  email_subject: Hi ha un nou comentari de %{author_name} a %{resource_title}
143
143
  notification_title: Hi ha un nou comentari de <a href="%{author_path}">%{author_name} %{author_nickname}</a> en <a href="%{resource_path}">%{resource_title}</a>
@@ -43,7 +43,6 @@ cs:
43
43
  error: Při hlasování o komentáři došlo k chybě.
44
44
  components:
45
45
  add_comment_form:
46
- account_message: <a href="%{sign_in_url}">Přihlaste se pomocí svého účtu</a> nebo se <a href="%{sign_up_url}">zaregistrujte</a> a přidejte svůj komentář.
47
46
  form:
48
47
  body:
49
48
  label: Komentář
@@ -78,11 +77,6 @@ cs:
78
77
  deleted_user: Vymazaný účastník
79
78
  edit: Upravit
80
79
  edited: Upraveno
81
- hide_replies:
82
- one: Skrýt odpověď
83
- few: Skrýt {count} odpovědi
84
- many: Skrýt {count} odpovědí
85
- other: Skrýt {count} odpovědí
86
80
  moderated_at: Komentář moderován dne %{date}
87
81
  reply: Odpověď
88
82
  report:
@@ -39,7 +39,6 @@ de:
39
39
  error: Beim Abstimmen des Kommentars sind Fehler aufgetreten.
40
40
  components:
41
41
  add_comment_form:
42
- account_message: <a href="%{sign_in_url}">Melden Sie sich mit Ihrem Konto an</a> oder <a href="%{sign_up_url}">registrieren Sie sich</a>, um Ihren Kommentar hinzuzufügen.
43
42
  form:
44
43
  body:
45
44
  label: Kommentar
@@ -87,7 +86,7 @@ de:
87
86
  details: Zusätzliche Kommentare
88
87
  reasons:
89
88
  does_not_belong: Enthält illegale Aktivitäten, Selbstmorddrohungen, persönliche Informationen oder etwas anderes, von dem Sie denken, dass es nicht auf %{organization_name} gehört.
90
- offensive: Enthält Formen von Rassismus, Sexismus, Verleumdungen, persönliche Angriffe, Morddrohungen, Selbstmordanträge oder andere Formen von seelischer Gewalt.
89
+ offensive: Enthält Rassismus, Sexismus, Verleumdungen, persönliche Angriffe, Morddrohungen, Selbstmordanträge oder jegliche Form von Hassreden.
91
90
  spam: Enthält Clickbait, Werbung, Scams oder Script Bots.
92
91
  title: Ungeeigneten Inhalt melden
93
92
  show_replies:
@@ -39,7 +39,7 @@ en:
39
39
  error: There was a problem voting the comment.
40
40
  components:
41
41
  add_comment_form:
42
- account_message: <a href="%{sign_in_url}">Log in with your account</a> or <a href="%{sign_up_url}">sign up</a> to add your comment.
42
+ account_message: <a href="%{sign_in_url}">Log in</a> or <a href="%{sign_up_url}">create an account</a> to add your comment.
43
43
  form:
44
44
  body:
45
45
  label: Comment
@@ -39,7 +39,7 @@ es-MX:
39
39
  error: Ha habido errores al votar el comentario.
40
40
  components:
41
41
  add_comment_form:
42
- account_message: Para añadir un comentario, <a href="%{sign_in_url}">inicia tu sesión </a> o <a href="%{sign_up_url}">regístrate</a>.
42
+ account_message: <a href="%{sign_in_url}">Inicia sesión</a> o <a href="%{sign_up_url}">crea una cuenta</a> para añadir tu comentario.
43
43
  form:
44
44
  body:
45
45
  label: Comentario
@@ -39,7 +39,7 @@ es-PY:
39
39
  error: Ha habido errores al votar el comentario.
40
40
  components:
41
41
  add_comment_form:
42
- account_message: Para añadir un comentario, <a href="%{sign_in_url}">inicia tu sesión </a> o <a href="%{sign_up_url}">regístrate</a>.
42
+ account_message: <a href="%{sign_in_url}">Inicia sesión</a> o <a href="%{sign_up_url}">crea una cuenta</a> para añadir tu comentario.
43
43
  form:
44
44
  body:
45
45
  label: Comentario