decidim-comments 0.27.4 → 0.28.0.rc5

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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/comments/comment/actions.erb +13 -7
  3. data/app/cells/decidim/comments/comment/alignment_badge.erb +1 -4
  4. data/app/cells/decidim/comments/comment/deletion_data.erb +9 -1
  5. data/app/cells/decidim/comments/comment/moderation_data.erb +1 -1
  6. data/app/cells/decidim/comments/comment/replies.erb +3 -0
  7. data/app/cells/decidim/comments/comment/show.erb +72 -35
  8. data/app/cells/decidim/comments/comment/votes.erb +14 -14
  9. data/app/cells/decidim/comments/comment_activity_cell.rb +11 -7
  10. data/app/cells/decidim/comments/comment_card_cell.rb +2 -2
  11. data/app/cells/decidim/comments/comment_cell.rb +5 -15
  12. data/app/cells/decidim/comments/comment_form/comment_as.erb +3 -3
  13. data/app/cells/decidim/comments/comment_form/opinion.erb +18 -0
  14. data/app/cells/decidim/comments/comment_form/show.erb +33 -16
  15. data/app/cells/decidim/comments/comment_form_cell.rb +11 -3
  16. data/app/cells/decidim/comments/comment_metadata_cell.rb +27 -0
  17. data/app/cells/decidim/comments/comment_s_cell.rb +27 -0
  18. data/app/cells/decidim/comments/comment_thread/show.erb +2 -5
  19. data/app/cells/decidim/comments/comment_thread_cell.rb +0 -6
  20. data/app/cells/decidim/comments/comments/add_comment.erb +1 -20
  21. data/app/cells/decidim/comments/comments/blocked_comments_warning.erb +1 -3
  22. data/app/cells/decidim/comments/comments/comments_loading.erb +1 -3
  23. data/app/cells/decidim/comments/comments/order_control.erb +11 -35
  24. data/app/cells/decidim/comments/comments/show.erb +8 -9
  25. data/app/cells/decidim/comments/comments/single_comment_warning.erb +6 -9
  26. data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +9 -6
  27. data/app/cells/decidim/comments/comments_cell.rb +1 -1
  28. data/app/cells/decidim/comments/edit_comment_modal_form/show.erb +20 -15
  29. data/app/commands/decidim/comments/create_comment.rb +17 -5
  30. data/app/commands/decidim/comments/delete_comment.rb +1 -1
  31. data/app/commands/decidim/comments/update_comment.rb +14 -2
  32. data/app/commands/decidim/comments/vote_comment.rb +1 -1
  33. data/app/controllers/decidim/comments/comments_controller.rb +14 -9
  34. data/app/controllers/decidim/comments/votes_controller.rb +1 -1
  35. data/app/events/decidim/comments/comment_by_followed_user_event.rb +1 -1
  36. data/app/events/decidim/comments/comment_by_followed_user_group_event.rb +1 -1
  37. data/app/events/decidim/comments/comment_event.rb +2 -3
  38. data/app/events/decidim/comments/reply_created_event.rb +1 -1
  39. data/app/events/decidim/comments/user_group_mentioned_event.rb +1 -1
  40. data/app/events/decidim/comments/user_mentioned_event.rb +1 -1
  41. data/app/helpers/decidim/comments/comment_cells_helper.rb +1 -1
  42. data/app/jobs/decidim/comments/hide_all_created_by_author_job.rb +13 -0
  43. data/app/models/decidim/comments/comment.rb +8 -4
  44. data/app/models/decidim/comments/seed.rb +30 -14
  45. data/app/packs/entrypoints/decidim_comments.js +5 -0
  46. data/app/packs/src/decidim/comments/comments.component.js +27 -36
  47. data/app/packs/src/decidim/comments/comments.component.test.js +218 -240
  48. data/app/packs/src/decidim/comments/comments.component_for_testing.js +1 -1
  49. data/app/packs/src/decidim/comments/comments.js +20 -1
  50. data/app/packs/stylesheets/comments.scss +327 -0
  51. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +1 -1
  52. data/app/queries/decidim/comments/sorted_comments.rb +10 -10
  53. data/app/services/decidim/comments/comment_creation.rb +1 -1
  54. data/app/services/decidim/comments/new_comment_notification_creator.rb +8 -8
  55. data/app/views/decidim/comments/admin/shared/_availability_fields.html.erb +4 -9
  56. data/app/views/decidim/comments/comments/_comment.html.erb +1 -1
  57. data/app/views/decidim/comments/comments/_comments.html.erb +1 -1
  58. data/app/views/decidim/comments/comments/_delete.html.erb +2 -4
  59. data/app/views/decidim/comments/comments/_moderated.html.erb +2 -4
  60. data/app/views/decidim/comments/comments/create.js.erb +5 -3
  61. data/app/views/decidim/comments/comments/delete.js.erb +4 -1
  62. data/app/views/decidim/comments/comments/index.js.erb +8 -1
  63. data/app/views/decidim/comments/comments/reload.js.erb +1 -2
  64. data/app/views/decidim/comments/comments/update.js.erb +5 -4
  65. data/app/views/decidim/comments/votes/create.js.erb +5 -5
  66. data/config/assets.rb +3 -0
  67. data/config/environment.rb +3 -0
  68. data/config/locales/ar.yml +0 -16
  69. data/config/locales/ca.yml +8 -10
  70. data/config/locales/cs.yml +8 -10
  71. data/config/locales/de.yml +6 -8
  72. data/config/locales/el.yml +3 -11
  73. data/config/locales/en.yml +10 -12
  74. data/config/locales/es-MX.yml +10 -12
  75. data/config/locales/es-PY.yml +10 -12
  76. data/config/locales/es.yml +9 -11
  77. data/config/locales/eu.yml +26 -28
  78. data/config/locales/fi-plain.yml +7 -9
  79. data/config/locales/fi.yml +7 -9
  80. data/config/locales/fr-CA.yml +9 -11
  81. data/config/locales/fr.yml +9 -11
  82. data/config/locales/ga-IE.yml +0 -4
  83. data/config/locales/gl.yml +0 -16
  84. data/config/locales/hu.yml +5 -11
  85. data/config/locales/id-ID.yml +0 -11
  86. data/config/locales/is-IS.yml +0 -8
  87. data/config/locales/it.yml +0 -16
  88. data/config/locales/ja.yml +10 -12
  89. data/config/locales/lb.yml +0 -16
  90. data/config/locales/lt.yml +12 -10
  91. data/config/locales/lv.yml +0 -11
  92. data/config/locales/nl.yml +0 -16
  93. data/config/locales/no.yml +0 -16
  94. data/config/locales/pl.yml +16 -10
  95. data/config/locales/pt-BR.yml +0 -16
  96. data/config/locales/pt.yml +0 -16
  97. data/config/locales/ro-RO.yml +2 -10
  98. data/config/locales/ru.yml +0 -11
  99. data/config/locales/sk.yml +0 -11
  100. data/config/locales/sq-AL.yml +1 -0
  101. data/config/locales/sv.yml +5 -16
  102. data/config/locales/th-TH.yml +1 -0
  103. data/config/locales/tr-TR.yml +1 -13
  104. data/config/locales/uk.yml +0 -8
  105. data/config/locales/zh-CN.yml +0 -13
  106. data/config/locales/zh-TW.yml +1 -9
  107. data/lib/decidim/api/commentable_interface.rb +1 -1
  108. data/lib/decidim/comments/comment_serializer.rb +2 -2
  109. data/lib/decidim/comments/comment_vote_serializer.rb +2 -2
  110. data/lib/decidim/comments/commentable.rb +1 -1
  111. data/lib/decidim/comments/comments_helper.rb +6 -3
  112. data/lib/decidim/comments/engine.rb +31 -1
  113. data/lib/decidim/comments/export.rb +1 -1
  114. data/lib/decidim/comments/test/factories.rb +2 -2
  115. data/lib/decidim/comments/test/shared_examples/comment_event.rb +3 -3
  116. data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +3 -3
  117. data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +5 -5
  118. data/lib/decidim/comments/test/shared_examples/has_comments_availability_attributes.rb +2 -2
  119. data/lib/decidim/comments/test/shared_examples/translatable_comment.rb +3 -3
  120. data/lib/decidim/comments/version.rb +1 -1
  121. metadata +28 -20
  122. data/app/cells/decidim/comments/comment/author.erb +0 -1
  123. data/app/cells/decidim/comments/comment/utilities.erb +0 -41
  124. data/app/cells/decidim/comments/comment_m/footer.erb +0 -5
  125. data/app/cells/decidim/comments/comment_m/top.erb +0 -7
  126. data/app/cells/decidim/comments/comment_m_cell.rb +0 -29
  127. data/app/cells/decidim/comments/comment_thread/title.erb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98316c17e51a4805c01a6e83a9e1a2ad76a5859b0013e9b78c569c49644da50c
4
- data.tar.gz: 05ed7977b512e18df994f8b4a88665ed0889debfacb57f991486bc78b4962f44
3
+ metadata.gz: b6a254be1ac8bf24f7fc9608b97a9212e93ec750fa825794f6b8b361c1afe052
4
+ data.tar.gz: e088ee5671aa8058a320d939114b7e74d092226ab3728aeb5c81fbccfd096259
5
5
  SHA512:
6
- metadata.gz: 5af106aa754874a212337f353d8bdddde35e09f6894dd678cb85353de237e1cf681e9914b189fdddf1c8f7e8e4dd86fb7301879426641cc1b09de0aaa6d7f660
7
- data.tar.gz: 828e037c123045bfa0bed0e39a65891a0f67eb39f712d03a74d11f512d533721b4fbf63c49d7b76e5686951c90c8cc241e58aca0e23a50b0958e519d0bb5117a
6
+ metadata.gz: 11b9f841442bc8cbb72308384d86572b02b9c1800278a0a89d1816c6c8fce9689bd5c70fcc0858612a444110c01e411dd70f69b118eebea0f5ba5c9e493be01e
7
+ data.tar.gz: ca06d10370897dfdda7a142d487d5bb8dd1a21d204f6b738e0adcb28e438cca92dd6cee9f381477a58a94bf8dc71db9a0d6a385e72e9da3ee4045ed97e53a37b
@@ -1,12 +1,18 @@
1
1
  <div class="comment__actions">
2
- <button class="comment__hide muted-link <%= depth.zero? && has_replies_in_children? ? "" : "hide" %>" aria-controls="comment-<%= model.id %>-replies" data-toggle="comment_<%= model.id %>">
3
- <%= icon "comment-square", class: "icon--small", role: "img", "aria-hidden": true %>&nbsp;
4
- <span class="hide-comment-replies"><%= t("decidim.components.comment.hide_replies") %></span>
5
- <span class="show-comment-replies"><%= t("decidim.components.comment.show_replies", count: replies.size, replies_count: replies.size ) %></span>
6
- </button>
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">
4
+ <%= icon "arrow-up-s-line" %>
5
+ <span class="hide-comment-replies font-normal"><%= t("decidim.components.comment.hide_replies") %></span>
6
+ <%= icon "arrow-down-s-line" %>
7
+ <span class="show-comment-replies font-normal"><%= t("decidim.components.comment.show_replies", count: replies.size, replies_count: replies.size ) %></span>
8
+ </button>
9
+ <% end %>
7
10
  <% if can_reply? %>
8
- <button class="comment__reply muted-link" aria-controls="<%= reply_id %>" data-toggle="<%= reply_id %>">
9
- <%= icon "pencil", class: "icon--small", role: "img", "aria-hidden": true %>&nbsp;<%= t("decidim.components.comment.reply") %>
11
+ <button class="button button__sm button__text-secondary" data-controls="panel-<%= reply_id %>">
12
+ <%= icon "chat-1-line" %>
13
+ <span class="font-normal"><%= t("decidim.components.comment.reply") %></span>
14
+ <%= icon "close-circle-line" %>
15
+ <span class="font-normal"><%= t("decidim.components.comment.cancel_reply") %></span>
10
16
  </button>
11
17
  <% end %>
12
18
  </div>
@@ -1,4 +1 @@
1
- <span>
2
- <span class="<%= alignment_badge_classes %>"><%= alignment_badge_label %></span>
3
- &nbsp;
4
- </span>
1
+ <span class="<%= alignment_badge_classes %> comment__content--label"><%= alignment_badge_label %></span>
@@ -1 +1,9 @@
1
- <%= render partial: "decidim/comments/comments/delete.html", locals: { comment: model } %>
1
+ <%= render partial: "decidim/comments/comments/delete", formats: [:html], locals: { comment: model } %>
2
+
3
+ <div class="comment__footer" data-component="accordion" id="accordion-<%= model.id %>">
4
+ <div id="comment-<%= model.id %>-replies" class="<%= "comment-reply" if has_replies_in_children? %>">
5
+ <% if has_replies_in_children? %>
6
+ <%= render :replies %>
7
+ <% end %>
8
+ </div>
9
+ </div>
@@ -1 +1 @@
1
- <%= render partial: "decidim/comments/comments/moderated.html", locals: { comment: model } %>
1
+ <%= render partial: "decidim/comments/comments/moderated", formats: [:html], locals: { comment: model } %>
@@ -0,0 +1,3 @@
1
+ <% replies.each do |reply| %>
2
+ <%= cell("decidim/comments/comment", reply, root_depth: , order: , reloaded: reloaded?) %>
3
+ <% end %>
@@ -1,51 +1,88 @@
1
- <%= content_tag :div, id: "comment_#{model.id}", class: comment_classes, data: { depth: model.depth, comment_id: model.id, toggler: ".no-comments" } do %>
1
+ <%= content_tag :div, id: "comment_#{model.id}", class: "comment relative", data: { comment_id: model.id } do %>
2
2
  <% if model.hidden? %>
3
3
  <%= render :moderation_data %>
4
4
  <% elsif model.deleted? %>
5
5
  <%= render :deletion_data %>
6
6
  <% else %>
7
7
  <div class="comment__header">
8
- <div class="author-data">
9
- <div class="author-data__main">
10
- <%= render :author %>
11
- <span>
12
- <%= time_tag created_at, l(created_at, format: :decidim_short) %>
13
- </span>
14
- <% if edited? %>
15
- <div class="author-data__extra">
16
- <span class="comment__edited">
17
- <%= t("decidim.components.comment.edited") %>
18
- </span>
19
- </div>
20
- <% end %>
8
+ <span class="font-bold">
9
+ <%== cell("decidim/author", author_presenter) %>
10
+ </span>
11
+ <span class="text-gray-2 text-sm">
12
+ <%= time_tag created_at, time_ago_in_words(created_at) %>
13
+ </span>
14
+ <% if edited? %>
15
+ <span class="label">
16
+ <%= t("decidim.components.comment.edited") %>
17
+ </span>
18
+ <% end %>
19
+
20
+ <div class="relative ml-auto">
21
+ <button id="dropdown-trigger-<%= context_menu_id %>" data-component="dropdown" data-target="dropdown-menu-<%= context_menu_id %>">
22
+ &#8230;
23
+ </button>
24
+
25
+ <div id="dropdown-menu-<%= context_menu_id %>" aria-hidden="true">
26
+ <ul class="dropdown dropdown__bottom divide-y divide-gray-3 px-4">
27
+ <% unless reloaded? %>
28
+ <li>
29
+ <%= cell("decidim/report_button", model, only_button: true, button_classes: "dropdown__item flex-row-reverse", modal_id: "flagModalComment#{model.id}") %>
30
+ </li>
31
+ <% end %>
32
+ <li>
33
+ <%= link_to "#{commentable_path("commentId" => model.id)}#comment_#{model.id}", target: "_blank", data: { "external-link": "false" }, class: "dropdown__item", title: t("decidim.components.comment.single_comment_link_title") do %>
34
+ <%= icon "share-line" %>
35
+ <span><%= t("decidim.components.comment.single_comment_link_title") %></span>
36
+ <% end %>
37
+ </li>
38
+ <% if model.authored_by?(current_user) %>
39
+ <li>
40
+ <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" tabindex="2">
41
+ <%= icon "edit-line" %>
42
+ <span><%= t("decidim.components.comment.edit") %></span>
43
+ </button>
44
+ </li>
45
+ <li>
46
+ <%= link_to comment_path, remote: true, method: :delete, class: "dropdown__item", data: { confirm: t("decidim.components.comment.confirm_destroy") }, tabindex: 3 do %>
47
+ <%= icon "delete-bin-line" %>
48
+ <span><%= t("decidim.components.comment.delete") %></span>
49
+ <% end %>
50
+ </li>
51
+ <% end %>
52
+ </ul>
21
53
  </div>
22
54
  </div>
23
- <%= render :utilities %>
24
55
  </div>
56
+
25
57
  <div class="comment__content">
26
58
  <%= alignment_badge %>
27
- <%= comment_body %>
28
- </div>
29
- <div class="comment__footer">
30
- <%= render :actions %>
31
- <%= votes %>
59
+ <div class="editor-content">
60
+ <%= comment_body %>
61
+ </div>
32
62
  </div>
33
- <% end %>
34
- <div id="comment-<%= model.id %>-replies" class="replies">
35
- <% if has_replies_in_children? %>
36
- <% replies.each do |reply| %>
37
- <%= cell("decidim/comments/comment", reply, root_depth: root_depth, order: order, reloaded: reloaded?) %>
63
+
64
+ <div class="comment__footer" data-component="accordion" id="accordion-<%= model.id %>">
65
+ <div class="comment__footer-grid">
66
+ <%= render :actions %>
67
+ <%= votes %>
68
+ </div>
69
+ <% if can_reply? %>
70
+ <div id="panel-<%= reply_id %>" class="add-comment comment__additionalreply">
71
+ <%== cell("decidim/comments/comment_form", model, root_depth:, order:) %>
72
+ </div>
38
73
  <% end %>
39
- <% end %>
40
- </div>
41
- <% if can_reply? %>
42
- <div class="comment__additionalreply<%= " hide" unless commentable? %> replies">
43
- <button class="comment__reply muted-link" aria-controls="<%= reply_id %>" data-toggle="<%= reply_id %>">
44
- <%= icon "pencil", class: "icon--small", role: "img", "aria-hidden": true %>&nbsp;<%= t("decidim.components.comment.reply") %>
45
- </button>
46
- </div>
47
- <div class="add-comment hide" id="<%= reply_id %>" data-toggler=".hide">
48
- <%== cell("decidim/comments/comment_form", model, root_depth: root_depth, order: order) %>
74
+ <div id="comment-<%= model.id %>-replies" class="<%= "comment-reply" if has_replies_in_children? %>">
75
+ <% if has_replies_in_children? %>
76
+ <%= render :replies %>
77
+ <% end %>
78
+ </div>
49
79
  </div>
50
80
  <% end %>
81
+ <% if current_user.present? %>
82
+ <%= cell("decidim/report_button", model, modal_id: "flagModalComment#{model.id}").flag_modal %>
83
+ <% end %>
84
+
85
+ <% if model.authored_by?(current_user) %>
86
+ <%= cell("decidim/comments/edit_comment_modal_form", model) %>
87
+ <% end %>
51
88
  <% end %>
@@ -1,25 +1,25 @@
1
1
  <div class="comment__votes">
2
2
  <% if user_signed_in? %>
3
3
  <%= vote_button_to decidim_comments.comment_votes_path(model, weight: 1), remote: true, disabled: voted_down?, class: votes_up_classes, title: t("decidim.components.up_vote_button.text") do %>
4
- <span class="show-for-sr"><%= t("decidim.components.up_vote_button.text") %></span>
5
- <%= icon "chevron-top", class: "icon--small", role: "img", "aria-hidden": true %>
6
- <span class="comment__votes--count"><%= up_votes_count %></span>
4
+ <%= icon "thumb-up-line" %>
5
+ <%= icon "thumb-up-fill" %>
6
+ <span><%= up_votes_count %></span>
7
7
  <% end %>
8
8
  <%= vote_button_to decidim_comments.comment_votes_path(model, weight: -1), remote: true, disabled: voted_up?, class: votes_down_classes, title: t("decidim.components.down_vote_button.text") do %>
9
- <span class="show-for-sr"><%= t("decidim.components.down_vote_button.text") %></span>
10
- <%= icon "chevron-bottom", class: "icon--small", role: "img", "aria-hidden": true %>
11
- <span class="comment__votes--count"><%= down_votes_count %></span>
9
+ <%= icon "thumb-down-line" %>
10
+ <%= icon "thumb-down-fill" %>
11
+ <span><%= down_votes_count %></span>
12
12
  <% end %>
13
13
  <% else %>
14
- <button class="<%= votes_up_classes %> " title="<%= t("decidim.components.up_vote_button.text") %>" data-open="loginModal">
15
- <span class="show-for-sr"><%= t("decidim.components.up_vote_button.text") %></span>
16
- <%= icon "chevron-top", class: "icon--small", role: "img", "aria-hidden": true %>
17
- <span class="comment__votes--count"><%= up_votes_count %></span>
14
+ <button class="<%= votes_up_classes %> " title="<%= t("decidim.components.up_vote_button.text") %>" data-dialog-open="loginModal">
15
+ <%= icon "thumb-up-line", class: "fill-secondary" %>
16
+ <%= icon "thumb-up-fill", class: "fill-secondary" %>
17
+ <span><%= up_votes_count %></span>
18
18
  </button>
19
- <button class="<%= votes_down_classes %> " title="<%= t("decidim.components.down_vote_button.text") %>" data-open="loginModal">
20
- <span class="show-for-sr"><%= t("decidim.components.down_vote_button.text") %></span>
21
- <%= icon "chevron-bottom", class: "icon--small", role: "img", "aria-hidden": true %>
22
- <span class="comment__votes--count"><%= down_votes_count %></span>
19
+ <button class="<%= votes_down_classes %> " title="<%= t("decidim.components.down_vote_button.text") %>" data-dialog-open="loginModal">
20
+ <%= icon "thumb-down-line", class: "fill-secondary" %>
21
+ <%= icon "thumb-down-fill", class: "fill-secondary" %>
22
+ <span><%= down_votes_count %></span>
23
23
  </button>
24
24
  <% end %>
25
25
  </div>
@@ -7,19 +7,23 @@ module Decidim
7
7
  include CommentCellsHelper
8
8
 
9
9
  def title
10
- I18n.t(
11
- "decidim.comments.last_activity.new_comment_at_html",
12
- link: link_to(
13
- root_commentable_title,
14
- resource_link_path
15
- )
16
- )
10
+ I18n.t("decidim.comments.last_activity.new_comment")
17
11
  end
18
12
 
19
13
  def participatory_space
20
14
  model.participatory_space_lazy
21
15
  end
22
16
 
17
+ def participatory_space_link
18
+ link_to(root_commentable_title, resource_link_path)
19
+ end
20
+
21
+ def participatory_space_icon
22
+ resource_type_icon(root_commentable.class)
23
+ end
24
+
25
+ def hide_participatory_space? = false
26
+
23
27
  def comment
24
28
  model.resource_lazy
25
29
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Comments
5
5
  # This cell renders the comment card for an instance of a Comment
6
- # the default size is the Medium Card (:m)
6
+ # the default size is the Search Card (:s)
7
7
  class CommentCardCell < Decidim::ViewModel
8
8
  include CommentCellsHelper
9
9
  include Cell::ViewModel::Partial
@@ -15,7 +15,7 @@ module Decidim
15
15
  private
16
16
 
17
17
  def card_size
18
- "decidim/comments/comment_m"
18
+ "decidim/comments/comment_s"
19
19
  end
20
20
  end
21
21
  end
@@ -91,15 +91,6 @@ module Decidim
91
91
  end
92
92
  end
93
93
 
94
- def comment_classes
95
- classes = ["comment"]
96
- if nested?
97
- classes << "comment--nested"
98
- classes << "comment--nested--alt" if nested_level_even?
99
- end
100
- classes.join(" ")
101
- end
102
-
103
94
  def alignment_badge_classes
104
95
  classes = %w(label alignment)
105
96
  case alignment
@@ -120,14 +111,14 @@ module Decidim
120
111
  end
121
112
 
122
113
  def votes_up_classes
123
- classes = ["comment__votes--up"]
114
+ classes = ["button button__sm button__text-secondary js-comment__votes--up"]
124
115
  classes << "is-vote-selected" if voted_up?
125
116
  classes << "is-vote-notselected" if voted_down?
126
117
  classes.join(" ")
127
118
  end
128
119
 
129
120
  def votes_down_classes
130
- classes = ["comment__votes--down"]
121
+ classes = ["button button__sm button__text-secondary js-comment__votes--down"]
131
122
  classes << "is-vote-selected" if voted_down?
132
123
  classes << "is-vote-notselected" if voted_up?
133
124
  classes.join(" ")
@@ -198,13 +189,12 @@ module Decidim
198
189
  root_commentable.try(:component)
199
190
  end
200
191
 
201
- def vote_button_to(path, params, &block)
192
+ def vote_button_to(path, params, &)
202
193
  # actions are linked to objects belonging to a component
203
- # In consultations, a question belong to a participatory_space but it has comments
204
194
  # To apply :comment permission, the modal authorizer should be refactored to allow participatory spaces-level comments
205
- return button_to(path, params, &block) unless current_component
195
+ return button_to(path, params, &) unless current_component
206
196
 
207
- action_authorized_button_to(:vote_comment, path, params.merge(resource: root_commentable), &block)
197
+ action_authorized_button_to(:vote_comment, path, params.merge(resource: root_commentable), &)
208
198
  end
209
199
  end
210
200
  end
@@ -1,8 +1,8 @@
1
- <div class="field">
2
- <label for="<%= comment_as_id %>">
1
+ <div class="comment__as">
2
+ <label class="mr-2 inline-block" for="<%= comment_as_id %>">
3
3
  <%= t("decidim.components.add_comment_form.form.user_group_id.label") %>
4
4
  </label>
5
- <select id="<%= comment_as_id %>" name="comment[user_group_id]">
5
+ <select class="p-2" id="<%= comment_as_id %>" name="comment[user_group_id]">
6
6
  <% comment_as_options.each do |option| %>
7
7
  <option value="<%= option[1] %>"><%= option[0] %></option>
8
8
  <% end %>
@@ -0,0 +1,18 @@
1
+ <div>
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") %>">
5
+ <span><%= t("decidim.components.comment.alignment.in_favor") %></span>
6
+ <%= icon "thumb-up-line" %>
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") %>">
9
+ <span><%= t("decidim.components.add_comment_form.opinion.neutral") %></span>
10
+ <%= icon "loader-3-line" %>
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") %>">
13
+ <span><%= t("decidim.components.comment.alignment.against") %></span>
14
+ <%= icon "thumb-down-line" %>
15
+ </button>
16
+ <div role="alert" aria-live="assertive" aria-atomic="true" class="selected-state sr-only"></div>
17
+ </div>
18
+ </div>
@@ -1,24 +1,41 @@
1
- <%= form_for(form_object, url: decidim_comments.comments_path(order: order), method: :post, remote: true, html: { id: form_id }) do |form| %>
1
+ <%= form_for(form_object, url: decidim_comments.comments_path(order:), method: :post, remote: true, html: { id: form_id }) do |form| %>
2
2
  <%= form.hidden_field :commentable_gid, id: nil %>
3
3
  <%= form.hidden_field :alignment, id: nil, class: "alignment-input" %>
4
4
  <%= comment_as_for(form) %>
5
- <div class="field">
6
- <label class="show-for-sr" for="<%= add_comment_id %>">
5
+
6
+ <div class="flex justify-between items-end mb-4">
7
+ <label class="comment__form-label" for="<%= add_comment_id %>">
7
8
  <%= t("decidim.components.add_comment_form.form.body.label") %>
8
9
  </label>
9
- <div class="hashtags__container">
10
- <%= form.text_area(
11
- :body,
12
- id: add_comment_id,
13
- rows: 4,
14
- maxlength: comments_max_length,
15
- required: true,
16
- placeholder: t("decidim.components.add_comment_form.form.body.placeholder"),
17
- label: false,
18
- data: { remaining_characters: "##{add_comment_id}-remaining-characters", input_emoji: true }
19
- ) %>
20
- </div>
21
- <button type="submit" class="button button--sc" disabled="disabled"><%= t("decidim.components.add_comment_form.form.submit") %></button>
10
+
22
11
  <span id="<%= add_comment_id %>-remaining-characters" class="remaining-character-count"></span>
23
12
  </div>
13
+
14
+ <%= form.text_area(
15
+ :body,
16
+ id: add_comment_id,
17
+ class: "w-full min-h-[160px]",
18
+ maxlength: comments_max_length,
19
+ required: true,
20
+ placeholder: t("decidim.components.add_comment_form.form.body.placeholder"),
21
+ label: false,
22
+ data: { remaining_characters: "##{add_comment_id}-remaining-characters", input_emoji: true }
23
+ ) %>
24
+
25
+ <div class="comment__form-submit">
26
+ <% if alignment_enabled? %>
27
+ <%= render :opinion %>
28
+ <% end %>
29
+
30
+ <button type="submit" class="button button__sm button__secondary" disabled="disabled">
31
+ <span>
32
+ <% if reply? %>
33
+ <%= t("decidim.components.add_comment_form.form.submit_reply") %>
34
+ <% else %>
35
+ <%= t("decidim.components.add_comment_form.form.submit_root_comment") %>
36
+ <% end %>
37
+ </span>
38
+ <%= icon "chat-1-line" %>
39
+ </button>
40
+ </div>
24
41
  <% end %>
@@ -12,7 +12,7 @@ module Decidim
12
12
  # Note that the form.select does not seem to work correctly in the cell
13
13
  # context. The Rails form builder tries to call @template.select which
14
14
  # is not available for the cell objects.
15
- render view: :comment_as, locals: { form: form }
15
+ render view: :comment_as, locals: { form: }
16
16
  end
17
17
 
18
18
  private
@@ -38,6 +38,14 @@ module Decidim
38
38
  model.commentable_type
39
39
  end
40
40
 
41
+ def reply?
42
+ model.is_a?(Decidim::Comments::Comment)
43
+ end
44
+
45
+ def alignment_enabled?
46
+ model.comments_have_alignment?
47
+ end
48
+
41
49
  def form_id
42
50
  "new_comment_for_#{commentable_type.demodulize}_#{model.id}"
43
51
  end
@@ -84,13 +92,13 @@ module Decidim
84
92
  def component_comments_max_length
85
93
  return unless model.component&.settings.respond_to?(:comments_max_length)
86
94
 
87
- model.component.settings.comments_max_length if model.component.settings.comments_max_length.positive?
95
+ model.component.settings.comments_max_length if model.component.settings.comments_max_length.to_i.positive?
88
96
  end
89
97
 
90
98
  def organization_comments_max_length
91
99
  return unless organization
92
100
 
93
- organization.comments_max_length if organization.comments_max_length.positive?
101
+ organization.comments_max_length if organization.comments_max_length.to_i.positive?
94
102
  end
95
103
 
96
104
  def organization
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Comments
5
+ # This cell renders the comment metadata for a card
6
+ class CommentMetadataCell < Decidim::CardMetadataCell
7
+ delegate :root_commentable, to: :model
8
+
9
+ private
10
+
11
+ def items
12
+ [author_item, commentable_item, comments_count_item]
13
+ end
14
+
15
+ def commentable_item
16
+ {
17
+ text: decidim_html_escape(translated_attribute(root_commentable.title)),
18
+ icon: resource_type_icon_key(root_commentable.class)
19
+ }
20
+ end
21
+
22
+ def comments_count_item
23
+ super(root_commentable)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Comments
5
+ # This cell renders the Search (:s) comment card
6
+ # for a given instance of a Comment
7
+ class CommentSCell < Decidim::CardSCell
8
+ include CommentCellsHelper
9
+
10
+ alias comment model
11
+
12
+ private
13
+
14
+ def title
15
+ resource_link_text
16
+ end
17
+
18
+ def resource_path
19
+ resource_link_path
20
+ end
21
+
22
+ def metadata_cell
23
+ "decidim/comments/comment_metadata"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,3 @@
1
- <div>
2
- <%= title %>
3
- <div class="comment-thread">
4
- <%= cell("decidim/comments/comment", model, root_depth: model.depth, order: order) %>
5
- </div>
1
+ <div class="comment-thread">
2
+ <%= cell("decidim/comments/comment", model, root_depth: model.depth, order:) %>
6
3
  </div>
@@ -16,12 +16,6 @@ module Decidim
16
16
  model.comment_threads.any?
17
17
  end
18
18
 
19
- def author_name
20
- return t("decidim.components.comment.deleted_user") if model.author.deleted?
21
-
22
- model.author.name
23
- end
24
-
25
19
  def order
26
20
  options[:order] || "older"
27
21
  end
@@ -1,25 +1,6 @@
1
1
  <div class="add-comment">
2
- <h4 class="section-heading"><%= t("decidim.components.add_comment_form.title") %></h4>
3
-
4
2
  <% if user_signed_in? %>
5
- <% if alignment_enabled? %>
6
- <div class="opinion-toggle button-group">
7
- <span class="show-for-sr"><%= t("decidim.components.add_comment_form.opinion.label") %></span>
8
- <button aria-pressed="false" class="button tiny button--muted opinion-toggle--ok" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.positive_selected") %>">
9
- <%= icon "thumb-up", role: "img", "aria-hidden": true %>
10
- <span class="show-for-sr"><%= t("decidim.components.add_comment_form.opinion.positive") %></span>
11
- </button>
12
- <button aria-pressed="true" class="button tiny button--muted opinion-toggle--meh is-active" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.neutral_selected") %>">
13
- <%= t("decidim.components.add_comment_form.opinion.neutral") %>
14
- </button>
15
- <button aria-pressed="false" class="button tiny button--muted opinion-toggle--ko" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.negative_selected") %>">
16
- <%= icon "thumb-down", role: "img", "aria-hidden": true %>
17
- <span class="show-for-sr"><%= t("decidim.components.add_comment_form.opinion.negative") %></span>
18
- </button>
19
- <div role="alert" aria-live="assertive" aria-atomic="true" class="selected-state show-for-sr"></div>
20
- </div>
21
- <% end %>
22
- <%== cell("decidim/comments/comment_form", model, root_depth: root_depth) %>
3
+ <%== cell("decidim/comments/comment_form", model, root_depth:) %>
23
4
  <% else %>
24
5
  <p>
25
6
  <span>
@@ -1,3 +1 @@
1
- <div class="callout warning">
2
- <p><%= t("decidim.components.comments.blocked_comments_warning") %></p>
3
- </div>
1
+ <%= cell("decidim/announcement", t("decidim.components.comments.blocked_comments_warning"), callout_class: "warning") %>
@@ -1,3 +1 @@
1
- <div class="callout primary loading-comments">
2
- <p><%= t("decidim.components.comments.loading") %></p>
3
- </div>
1
+ <%= cell("decidim/announcement", t("decidim.components.comments.loading"), callout_class: "primary loading-comments mb-4") %>