decidim-comments 0.28.1 → 0.29.0.rc1
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 +5 -5
- data/app/cells/decidim/comments/comment/deletion_data.erb +1 -1
- data/app/cells/decidim/comments/comment/show.erb +6 -4
- data/app/cells/decidim/comments/comment_cell.rb +18 -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/comment_thread/show.erb +1 -1
- data/app/cells/decidim/comments/comments/order_control.erb +2 -1
- data/app/cells/decidim/comments/comments/show.erb +1 -1
- data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +2 -2
- data/app/cells/decidim/comments/comments_cell.rb +5 -4
- 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/events/decidim/comments/comment_event.rb +4 -0
- 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 +16 -16
- 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/ar.yml +0 -1
- data/config/locales/bg.yml +168 -0
- data/config/locales/ca.yml +7 -2
- data/config/locales/cs.yml +3 -2
- data/config/locales/de.yml +6 -2
- data/config/locales/el.yml +0 -1
- data/config/locales/en.yml +7 -2
- data/config/locales/es-MX.yml +7 -2
- data/config/locales/es-PY.yml +7 -2
- data/config/locales/es.yml +8 -3
- data/config/locales/eu.yml +4 -2
- data/config/locales/fi-plain.yml +7 -2
- data/config/locales/fi.yml +7 -2
- data/config/locales/fr-CA.yml +7 -2
- data/config/locales/fr.yml +7 -2
- data/config/locales/gl.yml +0 -1
- data/config/locales/hu.yml +0 -1
- data/config/locales/it.yml +0 -1
- data/config/locales/ja.yml +6 -2
- data/config/locales/lb.yml +0 -1
- data/config/locales/lt.yml +0 -1
- data/config/locales/lv.yml +0 -1
- data/config/locales/nl.yml +0 -1
- data/config/locales/no.yml +0 -1
- data/config/locales/pl.yml +4 -2
- data/config/locales/pt-BR.yml +0 -1
- data/config/locales/pt.yml +0 -1
- data/config/locales/ro-RO.yml +0 -2
- data/config/locales/sk.yml +0 -1
- data/config/locales/sq-AL.yml +0 -1
- data/config/locales/sr-CS.yml +0 -2
- data/config/locales/sv.yml +0 -1
- data/config/locales/tr-TR.yml +3 -2
- data/config/locales/zh-CN.yml +0 -1
- data/config/locales/zh-TW.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/factories.rb +6 -0
- data/lib/decidim/comments/test/shared_examples/comment_event.rb +33 -0
- 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 +16 -16
- 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: 3d55828915033b2a2a4a6443c316df98042bbbdc627f70c2d4bcf4ef9c983131
|
4
|
+
data.tar.gz: 247c5198c406f27a1ca6de26bcb8c2b8621b6789a4fd6aa92c2b4df4705d885f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ff6042bb9daf77d523c9d6ef46a4bf20d34cb726c2e9cd5d959877ead8491c498d987b46e9a64b1e865a25c62b9c1fe0f1f6d6be69f35f7b7b22537fdaba84d
|
7
|
+
data.tar.gz: 1da79ef396ae8c7e7bd4ccb96f8fc0e7f75af9b861f618efe09e41f608d11e9d36829fb299d705dfcd1479eaa05b519d6206145f0df0e774d7fa09f2a636a137
|
@@ -1,14 +1,14 @@
|
|
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
|
-
<%= icon "arrow-up-s-line" %>
|
5
|
-
<span class="hide-comment-replies font-normal"><%= t("decidim.components.comment.hide_replies") %></span>
|
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">
|
6
4
|
<%= icon "arrow-down-s-line" %>
|
7
|
-
<span
|
5
|
+
<span data-show-comment-reply class="font-normal"><%= t("decidim.components.comment.show_replies", count: replies.size) %></span>
|
6
|
+
<%= icon "arrow-up-s-line" %>
|
7
|
+
<span data-hide-comment-reply class="font-normal"><%= t("decidim.components.comment.hide_replies", count: replies.size) %></span>
|
8
8
|
</button>
|
9
9
|
<% end %>
|
10
10
|
<% if can_reply? %>
|
11
|
-
<button class="button button__sm button__text-secondary" data-controls="panel-<%= reply_id %>">
|
11
|
+
<button class="button button__sm button__text-secondary" data-controls="panel-<%= reply_id %>" id="panel-<%= reply_id %>-trigger">
|
12
12
|
<%= icon "chat-1-line" %>
|
13
13
|
<span class="font-normal"><%= t("decidim.components.comment.reply") %></span>
|
14
14
|
<%= icon "close-circle-line" %>
|
@@ -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 %>
|
@@ -1,10 +1,12 @@
|
|
1
|
-
<%= content_tag :div, id: "comment_#{model.id}", class: "comment relative", data: { comment_id: model.id } do %>
|
1
|
+
<%= content_tag :div, id: "comment_#{model.id}", class: "comment relative", role: "comment", data: { comment_id: model.id, parent: parent_element_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="sr-only"><%= comment_label %></div>
|
9
|
+
|
8
10
|
<span class="font-bold">
|
9
11
|
<%== cell("decidim/author", author_presenter) %>
|
10
12
|
</span>
|
@@ -18,7 +20,7 @@
|
|
18
20
|
<% end %>
|
19
21
|
|
20
22
|
<div class="relative ml-auto">
|
21
|
-
<button id="dropdown-trigger-<%= context_menu_id %>" data-component="dropdown" data-target="dropdown-menu-<%= context_menu_id %>">
|
23
|
+
<button id="dropdown-trigger-<%= context_menu_id %>" data-component="dropdown" data-target="dropdown-menu-<%= context_menu_id %>" aria-label="<%= t("decidim.components.comment.controls_label") %>">
|
22
24
|
…
|
23
25
|
</button>
|
24
26
|
|
@@ -61,13 +63,13 @@
|
|
61
63
|
</div>
|
62
64
|
</div>
|
63
65
|
|
64
|
-
<div
|
66
|
+
<div data-comment-footer data-component="accordion" id="accordion-<%= model.id %>">
|
65
67
|
<div class="comment__footer-grid">
|
66
68
|
<%= render :actions %>
|
67
69
|
<%= votes %>
|
68
70
|
</div>
|
69
71
|
<% if can_reply? %>
|
70
|
-
<div id="panel-<%= reply_id %>" class="add-comment
|
72
|
+
<div id="panel-<%= reply_id %>" class="add-comment" data-additional-reply>
|
71
73
|
<%== cell("decidim/comments/comment_form", model, root_depth:, order:) %>
|
72
74
|
</div>
|
73
75
|
<% end %>
|
@@ -4,8 +4,6 @@ module Decidim
|
|
4
4
|
module Comments
|
5
5
|
# A cell to display a single comment.
|
6
6
|
class CommentCell < Decidim::ViewModel
|
7
|
-
include ActionView::Helpers::DateHelper
|
8
|
-
include Decidim::IconHelper
|
9
7
|
include Decidim::ResourceHelper
|
10
8
|
include Cell::ViewModel::Partial
|
11
9
|
|
@@ -39,6 +37,24 @@ module Decidim
|
|
39
37
|
|
40
38
|
private
|
41
39
|
|
40
|
+
def parent_element_id
|
41
|
+
return unless reply?
|
42
|
+
|
43
|
+
"comment_#{model.decidim_commentable_id}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def comment_label
|
47
|
+
if reply?
|
48
|
+
t("decidim.components.comment.comment_label_reply", comment_id: model.id, parent_comment_id: model.decidim_commentable_id)
|
49
|
+
else
|
50
|
+
t("decidim.components.comment.comment_label", comment_id: model.id)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def reply?
|
55
|
+
model.decidim_commentable_type == model.class.name
|
56
|
+
end
|
57
|
+
|
42
58
|
def cache_hash
|
43
59
|
return @hash if defined?(@hash)
|
44
60
|
|
@@ -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>
|
@@ -5,7 +5,8 @@
|
|
5
5
|
t("decidim.components.comment_order_selector.order.#{order_value}"),
|
6
6
|
decidim_comments.comments_path(commentable_gid: model.to_signed_global_id.to_s, order: order_value, reload: 1),
|
7
7
|
class: "button button__sm button__text-secondary only:m-auto comment-order-by__item inline-block #{order_value == order ? "underline font-bold" : ""}",
|
8
|
-
remote: true
|
8
|
+
remote: true,
|
9
|
+
aria: { controls: threads_node_id }
|
9
10
|
) %>
|
10
11
|
</div>
|
11
12
|
<% end %>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
</div>
|
17
17
|
<%= single_comment_warning %>
|
18
18
|
<%= blocked_comments_warning %>
|
19
|
-
<div class="comment-threads">
|
19
|
+
<div class="comment-threads" id="<%= threads_node_id %>" aria-live="polite">
|
20
20
|
<%= comments_loading %>
|
21
21
|
<% comments.each do |comment| %>
|
22
22
|
<%= cell("decidim/comments/comment_thread", comment, order:) %>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<%# We cannot use the AnnouncementCell directly here as the link is escaped and it would not work %>
|
2
2
|
<div class="flash warning" data-announcement="">
|
3
|
-
<
|
3
|
+
<div class="flash__message">
|
4
4
|
<% if comment_permissions? %>
|
5
5
|
<p><%= blocked_comments_for_unauthorized_user_warning_link %></p>
|
6
6
|
<% else %>
|
7
7
|
<p><%= t("decidim.components.comments.blocked_comments_for_user_warning") %></p>
|
8
8
|
<% end %>
|
9
|
-
</
|
9
|
+
</div>
|
10
10
|
</div>
|
@@ -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?
|
@@ -30,7 +27,7 @@ module Decidim
|
|
30
27
|
|
31
28
|
def blocked_comments_warning
|
32
29
|
return unless comments_blocked?
|
33
|
-
return
|
30
|
+
return if user_comments_blocked?
|
34
31
|
|
35
32
|
render :blocked_comments_warning
|
36
33
|
end
|
@@ -88,6 +85,10 @@ module Decidim
|
|
88
85
|
"comments-for-#{commentable_type.demodulize}-#{model.id}"
|
89
86
|
end
|
90
87
|
|
88
|
+
def threads_node_id
|
89
|
+
"#{node_id}-threads"
|
90
|
+
end
|
91
|
+
|
91
92
|
def commentable_type
|
92
93
|
model.commentable_type
|
93
94
|
end
|
@@ -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,30 +323,30 @@ 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>
|
344
344
|
${generateCommentForm("Dummy", 123)}
|
345
345
|
</div>
|
346
346
|
<div class="flash primary loading-comments hidden">
|
347
|
-
<
|
347
|
+
<div class="flash__message">
|
348
348
|
Loading comments ...
|
349
|
-
</
|
349
|
+
</div>
|
350
350
|
</div>
|
351
351
|
</div>
|
352
352
|
</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", {
|