decidim-comments 0.28.2 → 0.29.0.rc2
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/cells/decidim/comments/comment/actions.erb +4 -3
- data/app/cells/decidim/comments/comment/deletion_data.erb +1 -1
- data/app/cells/decidim/comments/comment/show.erb +2 -2
- data/app/cells/decidim/comments/comment_cell.rb +0 -2
- data/app/cells/decidim/comments/comment_form/opinion.erb +4 -4
- data/app/cells/decidim/comments/comment_form_cell.rb +0 -2
- data/app/cells/decidim/comments/comment_metadata_cell.rb +1 -1
- data/app/cells/decidim/comments/comments_cell.rb +0 -3
- data/app/cells/decidim/comments/edit_comment_modal_form_cell.rb +0 -1
- data/app/commands/decidim/comments/create_comment.rb +6 -6
- data/app/commands/decidim/comments/update_comment.rb +3 -4
- data/app/controllers/decidim/comments/comments_controller.rb +5 -3
- data/app/helpers/decidim/comments/comment_cells_helper.rb +1 -1
- data/app/models/decidim/comments/seed.rb +55 -5
- data/app/packs/entrypoints/decidim_comments.js +1 -1
- data/app/packs/src/decidim/comments/comments.component.js +8 -8
- data/app/packs/src/decidim/comments/comments.component.test.js +14 -14
- data/app/views/decidim/comments/comments/create.js.erb +2 -2
- data/app/views/decidim/comments/comments/delete.js.erb +5 -2
- data/app/views/decidim/comments/votes/create.js.erb +1 -1
- data/config/locales/bg.yml +0 -1
- data/config/locales/ca.yml +1 -1
- data/config/locales/cs.yml +0 -1
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es-MX.yml +1 -1
- data/config/locales/es-PY.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/eu.yml +1 -1
- data/config/locales/fi-plain.yml +1 -1
- data/config/locales/fi.yml +1 -1
- data/config/locales/fr-CA.yml +1 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/ja.yml +1 -1
- data/config/locales/pl.yml +1 -1
- data/config/locales/ro-RO.yml +0 -1
- data/config/locales/tr-TR.yml +0 -1
- data/db/seeds.rb +1 -0
- data/decidim-comments.gemspec +1 -1
- data/lib/decidim/api/commentable_mutation_type.rb +2 -1
- data/lib/decidim/comments/commentable.rb +2 -2
- data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +3 -2
- data/lib/decidim/comments/version.rb +1 -1
- data/lib/tasks/upgrade/decidim_comments.rake +28 -0
- metadata +12 -12
- data/lib/tasks/decidim_comments.rake +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9477ff3a7a4e7dd6176adb162064bb773e20e576a1098862d67a4d9e05c12fe
|
4
|
+
data.tar.gz: 7c7ea403b09d4b07749117c1c09af7250a928cd24928133aed71c1181719a8d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74211886a8bae87f91c5bc2cce830780b2e78e2354cfbc7a0ff24c609fa9872450726dd2906ee48b7f44255e0fda78a6fa6e58af076884cd0bd7e4ac57c2d9ec
|
7
|
+
data.tar.gz: 3c6709c7755b014f3726d449a1c5b11596d069e9bff75f03213f93fb8d414329a32dc24c62163c99f773f864be9df03a8535c7b99095fd83c8539c91aad32d7a
|
@@ -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
|
4
|
-
|
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
|
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
|
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 %>
|
@@ -63,13 +63,13 @@
|
|
63
63
|
</div>
|
64
64
|
</div>
|
65
65
|
|
66
|
-
<div
|
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
|
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 %>
|
@@ -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
|
4
|
-
<button type="button" aria-pressed="false"
|
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="
|
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"
|
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,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,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
|
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
|
33
|
+
attr_reader :form, :comment
|
34
34
|
|
35
35
|
def event_arguments
|
36
36
|
{
|
37
37
|
resource: comment,
|
38
38
|
extra: {
|
39
|
-
event_author:
|
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
|
-
|
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,
|
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
|
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,
|
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
|
85
|
+
Decidim::Comments::CreateComment.call(form) do
|
84
86
|
on(:ok) do |comment|
|
85
87
|
handle_success(comment)
|
86
88
|
respond_to do |format|
|
@@ -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
|
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
|
-
|
23
|
-
|
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 =
|
39
|
-
user_group =
|
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
|
@@ -2,7 +2,7 @@
|
|
2
2
|
/* eslint max-lines: ["error", {"max": 350, "skipBlankLines": true}] */
|
3
3
|
|
4
4
|
/**
|
5
|
-
* A plain
|
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
|
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 = $("
|
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 = $("
|
284
|
-
const $selectedState = $("
|
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.
|
290
|
+
if ($btn.data("toggleOk")) {
|
291
291
|
$alignment.val(1);
|
292
|
-
} else if ($btn.
|
292
|
+
} else if ($btn.data("toggleMeh")) {
|
293
293
|
$alignment.val(0);
|
294
|
-
} else if ($btn.
|
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 = $("
|
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
|
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 === "
|
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
|
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
|
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
|
327
|
-
<span class="
|
328
|
-
<button aria-pressed="false" class="button button__sm button__text-secondary
|
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
|
331
|
+
<span>Positive</span>
|
332
332
|
</button>
|
333
|
-
<button aria-pressed="true" class="button button__sm button__text-secondary
|
334
|
-
<span
|
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
|
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
|
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
|
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("
|
12
|
-
hideButton.find("
|
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 = ["
|
8
|
+
const sectionsToDelete = ["footer-grid", "reply"];
|
9
9
|
|
10
10
|
sectionsToDelete.forEach((section) => {
|
11
|
-
$(
|
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", {
|
@@ -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 = $(">
|
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
|
|
data/config/locales/bg.yml
CHANGED
@@ -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: Коментар
|
data/config/locales/ca.yml
CHANGED
@@ -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:
|
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
|
data/config/locales/cs.yml
CHANGED
@@ -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ář
|
data/config/locales/de.yml
CHANGED
@@ -39,7 +39,7 @@ 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}">
|
42
|
+
account_message: Sie müssen sich <a href="%{sign_in_url}">mit einem bestehendem Konto anmelden</a> oder <a href="%{sign_up_url}"> ein neues Konto registrieren</a>, um Ihren Kommentar hinzufügen.
|
43
43
|
form:
|
44
44
|
body:
|
45
45
|
label: Kommentar
|
data/config/locales/en.yml
CHANGED
@@ -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
|
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
|
data/config/locales/es-MX.yml
CHANGED
@@ -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:
|
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
|
data/config/locales/es-PY.yml
CHANGED
@@ -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:
|
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
|
data/config/locales/es.yml
CHANGED
@@ -39,7 +39,7 @@ es:
|
|
39
39
|
error: Se ha producido un error al votar el comentario.
|
40
40
|
components:
|
41
41
|
add_comment_form:
|
42
|
-
account_message:
|
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
|
data/config/locales/eu.yml
CHANGED
@@ -39,7 +39,7 @@ eu:
|
|
39
39
|
error: Arazo bat egon da iruzkina bozkatzean.
|
40
40
|
components:
|
41
41
|
add_comment_form:
|
42
|
-
account_message: <a href="%{sign_in_url}">
|
42
|
+
account_message: Sortu kontu bat <a href="%{sign_in_url}">Log in</a> edo <a href="%{sign_up_url}"> </a> zure iruzkina gehitzeko.
|
43
43
|
form:
|
44
44
|
body:
|
45
45
|
label: Iruzkina
|
data/config/locales/fi-plain.yml
CHANGED
@@ -39,7 +39,7 @@ fi-pl:
|
|
39
39
|
error: Äänestettäessä kommenttia tapahtui virhe.
|
40
40
|
components:
|
41
41
|
add_comment_form:
|
42
|
-
account_message: <a href="%{sign_in_url}">Kirjaudu
|
42
|
+
account_message: <a href="%{sign_in_url}">Kirjaudu sisään</a> tai <a href="%{sign_up_url}">luo tili</a> kommentoidaksesi.
|
43
43
|
form:
|
44
44
|
body:
|
45
45
|
label: Kommentti
|
data/config/locales/fi.yml
CHANGED
@@ -39,7 +39,7 @@ fi:
|
|
39
39
|
error: Kommentin äänestys epäonnistui.
|
40
40
|
components:
|
41
41
|
add_comment_form:
|
42
|
-
account_message: <a href="%{sign_in_url}">Kirjaudu
|
42
|
+
account_message: <a href="%{sign_in_url}">Kirjaudu sisään</a> tai <a href="%{sign_up_url}">luo tili</a> kommentoidaksesi.
|
43
43
|
form:
|
44
44
|
body:
|
45
45
|
label: Kommentti
|
data/config/locales/fr-CA.yml
CHANGED
@@ -39,7 +39,7 @@ fr-CA:
|
|
39
39
|
error: Une erreur s'est produite lors du vote sur le commentaire.
|
40
40
|
components:
|
41
41
|
add_comment_form:
|
42
|
-
account_message: <a href="%{sign_in_url}">Connectez-vous
|
42
|
+
account_message: <a href="%{sign_in_url}">Connectez-vous</a> ou <a href="%{sign_up_url}">créez un compte</a> pour ajouter votre commentaire.
|
43
43
|
form:
|
44
44
|
body:
|
45
45
|
label: Commentaire
|
data/config/locales/fr.yml
CHANGED
@@ -39,7 +39,7 @@ fr:
|
|
39
39
|
error: Une erreur s'est produite lors du vote sur le commentaire.
|
40
40
|
components:
|
41
41
|
add_comment_form:
|
42
|
-
account_message: <a href="%{sign_in_url}">Connectez-vous
|
42
|
+
account_message: <a href="%{sign_in_url}">Connectez-vous</a> ou <a href="%{sign_up_url}">créez un compte</a> pour ajouter votre commentaire.
|
43
43
|
form:
|
44
44
|
body:
|
45
45
|
label: Commentaire
|
data/config/locales/ja.yml
CHANGED
@@ -37,7 +37,7 @@ ja:
|
|
37
37
|
error: コメントに投票中に問題がありました。
|
38
38
|
components:
|
39
39
|
add_comment_form:
|
40
|
-
account_message:
|
40
|
+
account_message: コメントを追加するには<a href="%{sign_in_url}">ログインする</a> か <a href="%{sign_up_url}">アカウントを作成</a>してください
|
41
41
|
form:
|
42
42
|
body:
|
43
43
|
label: コメント
|
data/config/locales/pl.yml
CHANGED
@@ -43,7 +43,7 @@ pl:
|
|
43
43
|
error: Podczas dodawania komentarza wystąpił błąd.
|
44
44
|
components:
|
45
45
|
add_comment_form:
|
46
|
-
account_message: <a href="%{sign_in_url}">Zaloguj
|
46
|
+
account_message: <a href="%{sign_in_url}">Zaloguj się</a> lub <a href="%{sign_up_url}">utwórz konto</a>, aby dodać swój komentarz.
|
47
47
|
form:
|
48
48
|
body:
|
49
49
|
label: Komentarz
|
data/config/locales/ro-RO.yml
CHANGED
@@ -41,7 +41,6 @@ ro:
|
|
41
41
|
error: A apărut o problemă la votarea comentariului.
|
42
42
|
components:
|
43
43
|
add_comment_form:
|
44
|
-
account_message: <a href="%{sign_in_url}">Conectați-vă cu contul dumneavoastră</a> sau <a href="%{sign_up_url}">înregistrați-vă</a> pentru a adăuga un comentariu.
|
45
44
|
form:
|
46
45
|
body:
|
47
46
|
label: Comentariu
|
data/config/locales/tr-TR.yml
CHANGED
data/db/seeds.rb
CHANGED
data/decidim-comments.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
"homepage_uri" => "https://decidim.org",
|
20
20
|
"source_code_uri" => "https://github.com/decidim/decidim"
|
21
21
|
}
|
22
|
-
s.required_ruby_version = "~> 3.
|
22
|
+
s.required_ruby_version = "~> 3.2.0"
|
23
23
|
|
24
24
|
s.name = "decidim-comments"
|
25
25
|
s.summary = "Decidim comments module"
|
@@ -17,9 +17,10 @@ module Decidim
|
|
17
17
|
params = { "comment" => { "body" => body, "alignment" => alignment, "user_group_id" => user_group_id, "commentable" => object } }
|
18
18
|
form = Decidim::Comments::CommentForm.from_params(params).with_context(
|
19
19
|
current_organization: context[:current_organization],
|
20
|
+
current_user: context[:current_user],
|
20
21
|
current_component: object.component
|
21
22
|
)
|
22
|
-
Decidim::Comments::CreateComment.call(form
|
23
|
+
Decidim::Comments::CreateComment.call(form) do
|
23
24
|
on(:ok) do |comment|
|
24
25
|
return comment
|
25
26
|
end
|
@@ -28,7 +28,7 @@ module Decidim
|
|
28
28
|
false
|
29
29
|
end
|
30
30
|
|
31
|
-
# Public: Whether the object's comments can have
|
31
|
+
# Public: Whether the object's comments can have votes or not. It enables the
|
32
32
|
# upvote and downvote buttons for comments.
|
33
33
|
def comments_have_votes?
|
34
34
|
false
|
@@ -58,7 +58,7 @@ module Decidim
|
|
58
58
|
end
|
59
59
|
|
60
60
|
# Public: Updates the comments counter cache. We have to do it these
|
61
|
-
# way in order to properly calculate the
|
61
|
+
# way in order to properly calculate the counter with hidden
|
62
62
|
# comments.
|
63
63
|
#
|
64
64
|
# rubocop:disable Rails/SkipsModelValidations
|
@@ -6,6 +6,7 @@ RSpec.shared_context "when creating a comment" do
|
|
6
6
|
let(:component) { create(:component, participatory_space: participatory_process) }
|
7
7
|
let(:user) { create(:user, organization:) }
|
8
8
|
let(:author) { create(:user, organization:) }
|
9
|
+
let(:current_user) { author }
|
9
10
|
let(:dummy_resource) { create :dummy_resource, component: }
|
10
11
|
let(:commentable) { dummy_resource }
|
11
12
|
let(:body) { Faker::Lorem.paragraph }
|
@@ -25,8 +26,8 @@ RSpec.shared_context "when creating a comment" do
|
|
25
26
|
Decidim::Comments::CommentForm.from_params(
|
26
27
|
form_params
|
27
28
|
).with_context(
|
28
|
-
current_organization: organization
|
29
|
+
current_organization: organization, current_user:
|
29
30
|
)
|
30
31
|
end
|
31
|
-
let(:command) { described_class.new(form
|
32
|
+
let(:command) { described_class.new(form) }
|
32
33
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :decidim_comments do
|
4
|
+
namespace :upgrade do
|
5
|
+
desc "Adds participatory_process_id to comments if they are associated with a participatory process"
|
6
|
+
task participatory_process_in_comments: :environment do
|
7
|
+
puts "Updating comments..."
|
8
|
+
ok = errors = 0
|
9
|
+
|
10
|
+
log = ActiveSupport::Logger.new(Rails.root.join("log/update_participatory_process_in_comments.log"))
|
11
|
+
Decidim::Comments::Comment.where(participatory_space: nil).find_each do |c|
|
12
|
+
c.participatory_space = if c.root_commentable.is_a?(Decidim::Participable)
|
13
|
+
c.root_commentable
|
14
|
+
else
|
15
|
+
c.commentable.try(:participatory_space)
|
16
|
+
end
|
17
|
+
c.save(validate: false)
|
18
|
+
ok += 1
|
19
|
+
rescue StandardError => e
|
20
|
+
errors += 1
|
21
|
+
log.info "Error updating comment ##{c.id}: #{e.message}"
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "#{ok} comments updated."
|
25
|
+
puts "#{errors} errors found. Check the file 'log/update_participatory_process_in_comments.log' for more information." if errors.positive?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
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.
|
4
|
+
version: 0.29.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.29.0.rc2
|
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.
|
28
|
+
version: 0.29.0.rc2
|
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.
|
55
|
+
version: 0.29.0.rc2
|
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.
|
62
|
+
version: 0.29.0.rc2
|
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.
|
69
|
+
version: 0.29.0.rc2
|
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.
|
76
|
+
version: 0.29.0.rc2
|
77
77
|
description: Pluggable comments system for some components.
|
78
78
|
email:
|
79
79
|
- josepjaume@gmail.com
|
@@ -296,7 +296,7 @@ files:
|
|
296
296
|
- lib/decidim/comments/test/shared_examples/has_comments_availability_attributes.rb
|
297
297
|
- lib/decidim/comments/test/shared_examples/translatable_comment.rb
|
298
298
|
- lib/decidim/comments/version.rb
|
299
|
-
- lib/tasks/decidim_comments.rake
|
299
|
+
- lib/tasks/upgrade/decidim_comments.rake
|
300
300
|
homepage: https://decidim.org
|
301
301
|
licenses:
|
302
302
|
- AGPL-3.0
|
@@ -314,14 +314,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
314
314
|
requirements:
|
315
315
|
- - "~>"
|
316
316
|
- !ruby/object:Gem::Version
|
317
|
-
version: 3.
|
317
|
+
version: 3.2.0
|
318
318
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
319
319
|
requirements:
|
320
|
-
- - "
|
320
|
+
- - ">"
|
321
321
|
- !ruby/object:Gem::Version
|
322
|
-
version:
|
322
|
+
version: 1.3.1
|
323
323
|
requirements: []
|
324
|
-
rubygems_version: 3.
|
324
|
+
rubygems_version: 3.4.10
|
325
325
|
signing_key:
|
326
326
|
specification_version: 4
|
327
327
|
summary: Decidim comments module
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :decidim_comments do
|
4
|
-
desc "Adds participatory_process_id to comments if they are associated with a participatory process"
|
5
|
-
task update_participatory_process_in_comments: :environment do
|
6
|
-
puts "Updating comments..."
|
7
|
-
ok = errors = 0
|
8
|
-
|
9
|
-
log = ActiveSupport::Logger.new(Rails.root.join("log/update_participatory_process_in_comments.log"))
|
10
|
-
Decidim::Comments::Comment.where(participatory_space: nil).find_each do |c|
|
11
|
-
c.participatory_space = if c.root_commentable.is_a?(Decidim::Participable)
|
12
|
-
c.root_commentable
|
13
|
-
else
|
14
|
-
c.commentable.try(:participatory_space)
|
15
|
-
end
|
16
|
-
c.save(validate: false)
|
17
|
-
ok += 1
|
18
|
-
rescue StandardError => e
|
19
|
-
errors += 1
|
20
|
-
log.info "Error updating comment ##{c.id}: #{e.message}"
|
21
|
-
end
|
22
|
-
|
23
|
-
puts "#{ok} comments updated."
|
24
|
-
puts "#{errors} errors found. Check the file 'log/update_participatory_process_in_comments.log' for more information." if errors.positive?
|
25
|
-
end
|
26
|
-
end
|