decidim-comments 0.27.9 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) 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 +9 -21
  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 +9 -1
  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 -7
  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 +9 -7
  44. data/app/models/decidim/comments/comment_vote.rb +0 -10
  45. data/app/models/decidim/comments/seed.rb +30 -14
  46. data/app/packs/entrypoints/decidim_comments.js +5 -0
  47. data/app/packs/src/decidim/comments/comments.component.js +27 -36
  48. data/app/packs/src/decidim/comments/comments.component.test.js +218 -240
  49. data/app/packs/src/decidim/comments/comments.component_for_testing.js +1 -1
  50. data/app/packs/src/decidim/comments/comments.js +20 -1
  51. data/app/packs/stylesheets/comments.scss +327 -0
  52. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +1 -1
  53. data/app/queries/decidim/comments/sorted_comments.rb +10 -10
  54. data/app/services/decidim/comments/comment_creation.rb +1 -1
  55. data/app/services/decidim/comments/new_comment_notification_creator.rb +8 -8
  56. data/app/views/decidim/comments/admin/shared/_availability_fields.html.erb +4 -9
  57. data/app/views/decidim/comments/comments/_comment.html.erb +1 -1
  58. data/app/views/decidim/comments/comments/_comments.html.erb +1 -1
  59. data/app/views/decidim/comments/comments/_delete.html.erb +2 -4
  60. data/app/views/decidim/comments/comments/_moderated.html.erb +2 -4
  61. data/app/views/decidim/comments/comments/create.js.erb +5 -3
  62. data/app/views/decidim/comments/comments/delete.js.erb +4 -1
  63. data/app/views/decidim/comments/comments/index.js.erb +8 -1
  64. data/app/views/decidim/comments/comments/reload.js.erb +1 -2
  65. data/app/views/decidim/comments/comments/update.js.erb +5 -4
  66. data/app/views/decidim/comments/votes/create.js.erb +5 -5
  67. data/config/assets.rb +3 -0
  68. data/config/locales/ar.yml +0 -16
  69. data/config/locales/bg.yml +0 -166
  70. data/config/locales/ca.yml +15 -17
  71. data/config/locales/cs.yml +8 -10
  72. data/config/locales/de.yml +7 -9
  73. data/config/locales/el.yml +3 -11
  74. data/config/locales/en.yml +10 -12
  75. data/config/locales/es-MX.yml +10 -12
  76. data/config/locales/es-PY.yml +10 -12
  77. data/config/locales/es.yml +16 -18
  78. data/config/locales/eu.yml +6 -8
  79. data/config/locales/fi-plain.yml +7 -9
  80. data/config/locales/fi.yml +11 -13
  81. data/config/locales/fr-CA.yml +9 -11
  82. data/config/locales/fr.yml +9 -11
  83. data/config/locales/ga-IE.yml +0 -4
  84. data/config/locales/gl.yml +0 -16
  85. data/config/locales/hu.yml +3 -11
  86. data/config/locales/id-ID.yml +0 -11
  87. data/config/locales/is-IS.yml +0 -8
  88. data/config/locales/it.yml +0 -16
  89. data/config/locales/ja.yml +6 -8
  90. data/config/locales/lb.yml +0 -16
  91. data/config/locales/lt.yml +7 -10
  92. data/config/locales/lv.yml +0 -11
  93. data/config/locales/nl.yml +0 -16
  94. data/config/locales/no.yml +0 -16
  95. data/config/locales/pl.yml +7 -11
  96. data/config/locales/pt-BR.yml +0 -18
  97. data/config/locales/pt.yml +0 -16
  98. data/config/locales/ro-RO.yml +6 -14
  99. data/config/locales/ru.yml +0 -11
  100. data/config/locales/sk.yml +0 -11
  101. data/config/locales/sq-AL.yml +0 -38
  102. data/config/locales/sv.yml +4 -18
  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/comment_type.rb +2 -2
  108. data/lib/decidim/api/commentable_interface.rb +1 -1
  109. data/lib/decidim/comments/comment_serializer.rb +1 -1
  110. data/lib/decidim/comments/comment_vote_serializer.rb +1 -1
  111. data/lib/decidim/comments/commentable.rb +1 -1
  112. data/lib/decidim/comments/comments_helper.rb +6 -3
  113. data/lib/decidim/comments/engine.rb +31 -1
  114. data/lib/decidim/comments/export.rb +1 -1
  115. data/lib/decidim/comments/test/factories.rb +9 -22
  116. data/lib/decidim/comments/test/shared_examples/comment_event.rb +4 -37
  117. data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +4 -4
  118. data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +5 -5
  119. data/lib/decidim/comments/test/shared_examples/has_comments_availability_attributes.rb +2 -2
  120. data/lib/decidim/comments/test/shared_examples/translatable_comment.rb +3 -3
  121. data/lib/decidim/comments/version.rb +1 -1
  122. metadata +27 -24
  123. data/app/cells/decidim/comments/comment/author.erb +0 -1
  124. data/app/cells/decidim/comments/comment/utilities.erb +0 -41
  125. data/app/cells/decidim/comments/comment_m/footer.erb +0 -5
  126. data/app/cells/decidim/comments/comment_m/top.erb +0 -7
  127. data/app/cells/decidim/comments/comment_m_cell.rb +0 -29
  128. data/app/cells/decidim/comments/comment_thread/title.erb +0 -3
  129. data/config/locales/he-IL.yml +0 -1
  130. data/db/migrate/20240304092558_add_comment_vote_counter_cache_to_comments.rb +0 -21
  131. data/decidim-comments.gemspec +0 -33
@@ -1,7 +1,6 @@
1
1
  /* eslint id-length: ["error", { "exceptions": ["$"] }] */
2
2
  /* eslint max-lines: ["error", {"max": 350, "skipBlankLines": true}] */
3
3
 
4
-
5
4
  /**
6
5
  * A plain Javascript component that handles the comments.
7
6
  *
@@ -12,11 +11,7 @@
12
11
  // This is necessary for testing purposes
13
12
  const $ = window.$;
14
13
 
15
- import Rails from "@rails/ujs";
16
-
17
- import { createCharacterCounter } from "src/decidim/input_character_counter"
18
- import ExternalLink from "src/decidim/external_link"
19
- import updateExternalDomainLinks from "src/decidim/external_domain_warning"
14
+ import changeReportFormBehavior from "src/decidim/change_report_form_behavior"
20
15
 
21
16
  export default class CommentsComponent {
22
17
  constructor($element, config) {
@@ -48,8 +43,6 @@ export default class CommentsComponent {
48
43
  $(".add-comment textarea", this.$element).prop("disabled", false);
49
44
  });
50
45
  }
51
-
52
- $(".order-by__dropdown .is-submenu-item a", this.$element).on("click.decidim-comments", () => this._onInitOrder());
53
46
  }
54
47
  }
55
48
 
@@ -63,9 +56,8 @@ export default class CommentsComponent {
63
56
  this.mounted = false;
64
57
  this._stopPolling();
65
58
 
66
- $(".add-comment .opinion-toggle .button", this.$element).off("click.decidim-comments");
59
+ $(".add-comment .opinion-toggle button", this.$element).off("click.decidim-comments");
67
60
  $(".add-comment textarea", this.$element).off("input.decidim-comments");
68
- $(".order-by__dropdown .is-submenu-item a", this.$element).off("click.decidim-comments");
69
61
  $(".add-comment form", this.$element).off("submit.decidim-comments");
70
62
  $(".add-comment textarea", this.$element).each((_i, el) => el.removeEventListener("emoji.added", this._onTextInput));
71
63
  }
@@ -102,7 +94,7 @@ export default class CommentsComponent {
102
94
  const $comment = $(replyHtml);
103
95
  const $replies = $(`#comment-${commentId}-replies`);
104
96
  this._addComment($replies, $comment);
105
- $replies.siblings(".comment__additionalreply").removeClass("hide");
97
+ $replies.addClass("comment-reply");
106
98
  this._finalizeCommentCreation($parent, fromCurrentUser);
107
99
  }
108
100
 
@@ -125,7 +117,7 @@ export default class CommentsComponent {
125
117
  $(".add-comment", $parent).each((_i, el) => {
126
118
  const $add = $(el);
127
119
  const $form = $("form", $add);
128
- const $opinionButtons = $(".opinion-toggle .button", $add);
120
+ const $opinionButtons = $(".opinion-toggle button", $add);
129
121
  const $text = $("textarea", $form);
130
122
 
131
123
  $opinionButtons.on("click.decidim-comments", this._onToggleOpinion);
@@ -140,6 +132,8 @@ export default class CommentsComponent {
140
132
  this._stopPolling();
141
133
  });
142
134
 
135
+ document.querySelectorAll(".new_report").forEach((container) => changeReportFormBehavior(container))
136
+
143
137
  if ($text.length && $text.get(0) !== null) {
144
138
  // Attach event to the DOM node, instead of the jQuery object
145
139
  $text.get(0).addEventListener("emoji.added", this._onTextInput);
@@ -164,14 +158,9 @@ export default class CommentsComponent {
164
158
  this.lastCommentId = parseInt($comment.data("comment-id"), 10);
165
159
 
166
160
  $target.append($container);
167
- $container.foundation();
161
+
168
162
  this._initializeComments($container);
169
- createCharacterCounter($(".add-comment textarea", $container));
170
- $container.find('a[target="_blank"]').each((_i, elem) => {
171
- const $link = $(elem);
172
- $link.data("external-link", new ExternalLink($link));
173
- });
174
- updateExternalDomainLinks($container)
163
+ document.dispatchEvent(new CustomEvent("comments:loaded", { detail: {commentsIds: [this.lastCommentId] }}));
175
164
  }
176
165
 
177
166
  /**
@@ -185,16 +174,18 @@ export default class CommentsComponent {
185
174
  */
186
175
  _finalizeCommentCreation($parent, fromCurrentUser) {
187
176
  if (fromCurrentUser) {
188
- const $add = $("> .add-comment", $parent);
189
- const $text = $("textarea", $add);
190
- const characterCounter = $text.data("remaining-characters-counter");
191
- $text.val("");
192
- if (characterCounter) {
193
- characterCounter.updateStatus();
194
- }
195
- if (!$add.parent().is(".comments")) {
196
- $add.addClass("hide");
197
- }
177
+ const $add = $(".add-comment", $parent);
178
+ $("textarea", $add).each((_i, text) => {
179
+ const $text = $(text);
180
+ // Reset textarea content
181
+ $text.val("")
182
+ // Update characterCounter component
183
+ const characterCounter = $text.data("remaining-characters-counter");
184
+ if (characterCounter) {
185
+ characterCounter.handleInput();
186
+ characterCounter.updateStatus();
187
+ }
188
+ })
198
189
  }
199
190
 
200
191
  // Restart the polling
@@ -230,7 +221,7 @@ export default class CommentsComponent {
230
221
  "commentable_gid": this.commentableGid,
231
222
  "root_depth": this.rootDepth,
232
223
  "order": this.order,
233
- "after": this.lastCommentId,
224
+ // From here, the rest of properties are optional
234
225
  ...(this.toggleTranslations && { "toggle_translations": this.toggleTranslations }),
235
226
  ...(this.lastCommentId && { "after": this.lastCommentId })
236
227
  }),
@@ -260,9 +251,9 @@ export default class CommentsComponent {
260
251
  * @returns {Void} - Returns nothing
261
252
  */
262
253
  _setLoading() {
263
- const $container = $("> .comments-container", this.$element);
264
- $("> .comments", $container).addClass("hide");
265
- $("> .loading-comments", $container).removeClass("hide");
254
+ const $container = $("> #comments", this.$element);
255
+ $("> .comments", $container).addClass("hidden");
256
+ $("> .loading-comments", $container).removeClass("hidden");
266
257
  }
267
258
 
268
259
  /**
@@ -283,13 +274,13 @@ export default class CommentsComponent {
283
274
  */
284
275
  _onToggleOpinion(ev) {
285
276
  let $btn = $(ev.target);
286
- if (!$btn.is(".button")) {
287
- $btn = $btn.parents(".button");
277
+ if (!$btn.is("button")) {
278
+ $btn = $btn.parents("button");
288
279
  }
289
280
 
290
281
  const $add = $btn.closest(".add-comment");
291
282
  const $form = $("form", $add);
292
- const $opinionButtons = $(".opinion-toggle .button", $add);
283
+ const $opinionButtons = $(".opinion-toggle button", $add);
293
284
  const $selectedState = $(".opinion-toggle .selected-state", $add);
294
285
  const $alignment = $(".alignment-input", $form);
295
286