decidim-comments 0.25.0.rc2 → 0.25.0.rc3
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.
- checksums.yaml +4 -4
- data/app/packs/src/decidim/comments/comments.component.js +24 -23
- data/app/packs/src/decidim/comments/comments.component.test.js +67 -2
- data/app/queries/decidim/comments/sorted_comments.rb +8 -6
- data/app/views/decidim/comments/comments/create.js.erb +2 -2
- data/lib/decidim/comments/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5025c82564955ebb8952a49e8e301256ef9c4465fbf8f52e5b2489124674cff4
|
|
4
|
+
data.tar.gz: 66a5ab9d8c0af6e7120e02a0220fa8777b9e0bbe6d5c862ac420c729194cedee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da03ef21094993feba8baa55864c33292820678b7105a749abd68761522aae1b018796316f289ce0c847f10cd204d8f75df4530866f25d1742486674e9da85c3
|
|
7
|
+
data.tar.gz: 1cc6d927dbd821d7f0647c5dd22c30faeab751a39f948bcbde85f3cf269afded077dacc9935dea3cebf2b2e95f6aca4b5a21cffbdd2e92860c9a248039c3d9f2
|
|
@@ -37,12 +37,7 @@ export default class CommentsComponent {
|
|
|
37
37
|
this.mounted = true;
|
|
38
38
|
this._initializeComments(this.$element);
|
|
39
39
|
|
|
40
|
-
$(".order-by__dropdown .is-submenu-item a", this.$element).on(
|
|
41
|
-
"click.decidim-comments",
|
|
42
|
-
() => {
|
|
43
|
-
this._onInitOrder();
|
|
44
|
-
}
|
|
45
|
-
);
|
|
40
|
+
$(".order-by__dropdown .is-submenu-item a", this.$element).on("click.decidim-comments", () => this._onInitOrder());
|
|
46
41
|
}
|
|
47
42
|
}
|
|
48
43
|
|
|
@@ -68,14 +63,16 @@ export default class CommentsComponent {
|
|
|
68
63
|
* Adds a new thread to the comments section.
|
|
69
64
|
* @public
|
|
70
65
|
* @param {String} threadHtml - The HTML content for the thread.
|
|
66
|
+
* @param {Boolean} fromCurrentUser - A boolean indicating whether the user
|
|
67
|
+
* herself was the author of the new thread. Defaults to false.
|
|
71
68
|
* @returns {Void} - Returns nothing
|
|
72
69
|
*/
|
|
73
|
-
addThread(threadHtml) {
|
|
70
|
+
addThread(threadHtml, fromCurrentUser = false) {
|
|
74
71
|
const $parent = $(".comments:first", this.$element);
|
|
75
72
|
const $comment = $(threadHtml);
|
|
76
73
|
const $threads = $(".comment-threads", this.$element);
|
|
77
74
|
this._addComment($threads, $comment);
|
|
78
|
-
this._finalizeCommentCreation($parent);
|
|
75
|
+
this._finalizeCommentCreation($parent, fromCurrentUser);
|
|
79
76
|
}
|
|
80
77
|
|
|
81
78
|
/**
|
|
@@ -84,15 +81,17 @@ export default class CommentsComponent {
|
|
|
84
81
|
* @param {Number} commentId - The ID of the comment for which to add the
|
|
85
82
|
* reply to.
|
|
86
83
|
* @param {String} replyHtml - The HTML content for the reply.
|
|
84
|
+
* @param {Boolean} fromCurrentUser - A boolean indicating whether the user
|
|
85
|
+
* herself was the author of the new reply. Defaults to false.
|
|
87
86
|
* @returns {Void} - Returns nothing
|
|
88
87
|
*/
|
|
89
|
-
addReply(commentId, replyHtml) {
|
|
88
|
+
addReply(commentId, replyHtml, fromCurrentUser = false) {
|
|
90
89
|
const $parent = $(`#comment_${commentId}`);
|
|
91
90
|
const $comment = $(replyHtml);
|
|
92
91
|
const $replies = $(`#comment-${commentId}-replies`);
|
|
93
92
|
this._addComment($replies, $comment);
|
|
94
93
|
$replies.siblings(".comment__additionalreply").removeClass("hide");
|
|
95
|
-
this._finalizeCommentCreation($parent);
|
|
94
|
+
this._finalizeCommentCreation($parent, fromCurrentUser);
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
/**
|
|
@@ -170,18 +169,22 @@ export default class CommentsComponent {
|
|
|
170
169
|
* successfully.
|
|
171
170
|
* @private
|
|
172
171
|
* @param {jQuery} $parent - The parent comment element to finalize.
|
|
172
|
+
* @param {Boolean} fromCurrentUser - A boolean indicating whether the user
|
|
173
|
+
* herself was the author of the new comment.
|
|
173
174
|
* @returns {Void} - Returns nothing
|
|
174
175
|
*/
|
|
175
|
-
_finalizeCommentCreation($parent) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
characterCounter
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
176
|
+
_finalizeCommentCreation($parent, fromCurrentUser) {
|
|
177
|
+
if (fromCurrentUser) {
|
|
178
|
+
const $add = $("> .add-comment", $parent);
|
|
179
|
+
const $text = $("textarea", $add);
|
|
180
|
+
const characterCounter = $text.data("remaining-characters-counter");
|
|
181
|
+
$text.val("");
|
|
182
|
+
if (characterCounter) {
|
|
183
|
+
characterCounter.updateStatus();
|
|
184
|
+
}
|
|
185
|
+
if (!$add.parent().is(".comments")) {
|
|
186
|
+
$add.addClass("hide");
|
|
187
|
+
}
|
|
185
188
|
}
|
|
186
189
|
|
|
187
190
|
// Restart the polling
|
|
@@ -207,9 +210,7 @@ export default class CommentsComponent {
|
|
|
207
210
|
order: this.order,
|
|
208
211
|
after: this.lastCommentId
|
|
209
212
|
}
|
|
210
|
-
}).done(() =>
|
|
211
|
-
this._pollComments();
|
|
212
|
-
});
|
|
213
|
+
}).done(() => this._pollComments());
|
|
213
214
|
}, this.pollingInterval);
|
|
214
215
|
}
|
|
215
216
|
|
|
@@ -558,17 +558,82 @@ describe("CommentsComponent", () => {
|
|
|
558
558
|
"This is a dynamically added comment"
|
|
559
559
|
));
|
|
560
560
|
});
|
|
561
|
+
|
|
562
|
+
it("does not clear the comment form text area", () => {
|
|
563
|
+
const commentSection = addComment[addComment.length - 1];
|
|
564
|
+
const textArea = $("textarea", commentSection);
|
|
565
|
+
textArea.val("I am writing a new comment...");
|
|
566
|
+
|
|
567
|
+
const newThread = generateCommentThread(999, "This is a dynamically added comment");
|
|
568
|
+
subject.addThread(newThread);
|
|
569
|
+
|
|
570
|
+
expect(textArea.val()).toEqual("I am writing a new comment...");
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
describe("as the current user", () => {
|
|
574
|
+
it("clears the comment form text area", () => {
|
|
575
|
+
const commentSection = addComment[addComment.length - 1];
|
|
576
|
+
const textArea = $("textarea", commentSection);
|
|
577
|
+
textArea.val("I am writing a new comment...");
|
|
578
|
+
|
|
579
|
+
const newThread = generateCommentThread(999, "This is a dynamically added comment");
|
|
580
|
+
subject.addThread(newThread, true);
|
|
581
|
+
|
|
582
|
+
expect(textArea.val()).toEqual("");
|
|
583
|
+
});
|
|
584
|
+
});
|
|
561
585
|
});
|
|
562
586
|
|
|
563
587
|
describe("addReply", () => {
|
|
588
|
+
const newReply = generateSingleComment(999, "This is a dynamically added reply");
|
|
589
|
+
|
|
564
590
|
it("adds a new reply to an existing thread", () => {
|
|
565
|
-
|
|
566
|
-
subject.addReply(450, newThread);
|
|
591
|
+
subject.addReply(450, newReply);
|
|
567
592
|
|
|
568
593
|
expect(subject.$element.html()).toEqual(expect.stringContaining(
|
|
569
594
|
"This is a dynamically added reply"
|
|
570
595
|
));
|
|
571
596
|
});
|
|
597
|
+
|
|
598
|
+
it("does not clear the reply comment form text area", () => {
|
|
599
|
+
const commentSection = $("#comment450-reply", subject.$element);
|
|
600
|
+
const textArea = $("textarea", commentSection);
|
|
601
|
+
textArea.val("I am writing a new comment...");
|
|
602
|
+
|
|
603
|
+
subject.addReply(450, newReply);
|
|
604
|
+
|
|
605
|
+
expect(textArea.val()).toEqual("I am writing a new comment...");
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
it("does not hide the reply form", () => {
|
|
609
|
+
const commentSection = $("#comment450-reply", subject.$element);
|
|
610
|
+
commentSection.removeClass("hide");
|
|
611
|
+
|
|
612
|
+
subject.addReply(450, newReply);
|
|
613
|
+
|
|
614
|
+
expect(commentSection.hasClass("hide")).toBeFalsy();
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
describe("as the current user", () => {
|
|
618
|
+
it("clears the comment form text area", () => {
|
|
619
|
+
const commentSection = $("#comment450-reply", subject.$element);
|
|
620
|
+
const textArea = $("textarea", commentSection);
|
|
621
|
+
textArea.val("I am writing a new comment...");
|
|
622
|
+
|
|
623
|
+
subject.addReply(450, newReply, true);
|
|
624
|
+
|
|
625
|
+
expect(textArea.val()).toEqual("");
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
it("hides the reply form", () => {
|
|
629
|
+
const commentSection = $("#comment450-reply", subject.$element);
|
|
630
|
+
commentSection.removeClass("hide");
|
|
631
|
+
|
|
632
|
+
subject.addReply(450, newReply, true);
|
|
633
|
+
|
|
634
|
+
expect(commentSection.hasClass("hide")).toBeTruthy();
|
|
635
|
+
});
|
|
636
|
+
});
|
|
572
637
|
});
|
|
573
638
|
});
|
|
574
639
|
|
|
@@ -33,12 +33,6 @@ module Decidim
|
|
|
33
33
|
scope = base_scope
|
|
34
34
|
.not_hidden
|
|
35
35
|
.includes(:author, :user_group, :up_votes, :down_votes)
|
|
36
|
-
if @options[:after]
|
|
37
|
-
scope = scope.where(
|
|
38
|
-
"decidim_comments_comments.id > ?",
|
|
39
|
-
@options[:after]
|
|
40
|
-
)
|
|
41
|
-
end
|
|
42
36
|
|
|
43
37
|
case @options[:order_by]
|
|
44
38
|
when "older"
|
|
@@ -60,6 +54,14 @@ module Decidim
|
|
|
60
54
|
id = @options[:id]
|
|
61
55
|
return Comment.where(root_commentable: commentable, id: id) if id.present?
|
|
62
56
|
|
|
57
|
+
after = @options[:after]
|
|
58
|
+
if after.present?
|
|
59
|
+
return Comment.where(root_commentable: commentable).where(
|
|
60
|
+
"decidim_comments_comments.id > ?",
|
|
61
|
+
after
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
63
65
|
Comment.where(commentable: commentable)
|
|
64
66
|
end
|
|
65
67
|
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
var $comments = $("#" + rootCommentableId);
|
|
7
7
|
var component = $comments.data("comments");
|
|
8
8
|
if (inReplyTo) {
|
|
9
|
-
component.addReply(inReplyTo, commentHtml);
|
|
9
|
+
component.addReply(inReplyTo, commentHtml, true);
|
|
10
10
|
} else {
|
|
11
|
-
component.addThread(commentHtml);
|
|
11
|
+
component.addThread(commentHtml, true);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// Update the comments count
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-comments
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.25.0.
|
|
4
|
+
version: 0.25.0.rc3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josep Jaume Rey Peroy
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2021-09-
|
|
13
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: decidim-core
|
|
@@ -18,14 +18,14 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - '='
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.25.0.
|
|
21
|
+
version: 0.25.0.rc3
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - '='
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 0.25.0.
|
|
28
|
+
version: 0.25.0.rc3
|
|
29
29
|
- !ruby/object:Gem::Dependency
|
|
30
30
|
name: redcarpet
|
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -52,28 +52,28 @@ dependencies:
|
|
|
52
52
|
requirements:
|
|
53
53
|
- - '='
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: 0.25.0.
|
|
55
|
+
version: 0.25.0.rc3
|
|
56
56
|
type: :development
|
|
57
57
|
prerelease: false
|
|
58
58
|
version_requirements: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
60
|
- - '='
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 0.25.0.
|
|
62
|
+
version: 0.25.0.rc3
|
|
63
63
|
- !ruby/object:Gem::Dependency
|
|
64
64
|
name: decidim-dev
|
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
67
|
- - '='
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 0.25.0.
|
|
69
|
+
version: 0.25.0.rc3
|
|
70
70
|
type: :development
|
|
71
71
|
prerelease: false
|
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements:
|
|
74
74
|
- - '='
|
|
75
75
|
- !ruby/object:Gem::Version
|
|
76
|
-
version: 0.25.0.
|
|
76
|
+
version: 0.25.0.rc3
|
|
77
77
|
description: Pluggable comments system for some components.
|
|
78
78
|
email:
|
|
79
79
|
- josepjaume@gmail.com
|