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.
- checksums.yaml +4 -4
- data/app/cells/decidim/comments/comment/actions.erb +13 -7
- data/app/cells/decidim/comments/comment/alignment_badge.erb +1 -4
- data/app/cells/decidim/comments/comment/deletion_data.erb +9 -1
- data/app/cells/decidim/comments/comment/moderation_data.erb +1 -1
- data/app/cells/decidim/comments/comment/replies.erb +3 -0
- data/app/cells/decidim/comments/comment/show.erb +72 -35
- data/app/cells/decidim/comments/comment/votes.erb +14 -14
- data/app/cells/decidim/comments/comment_activity_cell.rb +11 -7
- data/app/cells/decidim/comments/comment_card_cell.rb +2 -2
- data/app/cells/decidim/comments/comment_cell.rb +9 -21
- data/app/cells/decidim/comments/comment_form/comment_as.erb +3 -3
- data/app/cells/decidim/comments/comment_form/opinion.erb +18 -0
- data/app/cells/decidim/comments/comment_form/show.erb +33 -16
- data/app/cells/decidim/comments/comment_form_cell.rb +9 -1
- data/app/cells/decidim/comments/comment_metadata_cell.rb +27 -0
- data/app/cells/decidim/comments/comment_s_cell.rb +27 -0
- data/app/cells/decidim/comments/comment_thread/show.erb +2 -5
- data/app/cells/decidim/comments/comment_thread_cell.rb +0 -6
- data/app/cells/decidim/comments/comments/add_comment.erb +1 -20
- data/app/cells/decidim/comments/comments/blocked_comments_warning.erb +1 -3
- data/app/cells/decidim/comments/comments/comments_loading.erb +1 -3
- data/app/cells/decidim/comments/comments/order_control.erb +11 -35
- data/app/cells/decidim/comments/comments/show.erb +8 -9
- data/app/cells/decidim/comments/comments/single_comment_warning.erb +6 -9
- data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +9 -6
- data/app/cells/decidim/comments/comments_cell.rb +1 -1
- data/app/cells/decidim/comments/edit_comment_modal_form/show.erb +20 -15
- data/app/commands/decidim/comments/create_comment.rb +17 -5
- data/app/commands/decidim/comments/delete_comment.rb +1 -1
- data/app/commands/decidim/comments/update_comment.rb +14 -2
- data/app/commands/decidim/comments/vote_comment.rb +1 -1
- data/app/controllers/decidim/comments/comments_controller.rb +14 -9
- data/app/controllers/decidim/comments/votes_controller.rb +1 -1
- data/app/events/decidim/comments/comment_by_followed_user_event.rb +1 -1
- data/app/events/decidim/comments/comment_by_followed_user_group_event.rb +1 -1
- data/app/events/decidim/comments/comment_event.rb +2 -7
- data/app/events/decidim/comments/reply_created_event.rb +1 -1
- data/app/events/decidim/comments/user_group_mentioned_event.rb +1 -1
- data/app/events/decidim/comments/user_mentioned_event.rb +1 -1
- data/app/helpers/decidim/comments/comment_cells_helper.rb +1 -1
- data/app/jobs/decidim/comments/hide_all_created_by_author_job.rb +13 -0
- data/app/models/decidim/comments/comment.rb +9 -7
- data/app/models/decidim/comments/comment_vote.rb +0 -10
- data/app/models/decidim/comments/seed.rb +30 -14
- data/app/packs/entrypoints/decidim_comments.js +5 -0
- data/app/packs/src/decidim/comments/comments.component.js +27 -36
- data/app/packs/src/decidim/comments/comments.component.test.js +218 -240
- data/app/packs/src/decidim/comments/comments.component_for_testing.js +1 -1
- data/app/packs/src/decidim/comments/comments.js +20 -1
- data/app/packs/stylesheets/comments.scss +327 -0
- data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +1 -1
- data/app/queries/decidim/comments/sorted_comments.rb +10 -10
- data/app/services/decidim/comments/comment_creation.rb +1 -1
- data/app/services/decidim/comments/new_comment_notification_creator.rb +8 -8
- data/app/views/decidim/comments/admin/shared/_availability_fields.html.erb +4 -9
- data/app/views/decidim/comments/comments/_comment.html.erb +1 -1
- data/app/views/decidim/comments/comments/_comments.html.erb +1 -1
- data/app/views/decidim/comments/comments/_delete.html.erb +2 -4
- data/app/views/decidim/comments/comments/_moderated.html.erb +2 -4
- data/app/views/decidim/comments/comments/create.js.erb +5 -3
- data/app/views/decidim/comments/comments/delete.js.erb +4 -1
- data/app/views/decidim/comments/comments/index.js.erb +8 -1
- data/app/views/decidim/comments/comments/reload.js.erb +1 -2
- data/app/views/decidim/comments/comments/update.js.erb +5 -4
- data/app/views/decidim/comments/votes/create.js.erb +5 -5
- data/config/assets.rb +3 -0
- data/config/locales/ar.yml +0 -16
- data/config/locales/bg.yml +0 -166
- data/config/locales/ca.yml +15 -17
- data/config/locales/cs.yml +8 -10
- data/config/locales/de.yml +7 -9
- data/config/locales/el.yml +3 -11
- data/config/locales/en.yml +10 -12
- data/config/locales/es-MX.yml +10 -12
- data/config/locales/es-PY.yml +10 -12
- data/config/locales/es.yml +16 -18
- data/config/locales/eu.yml +6 -8
- data/config/locales/fi-plain.yml +7 -9
- data/config/locales/fi.yml +11 -13
- data/config/locales/fr-CA.yml +9 -11
- data/config/locales/fr.yml +9 -11
- data/config/locales/ga-IE.yml +0 -4
- data/config/locales/gl.yml +0 -16
- data/config/locales/hu.yml +3 -11
- data/config/locales/id-ID.yml +0 -11
- data/config/locales/is-IS.yml +0 -8
- data/config/locales/it.yml +0 -16
- data/config/locales/ja.yml +6 -8
- data/config/locales/lb.yml +0 -16
- data/config/locales/lt.yml +7 -10
- data/config/locales/lv.yml +0 -11
- data/config/locales/nl.yml +0 -16
- data/config/locales/no.yml +0 -16
- data/config/locales/pl.yml +7 -11
- data/config/locales/pt-BR.yml +0 -18
- data/config/locales/pt.yml +0 -16
- data/config/locales/ro-RO.yml +6 -14
- data/config/locales/ru.yml +0 -11
- data/config/locales/sk.yml +0 -11
- data/config/locales/sq-AL.yml +0 -38
- data/config/locales/sv.yml +4 -18
- data/config/locales/tr-TR.yml +1 -13
- data/config/locales/uk.yml +0 -8
- data/config/locales/zh-CN.yml +0 -13
- data/config/locales/zh-TW.yml +1 -9
- data/lib/decidim/api/comment_type.rb +2 -2
- data/lib/decidim/api/commentable_interface.rb +1 -1
- data/lib/decidim/comments/comment_serializer.rb +1 -1
- data/lib/decidim/comments/comment_vote_serializer.rb +1 -1
- data/lib/decidim/comments/commentable.rb +1 -1
- data/lib/decidim/comments/comments_helper.rb +6 -3
- data/lib/decidim/comments/engine.rb +31 -1
- data/lib/decidim/comments/export.rb +1 -1
- data/lib/decidim/comments/test/factories.rb +9 -22
- data/lib/decidim/comments/test/shared_examples/comment_event.rb +4 -37
- data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +4 -4
- data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +5 -5
- data/lib/decidim/comments/test/shared_examples/has_comments_availability_attributes.rb +2 -2
- data/lib/decidim/comments/test/shared_examples/translatable_comment.rb +3 -3
- data/lib/decidim/comments/version.rb +1 -1
- metadata +27 -24
- data/app/cells/decidim/comments/comment/author.erb +0 -1
- data/app/cells/decidim/comments/comment/utilities.erb +0 -41
- data/app/cells/decidim/comments/comment_m/footer.erb +0 -5
- data/app/cells/decidim/comments/comment_m/top.erb +0 -7
- data/app/cells/decidim/comments/comment_m_cell.rb +0 -29
- data/app/cells/decidim/comments/comment_thread/title.erb +0 -3
- data/config/locales/he-IL.yml +0 -1
- data/db/migrate/20240304092558_add_comment_vote_counter_cache_to_comments.rb +0 -21
- 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
|
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
|
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.
|
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
|
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
|
-
|
161
|
+
|
168
162
|
this._initializeComments($container);
|
169
|
-
|
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 = $("
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
characterCounter
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|
-
|
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 = $(">
|
264
|
-
$("> .comments", $container).addClass("
|
265
|
-
$("> .loading-comments", $container).removeClass("
|
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("
|
287
|
-
$btn = $btn.parents("
|
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
|
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
|
|