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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 648725e9925c3a017d8ac0d70283138a25938f9c92018346bc0a54ab7ab0eb17
|
4
|
+
data.tar.gz: 0f091351a41b0fc39873fa75e8ebd7ec8b403285a6a516a835a634e0e9968b70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2588f2b4cb9af337b4871dfa5ecdecb922ef6f99bbfab9756b831476d01688e2ecd1f9ad4ba656b8960dbcebab505cfcb72f8d88a7cf17d722d20bedd37972d1
|
7
|
+
data.tar.gz: 8386f0e42ec38344cd27863eb949a53a73d7bbbdb61146b6caa86738c724260355a0c14280132b40b6de6d841dcec201715c0930d69370334581dab9221b2d66
|
@@ -1,12 +1,18 @@
|
|
1
1
|
<div class="comment__actions">
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
<% if depth.zero? && has_replies_in_children? %>
|
3
|
+
<button class="button button__sm button__text-secondary comment__hide" data-controls="comment-<%= model.id %>-replies">
|
4
|
+
<%= icon "arrow-up-s-line" %>
|
5
|
+
<span class="hide-comment-replies font-normal"><%= t("decidim.components.comment.hide_replies") %></span>
|
6
|
+
<%= icon "arrow-down-s-line" %>
|
7
|
+
<span class="show-comment-replies font-normal"><%= t("decidim.components.comment.show_replies", count: replies.size, replies_count: replies.size ) %></span>
|
8
|
+
</button>
|
9
|
+
<% end %>
|
7
10
|
<% if can_reply? %>
|
8
|
-
<button class="
|
9
|
-
<%= icon "
|
11
|
+
<button class="button button__sm button__text-secondary" data-controls="panel-<%= reply_id %>">
|
12
|
+
<%= icon "chat-1-line" %>
|
13
|
+
<span class="font-normal"><%= t("decidim.components.comment.reply") %></span>
|
14
|
+
<%= icon "close-circle-line" %>
|
15
|
+
<span class="font-normal"><%= t("decidim.components.comment.cancel_reply") %></span>
|
10
16
|
</button>
|
11
17
|
<% end %>
|
12
18
|
</div>
|
@@ -1 +1,9 @@
|
|
1
|
-
<%= render partial: "decidim/comments/comments/delete
|
1
|
+
<%= render partial: "decidim/comments/comments/delete", formats: [:html], locals: { comment: model } %>
|
2
|
+
|
3
|
+
<div class="comment__footer" data-component="accordion" id="accordion-<%= model.id %>">
|
4
|
+
<div id="comment-<%= model.id %>-replies" class="<%= "comment-reply" if has_replies_in_children? %>">
|
5
|
+
<% if has_replies_in_children? %>
|
6
|
+
<%= render :replies %>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
</div>
|
@@ -1 +1 @@
|
|
1
|
-
<%= render partial: "decidim/comments/comments/moderated
|
1
|
+
<%= render partial: "decidim/comments/comments/moderated", formats: [:html], locals: { comment: model } %>
|
@@ -1,51 +1,88 @@
|
|
1
|
-
<%= content_tag :div, id: "comment_#{model.id}", class:
|
1
|
+
<%= content_tag :div, id: "comment_#{model.id}", class: "comment relative", data: { comment_id: model.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
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
<span class="font-bold">
|
9
|
+
<%== cell("decidim/author", author_presenter) %>
|
10
|
+
</span>
|
11
|
+
<span class="text-gray-2 text-sm">
|
12
|
+
<%= time_tag created_at, time_ago_in_words(created_at) %>
|
13
|
+
</span>
|
14
|
+
<% if edited? %>
|
15
|
+
<span class="label">
|
16
|
+
<%= t("decidim.components.comment.edited") %>
|
17
|
+
</span>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<div class="relative ml-auto">
|
21
|
+
<button id="dropdown-trigger-<%= context_menu_id %>" data-component="dropdown" data-target="dropdown-menu-<%= context_menu_id %>">
|
22
|
+
…
|
23
|
+
</button>
|
24
|
+
|
25
|
+
<div id="dropdown-menu-<%= context_menu_id %>" aria-hidden="true">
|
26
|
+
<ul class="dropdown dropdown__bottom divide-y divide-gray-3 px-4">
|
27
|
+
<% unless reloaded? %>
|
28
|
+
<li>
|
29
|
+
<%= cell("decidim/report_button", model, only_button: true, button_classes: "dropdown__item flex-row-reverse", modal_id: "flagModalComment#{model.id}") %>
|
30
|
+
</li>
|
31
|
+
<% end %>
|
32
|
+
<li>
|
33
|
+
<%= link_to "#{commentable_path("commentId" => model.id)}#comment_#{model.id}", target: "_blank", data: { "external-link": "false" }, class: "dropdown__item", title: t("decidim.components.comment.single_comment_link_title") do %>
|
34
|
+
<%= icon "share-line" %>
|
35
|
+
<span><%= t("decidim.components.comment.single_comment_link_title") %></span>
|
36
|
+
<% end %>
|
37
|
+
</li>
|
38
|
+
<% if model.authored_by?(current_user) %>
|
39
|
+
<li>
|
40
|
+
<button type="button" class="dropdown__item" data-dialog-open="<%= "editCommentModal#{model.id}" %>" title="<%= t("decidim.components.comment.edit") %>" aria-controls="<%= "editCommentModal#{model.id}" %>" aria-haspopup="dialog" tabindex="2">
|
41
|
+
<%= icon "edit-line" %>
|
42
|
+
<span><%= t("decidim.components.comment.edit") %></span>
|
43
|
+
</button>
|
44
|
+
</li>
|
45
|
+
<li>
|
46
|
+
<%= link_to comment_path, remote: true, method: :delete, class: "dropdown__item", data: { confirm: t("decidim.components.comment.confirm_destroy") }, tabindex: 3 do %>
|
47
|
+
<%= icon "delete-bin-line" %>
|
48
|
+
<span><%= t("decidim.components.comment.delete") %></span>
|
49
|
+
<% end %>
|
50
|
+
</li>
|
51
|
+
<% end %>
|
52
|
+
</ul>
|
21
53
|
</div>
|
22
54
|
</div>
|
23
|
-
<%= render :utilities %>
|
24
55
|
</div>
|
56
|
+
|
25
57
|
<div class="comment__content">
|
26
58
|
<%= alignment_badge %>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
<%= render :actions %>
|
31
|
-
<%= votes %>
|
59
|
+
<div class="editor-content">
|
60
|
+
<%= comment_body %>
|
61
|
+
</div>
|
32
62
|
</div>
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
<%=
|
63
|
+
|
64
|
+
<div class="comment__footer" data-component="accordion" id="accordion-<%= model.id %>">
|
65
|
+
<div class="comment__footer-grid">
|
66
|
+
<%= render :actions %>
|
67
|
+
<%= votes %>
|
68
|
+
</div>
|
69
|
+
<% if can_reply? %>
|
70
|
+
<div id="panel-<%= reply_id %>" class="add-comment comment__additionalreply">
|
71
|
+
<%== cell("decidim/comments/comment_form", model, root_depth:, order:) %>
|
72
|
+
</div>
|
38
73
|
<% end %>
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
<%= icon "pencil", class: "icon--small", role: "img", "aria-hidden": true %> <%= t("decidim.components.comment.reply") %>
|
45
|
-
</button>
|
46
|
-
</div>
|
47
|
-
<div class="add-comment hide" id="<%= reply_id %>" data-toggler=".hide">
|
48
|
-
<%== cell("decidim/comments/comment_form", model, root_depth: root_depth, order: order) %>
|
74
|
+
<div id="comment-<%= model.id %>-replies" class="<%= "comment-reply" if has_replies_in_children? %>">
|
75
|
+
<% if has_replies_in_children? %>
|
76
|
+
<%= render :replies %>
|
77
|
+
<% end %>
|
78
|
+
</div>
|
49
79
|
</div>
|
50
80
|
<% end %>
|
81
|
+
<% if current_user.present? %>
|
82
|
+
<%= cell("decidim/report_button", model, modal_id: "flagModalComment#{model.id}").flag_modal %>
|
83
|
+
<% end %>
|
84
|
+
|
85
|
+
<% if model.authored_by?(current_user) %>
|
86
|
+
<%= cell("decidim/comments/edit_comment_modal_form", model) %>
|
87
|
+
<% end %>
|
51
88
|
<% end %>
|
@@ -1,25 +1,25 @@
|
|
1
1
|
<div class="comment__votes">
|
2
2
|
<% if user_signed_in? %>
|
3
3
|
<%= vote_button_to decidim_comments.comment_votes_path(model, weight: 1), remote: true, disabled: voted_down?, class: votes_up_classes, title: t("decidim.components.up_vote_button.text") do %>
|
4
|
-
|
5
|
-
<%= icon "
|
6
|
-
<span
|
4
|
+
<%= icon "thumb-up-line" %>
|
5
|
+
<%= icon "thumb-up-fill" %>
|
6
|
+
<span><%= up_votes_count %></span>
|
7
7
|
<% end %>
|
8
8
|
<%= vote_button_to decidim_comments.comment_votes_path(model, weight: -1), remote: true, disabled: voted_up?, class: votes_down_classes, title: t("decidim.components.down_vote_button.text") do %>
|
9
|
-
|
10
|
-
<%= icon "
|
11
|
-
<span
|
9
|
+
<%= icon "thumb-down-line" %>
|
10
|
+
<%= icon "thumb-down-fill" %>
|
11
|
+
<span><%= down_votes_count %></span>
|
12
12
|
<% end %>
|
13
13
|
<% else %>
|
14
|
-
<button class="<%= votes_up_classes %> " title="<%= t("decidim.components.up_vote_button.text") %>" data-open="loginModal">
|
15
|
-
|
16
|
-
<%= icon "
|
17
|
-
<span
|
14
|
+
<button class="<%= votes_up_classes %> " title="<%= t("decidim.components.up_vote_button.text") %>" data-dialog-open="loginModal">
|
15
|
+
<%= icon "thumb-up-line", class: "fill-secondary" %>
|
16
|
+
<%= icon "thumb-up-fill", class: "fill-secondary" %>
|
17
|
+
<span><%= up_votes_count %></span>
|
18
18
|
</button>
|
19
|
-
<button class="<%= votes_down_classes %> " title="<%= t("decidim.components.down_vote_button.text") %>" data-open="loginModal">
|
20
|
-
|
21
|
-
<%= icon "
|
22
|
-
<span
|
19
|
+
<button class="<%= votes_down_classes %> " title="<%= t("decidim.components.down_vote_button.text") %>" data-dialog-open="loginModal">
|
20
|
+
<%= icon "thumb-down-line", class: "fill-secondary" %>
|
21
|
+
<%= icon "thumb-down-fill", class: "fill-secondary" %>
|
22
|
+
<span><%= down_votes_count %></span>
|
23
23
|
</button>
|
24
24
|
<% end %>
|
25
25
|
</div>
|
@@ -7,19 +7,23 @@ module Decidim
|
|
7
7
|
include CommentCellsHelper
|
8
8
|
|
9
9
|
def title
|
10
|
-
I18n.t(
|
11
|
-
"decidim.comments.last_activity.new_comment_at_html",
|
12
|
-
link: link_to(
|
13
|
-
root_commentable_title,
|
14
|
-
resource_link_path
|
15
|
-
)
|
16
|
-
)
|
10
|
+
I18n.t("decidim.comments.last_activity.new_comment")
|
17
11
|
end
|
18
12
|
|
19
13
|
def participatory_space
|
20
14
|
model.participatory_space_lazy
|
21
15
|
end
|
22
16
|
|
17
|
+
def participatory_space_link
|
18
|
+
link_to(root_commentable_title, resource_link_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def participatory_space_icon
|
22
|
+
resource_type_icon(root_commentable.class)
|
23
|
+
end
|
24
|
+
|
25
|
+
def hide_participatory_space? = false
|
26
|
+
|
23
27
|
def comment
|
24
28
|
model.resource_lazy
|
25
29
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Decidim
|
4
4
|
module Comments
|
5
5
|
# This cell renders the comment card for an instance of a Comment
|
6
|
-
# the default size is the
|
6
|
+
# the default size is the Search Card (:s)
|
7
7
|
class CommentCardCell < Decidim::ViewModel
|
8
8
|
include CommentCellsHelper
|
9
9
|
include Cell::ViewModel::Partial
|
@@ -15,7 +15,7 @@ module Decidim
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def card_size
|
18
|
-
"decidim/comments/
|
18
|
+
"decidim/comments/comment_s"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -47,8 +47,6 @@ module Decidim
|
|
47
47
|
hash.push(model.must_render_translation?(current_organization) ? 1 : 0)
|
48
48
|
hash.push(model.authored_by?(current_user) ? 1 : 0)
|
49
49
|
hash.push(model.reported_by?(current_user) ? 1 : 0)
|
50
|
-
hash.push(model.up_votes_count)
|
51
|
-
hash.push(model.down_votes_count)
|
52
50
|
hash.push(model.cache_key_with_version)
|
53
51
|
hash.push(model.author.cache_key_with_version)
|
54
52
|
@hash = hash.join(Decidim.cache_key_separator)
|
@@ -93,15 +91,6 @@ module Decidim
|
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
96
|
-
def comment_classes
|
97
|
-
classes = ["comment"]
|
98
|
-
if nested?
|
99
|
-
classes << "comment--nested"
|
100
|
-
classes << "comment--nested--alt" if nested_level_even?
|
101
|
-
end
|
102
|
-
classes.join(" ")
|
103
|
-
end
|
104
|
-
|
105
94
|
def alignment_badge_classes
|
106
95
|
classes = %w(label alignment)
|
107
96
|
case alignment
|
@@ -122,14 +111,14 @@ module Decidim
|
|
122
111
|
end
|
123
112
|
|
124
113
|
def votes_up_classes
|
125
|
-
classes = ["comment__votes--up"]
|
114
|
+
classes = ["button button__sm button__text-secondary js-comment__votes--up"]
|
126
115
|
classes << "is-vote-selected" if voted_up?
|
127
116
|
classes << "is-vote-notselected" if voted_down?
|
128
117
|
classes.join(" ")
|
129
118
|
end
|
130
119
|
|
131
120
|
def votes_down_classes
|
132
|
-
classes = ["comment__votes--down"]
|
121
|
+
classes = ["button button__sm button__text-secondary js-comment__votes--down"]
|
133
122
|
classes << "is-vote-selected" if voted_down?
|
134
123
|
classes << "is-vote-notselected" if voted_up?
|
135
124
|
classes.join(" ")
|
@@ -148,11 +137,11 @@ module Decidim
|
|
148
137
|
end
|
149
138
|
|
150
139
|
def up_votes_count
|
151
|
-
model.
|
140
|
+
model.up_votes.count
|
152
141
|
end
|
153
142
|
|
154
143
|
def down_votes_count
|
155
|
-
model.
|
144
|
+
model.down_votes.count
|
156
145
|
end
|
157
146
|
|
158
147
|
def root_depth
|
@@ -168,11 +157,11 @@ module Decidim
|
|
168
157
|
end
|
169
158
|
|
170
159
|
def voted_up?
|
171
|
-
|
160
|
+
model.up_voted_by?(current_user)
|
172
161
|
end
|
173
162
|
|
174
163
|
def voted_down?
|
175
|
-
|
164
|
+
model.down_voted_by?(current_user)
|
176
165
|
end
|
177
166
|
|
178
167
|
def nested?
|
@@ -200,13 +189,12 @@ module Decidim
|
|
200
189
|
root_commentable.try(:component)
|
201
190
|
end
|
202
191
|
|
203
|
-
def vote_button_to(path, params, &
|
192
|
+
def vote_button_to(path, params, &)
|
204
193
|
# actions are linked to objects belonging to a component
|
205
|
-
# In consultations, a question belong to a participatory_space but it has comments
|
206
194
|
# To apply :comment permission, the modal authorizer should be refactored to allow participatory spaces-level comments
|
207
|
-
return button_to(path, params, &
|
195
|
+
return button_to(path, params, &) unless current_component
|
208
196
|
|
209
|
-
action_authorized_button_to(:vote_comment, path, params.merge(resource: root_commentable), &
|
197
|
+
action_authorized_button_to(:vote_comment, path, params.merge(resource: root_commentable), &)
|
210
198
|
end
|
211
199
|
end
|
212
200
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<div class="
|
2
|
-
<label for="<%= comment_as_id %>">
|
1
|
+
<div class="comment__as">
|
2
|
+
<label class="mr-2 inline-block" for="<%= comment_as_id %>">
|
3
3
|
<%= t("decidim.components.add_comment_form.form.user_group_id.label") %>
|
4
4
|
</label>
|
5
|
-
<select id="<%= comment_as_id %>" name="comment[user_group_id]">
|
5
|
+
<select class="p-2" id="<%= comment_as_id %>" name="comment[user_group_id]">
|
6
6
|
<% comment_as_options.each do |option| %>
|
7
7
|
<option value="<%= option[1] %>"><%= option[0] %></option>
|
8
8
|
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div>
|
2
|
+
<span class="comment__opinion-label"><%= t("decidim.components.add_comment_form.opinion.label") %></span>
|
3
|
+
<div class="opinion-toggle comment__opinion-container">
|
4
|
+
<button type="button" aria-pressed="false" class="opinion-toggle--ok" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.positive_selected") %>">
|
5
|
+
<span><%= t("decidim.components.comment.alignment.in_favor") %></span>
|
6
|
+
<%= icon "thumb-up-line" %>
|
7
|
+
</button>
|
8
|
+
<button type="button" aria-pressed="true" class="opinion-toggle--meh is-active" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.neutral_selected") %>">
|
9
|
+
<span><%= t("decidim.components.add_comment_form.opinion.neutral") %></span>
|
10
|
+
<%= icon "loader-3-line" %>
|
11
|
+
</button>
|
12
|
+
<button type="button" aria-pressed="false" class="opinion-toggle--ko" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.negative_selected") %>">
|
13
|
+
<span><%= t("decidim.components.comment.alignment.against") %></span>
|
14
|
+
<%= icon "thumb-down-line" %>
|
15
|
+
</button>
|
16
|
+
<div role="alert" aria-live="assertive" aria-atomic="true" class="selected-state sr-only"></div>
|
17
|
+
</div>
|
18
|
+
</div>
|
@@ -1,24 +1,41 @@
|
|
1
|
-
<%= form_for(form_object, url: decidim_comments.comments_path(order:
|
1
|
+
<%= form_for(form_object, url: decidim_comments.comments_path(order:), method: :post, remote: true, html: { id: form_id }) do |form| %>
|
2
2
|
<%= form.hidden_field :commentable_gid, id: nil %>
|
3
3
|
<%= form.hidden_field :alignment, id: nil, class: "alignment-input" %>
|
4
4
|
<%= comment_as_for(form) %>
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
<div class="flex justify-between items-end mb-4">
|
7
|
+
<label class="comment__form-label" for="<%= add_comment_id %>">
|
7
8
|
<%= t("decidim.components.add_comment_form.form.body.label") %>
|
8
9
|
</label>
|
9
|
-
|
10
|
-
<%= form.text_area(
|
11
|
-
:body,
|
12
|
-
id: add_comment_id,
|
13
|
-
rows: 4,
|
14
|
-
maxlength: comments_max_length,
|
15
|
-
required: true,
|
16
|
-
placeholder: t("decidim.components.add_comment_form.form.body.placeholder"),
|
17
|
-
label: false,
|
18
|
-
data: { remaining_characters: "##{add_comment_id}-remaining-characters", input_emoji: true }
|
19
|
-
) %>
|
20
|
-
</div>
|
21
|
-
<button type="submit" class="button button--sc" disabled="disabled"><%= t("decidim.components.add_comment_form.form.submit") %></button>
|
10
|
+
|
22
11
|
<span id="<%= add_comment_id %>-remaining-characters" class="remaining-character-count"></span>
|
23
12
|
</div>
|
13
|
+
|
14
|
+
<%= form.text_area(
|
15
|
+
:body,
|
16
|
+
id: add_comment_id,
|
17
|
+
class: "w-full min-h-[160px]",
|
18
|
+
maxlength: comments_max_length,
|
19
|
+
required: true,
|
20
|
+
placeholder: t("decidim.components.add_comment_form.form.body.placeholder"),
|
21
|
+
label: false,
|
22
|
+
data: { remaining_characters: "##{add_comment_id}-remaining-characters", input_emoji: true }
|
23
|
+
) %>
|
24
|
+
|
25
|
+
<div class="comment__form-submit">
|
26
|
+
<% if alignment_enabled? %>
|
27
|
+
<%= render :opinion %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<button type="submit" class="button button__sm button__secondary" disabled="disabled">
|
31
|
+
<span>
|
32
|
+
<% if reply? %>
|
33
|
+
<%= t("decidim.components.add_comment_form.form.submit_reply") %>
|
34
|
+
<% else %>
|
35
|
+
<%= t("decidim.components.add_comment_form.form.submit_root_comment") %>
|
36
|
+
<% end %>
|
37
|
+
</span>
|
38
|
+
<%= icon "chat-1-line" %>
|
39
|
+
</button>
|
40
|
+
</div>
|
24
41
|
<% end %>
|
@@ -12,7 +12,7 @@ module Decidim
|
|
12
12
|
# Note that the form.select does not seem to work correctly in the cell
|
13
13
|
# context. The Rails form builder tries to call @template.select which
|
14
14
|
# is not available for the cell objects.
|
15
|
-
render view: :comment_as, locals: { form:
|
15
|
+
render view: :comment_as, locals: { form: }
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
@@ -38,6 +38,14 @@ module Decidim
|
|
38
38
|
model.commentable_type
|
39
39
|
end
|
40
40
|
|
41
|
+
def reply?
|
42
|
+
model.is_a?(Decidim::Comments::Comment)
|
43
|
+
end
|
44
|
+
|
45
|
+
def alignment_enabled?
|
46
|
+
model.comments_have_alignment?
|
47
|
+
end
|
48
|
+
|
41
49
|
def form_id
|
42
50
|
"new_comment_for_#{commentable_type.demodulize}_#{model.id}"
|
43
51
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Comments
|
5
|
+
# This cell renders the comment metadata for a card
|
6
|
+
class CommentMetadataCell < Decidim::CardMetadataCell
|
7
|
+
delegate :root_commentable, to: :model
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def items
|
12
|
+
[author_item, commentable_item, comments_count_item]
|
13
|
+
end
|
14
|
+
|
15
|
+
def commentable_item
|
16
|
+
{
|
17
|
+
text: decidim_html_escape(translated_attribute(root_commentable.title)),
|
18
|
+
icon: resource_type_icon_key(root_commentable.class)
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def comments_count_item
|
23
|
+
super(root_commentable)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Comments
|
5
|
+
# This cell renders the Search (:s) comment card
|
6
|
+
# for a given instance of a Comment
|
7
|
+
class CommentSCell < Decidim::CardSCell
|
8
|
+
include CommentCellsHelper
|
9
|
+
|
10
|
+
alias comment model
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def title
|
15
|
+
resource_link_text
|
16
|
+
end
|
17
|
+
|
18
|
+
def resource_path
|
19
|
+
resource_link_path
|
20
|
+
end
|
21
|
+
|
22
|
+
def metadata_cell
|
23
|
+
"decidim/comments/comment_metadata"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,6 +1,3 @@
|
|
1
|
-
<div>
|
2
|
-
<%=
|
3
|
-
<div class="comment-thread">
|
4
|
-
<%= cell("decidim/comments/comment", model, root_depth: model.depth, order: order) %>
|
5
|
-
</div>
|
1
|
+
<div class="comment-thread">
|
2
|
+
<%= cell("decidim/comments/comment", model, root_depth: model.depth, order:) %>
|
6
3
|
</div>
|
@@ -1,25 +1,6 @@
|
|
1
1
|
<div class="add-comment">
|
2
|
-
<h4 class="section-heading"><%= t("decidim.components.add_comment_form.title") %></h4>
|
3
|
-
|
4
2
|
<% if user_signed_in? %>
|
5
|
-
|
6
|
-
<div class="opinion-toggle button-group">
|
7
|
-
<span class="show-for-sr"><%= t("decidim.components.add_comment_form.opinion.label") %></span>
|
8
|
-
<button aria-pressed="false" class="button tiny button--muted opinion-toggle--ok" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.positive_selected") %>">
|
9
|
-
<%= icon "thumb-up", role: "img", "aria-hidden": true %>
|
10
|
-
<span class="show-for-sr"><%= t("decidim.components.add_comment_form.opinion.positive") %></span>
|
11
|
-
</button>
|
12
|
-
<button aria-pressed="true" class="button tiny button--muted opinion-toggle--meh is-active" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.neutral_selected") %>">
|
13
|
-
<%= t("decidim.components.add_comment_form.opinion.neutral") %>
|
14
|
-
</button>
|
15
|
-
<button aria-pressed="false" class="button tiny button--muted opinion-toggle--ko" data-selected-label="<%= t("decidim.components.add_comment_form.opinion.negative_selected") %>">
|
16
|
-
<%= icon "thumb-down", role: "img", "aria-hidden": true %>
|
17
|
-
<span class="show-for-sr"><%= t("decidim.components.add_comment_form.opinion.negative") %></span>
|
18
|
-
</button>
|
19
|
-
<div role="alert" aria-live="assertive" aria-atomic="true" class="selected-state show-for-sr"></div>
|
20
|
-
</div>
|
21
|
-
<% end %>
|
22
|
-
<%== cell("decidim/comments/comment_form", model, root_depth: root_depth) %>
|
3
|
+
<%== cell("decidim/comments/comment_form", model, root_depth:) %>
|
23
4
|
<% else %>
|
24
5
|
<p>
|
25
6
|
<span>
|