decidim-comments 0.30.2 → 0.31.0.rc1
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/deletion_data.erb +1 -1
- data/app/cells/decidim/comments/comment/show.erb +12 -12
- data/app/cells/decidim/comments/comment_cell.rb +1 -3
- data/app/cells/decidim/comments/comment_form/comment_as.erb +5 -24
- data/app/cells/decidim/comments/comment_form/show.erb +3 -3
- data/app/cells/decidim/comments/comment_form_cell.rb +5 -20
- data/app/cells/decidim/comments/comments/order_control.erb +1 -1
- data/app/cells/decidim/comments/edit_comment_modal_form/show.erb +2 -2
- data/app/commands/decidim/comments/create_comment.rb +3 -5
- data/app/events/decidim/comments/comment_event.rb +3 -10
- data/app/forms/decidim/comments/comment_form.rb +0 -1
- data/app/models/decidim/comments/comment.rb +2 -2
- data/app/models/decidim/comments/seed.rb +4 -16
- data/app/packs/src/decidim/comments/comments.component.js +0 -7
- data/app/packs/src/decidim/comments/comments.component.test.js +4 -16
- data/app/packs/src/decidim/comments/comments.js +1 -1
- data/app/packs/src/decidim/comments/comments_mobile_modal.js +1 -1
- data/app/packs/stylesheets/comments.scss +1 -5
- data/app/queries/decidim/comments/sorted_comments.rb +1 -1
- data/app/services/decidim/comments/new_comment_notification_creator.rb +2 -27
- data/app/views/decidim/comments/admin/shared/_availability_fields.html.erb +1 -1
- data/app/views/decidim/comments/comments/delete.js.erb +4 -2
- data/app/views/decidim/comments/comments/reload.js.erb +0 -1
- data/app/views/decidim/comments/comments/update.js.erb +3 -1
- data/config/assets.rb +2 -2
- data/config/locales/ar.yml +0 -18
- data/config/locales/bg.yml +0 -18
- data/config/locales/bs-BA.yml +0 -8
- data/config/locales/ca-IT.yml +0 -20
- data/config/locales/ca.yml +0 -20
- data/config/locales/cs.yml +0 -20
- data/config/locales/de.yml +0 -20
- data/config/locales/el.yml +0 -18
- data/config/locales/en.yml +0 -20
- data/config/locales/es-MX.yml +0 -20
- data/config/locales/es-PY.yml +0 -20
- data/config/locales/es.yml +0 -20
- data/config/locales/eu.yml +0 -20
- data/config/locales/fi-plain.yml +0 -20
- data/config/locales/fi.yml +0 -20
- data/config/locales/fr-CA.yml +0 -23
- data/config/locales/fr.yml +0 -23
- data/config/locales/ga-IE.yml +0 -5
- data/config/locales/gl.yml +0 -11
- data/config/locales/hu.yml +0 -18
- data/config/locales/id-ID.yml +0 -11
- data/config/locales/is-IS.yml +0 -5
- data/config/locales/it.yml +0 -18
- data/config/locales/ja.yml +0 -20
- data/config/locales/lb.yml +0 -18
- data/config/locales/lt.yml +0 -18
- data/config/locales/lv.yml +0 -18
- data/config/locales/nl.yml +0 -18
- data/config/locales/no.yml +0 -18
- data/config/locales/pl.yml +0 -18
- data/config/locales/pt-BR.yml +0 -18
- data/config/locales/pt.yml +0 -18
- data/config/locales/ro-RO.yml +0 -20
- data/config/locales/ru.yml +0 -11
- data/config/locales/si-LK.yml +0 -2
- data/config/locales/sk.yml +0 -18
- data/config/locales/sq-AL.yml +0 -2
- data/config/locales/sr-CS.yml +0 -9
- data/config/locales/sv.yml +0 -20
- data/config/locales/tr-TR.yml +0 -18
- data/config/locales/uk.yml +0 -6
- data/config/locales/zh-CN.yml +0 -18
- data/config/locales/zh-TW.yml +0 -18
- data/db/migrate/20181003080320_fix_user_groups_ids_in_comments.rb +8 -1
- data/lib/decidim/api/comment_type.rb +1 -4
- data/lib/decidim/api/commentable_interface.rb +7 -13
- data/lib/decidim/api/commentable_mutation_type.rb +2 -3
- data/lib/decidim/comments/comment_serializer.rb +0 -4
- data/lib/decidim/comments/comment_vote_serializer.rb +0 -4
- data/lib/decidim/comments/commentable.rb +4 -0
- data/lib/decidim/comments/engine.rb +6 -20
- data/lib/decidim/comments/test/factories.rb +1 -1
- data/lib/decidim/comments/test/shared_examples/comment_event.rb +1 -10
- data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +0 -2
- data/lib/decidim/comments/version.rb +1 -1
- metadata +8 -12
- data/app/events/decidim/comments/comment_by_followed_user_group_event.rb +0 -9
- data/app/events/decidim/comments/user_group_mentioned_event.rb +0 -10
- data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +0 -50
- data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +0 -97
data/config/locales/tr-TR.yml
CHANGED
@@ -5,7 +5,6 @@ tr:
|
|
5
5
|
decidim/comments/comment_by_followed_user_event: Yorum
|
6
6
|
decidim/comments/comment_created_event: Yorum
|
7
7
|
decidim/comments/reply_created_event: Yorum cevabı
|
8
|
-
decidim/comments/user_group_mentioned_event: Bahset
|
9
8
|
decidim/comments/user_mentioned_event: Bahset
|
10
9
|
activerecord:
|
11
10
|
models:
|
@@ -33,8 +32,6 @@ tr:
|
|
33
32
|
body:
|
34
33
|
label: Yorum
|
35
34
|
placeholder: Bunun hakkında ne düşünüyorsun?
|
36
|
-
user_group_id:
|
37
|
-
label: Olarak yorum yap
|
38
35
|
opinion:
|
39
36
|
neutral: Tarafsız
|
40
37
|
remaining_characters: "%{count} karakter kaldı"
|
@@ -85,11 +82,6 @@ tr:
|
|
85
82
|
email_outro: Bu bildirimi %{author_name} adlı yazarı takip ettiğiniz için aldınız. Bu grubu profil sayfasından takip etmeyi bırakabilirsiniz.
|
86
83
|
email_subject: '%{author_name} %{resource_title} alanında yeni bir yorum yaptı'
|
87
84
|
notification_title: <a href="%{resource_path}">%{resource_title} </a> içinde <a href="%{author_path}">%{author_name} %{author_nickname} </a> tarafından yeni bir yorum var.
|
88
|
-
comment_by_followed_user_group:
|
89
|
-
email_intro: '%{author_name} grubu %{resource_title} alanında bir yorum bıraktı. Bu sayfada okuyabilirsiniz:'
|
90
|
-
email_outro: Bu bildirimi %{author_name} adlı yazarı takip ettiğiniz için aldınız. Bu grubu profil sayfasından takip etmeyi bırakabilirsiniz.
|
91
|
-
email_subject: '%{author_name} %{resource_title} alanında yeni bir yorum yaptı'
|
92
|
-
notification_title: <a href="%{resource_path}">%{resource_title} </a> içinde <a href="%{author_path}">%{author_name} %{author_nickname} </a> tarafından yeni bir yorum var.
|
93
85
|
comment_created:
|
94
86
|
email_intro: "%{resource_title} alanında yorum yapıldı. Bu sayfadaki yorumu okuyabilirsiniz:"
|
95
87
|
email_outro: '"%{resource_title}" alanında veya yazarı takip ettiğiniz için bu bildirimi aldınız. Bunu önceki linkten takip edebilirsiniz.'
|
@@ -100,18 +92,8 @@ tr:
|
|
100
92
|
email_outro: Yorumunuz yanıtlandığı için bu bildirimi aldınız.
|
101
93
|
email_subject: "%{author_name}, yorumunuzu %{resource_title} alanında yanıtladı"
|
102
94
|
notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> <a href="%{resource_path}">%{resource_title}</a> alanında yorumunuzu yanıtladı
|
103
|
-
user_group_mentioned:
|
104
|
-
email_intro: Ait olduğunuz bir gruptan bahsedildi
|
105
|
-
email_outro: Bu bildirimi, %{resource_title} içinde adı geçen %{group_name} grubunun bir üyesi olduğunuz için aldınız.
|
106
|
-
email_subject: '%{resource_title} içinde %{group_name} üyesi olarak bahsedildiniz'
|
107
|
-
notification_title: <a href="%{resource_path}">%{resource_title} </a> ’de <a href="%{author_path}">%{author_name} %{author_nickname} </a> tarafından bir <a href="%{group_path}">%{group_name} %{group_nickname} </a> üyesi
|
108
95
|
user_mentioned:
|
109
96
|
email_intro: Sen bahsedildin
|
110
97
|
email_outro: Bu bildirimi, sizden %{resource_title} alanında bahsedildiği için aldınız.
|
111
98
|
email_subject: '%{resource_title} alanında bahsedildiniz'
|
112
99
|
notification_title: <a href="%{resource_path}">%{resource_title} </a> alanında <a href="%{author_path}">%{author_name} %{author_nickname} </a> tarafından bahsedildi
|
113
|
-
metrics:
|
114
|
-
comments:
|
115
|
-
description: Katılımcılar tarafından oluşturulan yorum sayısı
|
116
|
-
object: yorumlar
|
117
|
-
title: Yorumlar
|
data/config/locales/uk.yml
CHANGED
@@ -5,7 +5,6 @@ uk:
|
|
5
5
|
decidim/comments/comment_by_followed_user_event: Коментар
|
6
6
|
decidim/comments/comment_created_event: Коментар
|
7
7
|
decidim/comments/reply_created_event: Відповідь на коментар
|
8
|
-
decidim/comments/user_group_mentioned_event: Згадка
|
9
8
|
decidim/comments/user_mentioned_event: Згадка
|
10
9
|
activerecord:
|
11
10
|
models:
|
@@ -30,8 +29,6 @@ uk:
|
|
30
29
|
body:
|
31
30
|
label: Коментар
|
32
31
|
placeholder: Що ви думаєте з цього приводу?
|
33
|
-
user_group_id:
|
34
|
-
label: Коментувати як
|
35
32
|
opinion:
|
36
33
|
neutral: Безсторонньо
|
37
34
|
remaining_characters: "Залишилось %{count} символів"
|
@@ -68,9 +65,6 @@ uk:
|
|
68
65
|
email_outro: Ви отримали це сповіщення, тому що ви стежите за %{author_name}. Ви можете припинити стежити за ним на сторінці його профілю.
|
69
66
|
email_subject: У %{resource_title} з'явився новий коментар від %{author_name}
|
70
67
|
notification_title: У <a href="%{resource_path}">%{resource_title}</a> з'явився новий коментар від <a href="%{author_path}">%{author_name} %{author_nickname}</a>.
|
71
|
-
comment_by_followed_user_group:
|
72
|
-
email_subject: У %{resource_title} з'явився новий коментар від %{author_name}
|
73
|
-
notification_title: У <a href="%{resource_path}">%{resource_title}</a> з'явився новий коментар від <a href="%{author_path}">%{author_name} %{author_nickname}</a>.
|
74
68
|
comment_created:
|
75
69
|
email_intro: "%{resource_title} прокоментували. Ви можете прочитати коментар на сторінці:"
|
76
70
|
email_outro: Ви отримали це сповіщення, тому що ви стежите за "%{resource_title}". Ви можете припинити стежити за ним, перейшовши за наведеним вище посиланням.
|
data/config/locales/zh-CN.yml
CHANGED
@@ -5,7 +5,6 @@ zh-CN:
|
|
5
5
|
decidim/comments/comment_by_followed_user_event: 评论
|
6
6
|
decidim/comments/comment_created_event: 评论
|
7
7
|
decidim/comments/reply_created_event: 评论回复
|
8
|
-
decidim/comments/user_group_mentioned_event: 提到了
|
9
8
|
decidim/comments/user_mentioned_event: 提到了
|
10
9
|
activerecord:
|
11
10
|
models:
|
@@ -28,8 +27,6 @@ zh-CN:
|
|
28
27
|
body:
|
29
28
|
label: 评论
|
30
29
|
placeholder: 你对此有什么看法?
|
31
|
-
user_group_id:
|
32
|
-
label: 评论为
|
33
30
|
opinion:
|
34
31
|
neutral: 中性的
|
35
32
|
remaining_characters: "剩余 %{count} 个字符"
|
@@ -74,11 +71,6 @@ zh-CN:
|
|
74
71
|
email_outro: 您收到此通知是因为您正在关注 %{author_name}。您可以从其个人资料页面取消关注此用户。
|
75
72
|
email_subject: '%{author_name} 在 %{resource_title} 有一个新评论'
|
76
73
|
notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> 在 <a href="%{resource_path}">%{resource_title}</a> 有新的评论。
|
77
|
-
comment_by_followed_user_group:
|
78
|
-
email_intro: '组 %{author_name} 在 %{resource_title}留下了一个评论。您可以在这个页面阅读它:'
|
79
|
-
email_outro: 您收到此通知是因为您正在关注 %{author_name}。您可以从其个人资料页面取消关注此组。
|
80
|
-
email_subject: '%{author_name} 在 %{resource_title} 有一个新评论'
|
81
|
-
notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> 在 <a href="%{resource_path}">%{resource_title}</a> 有新的评论。
|
82
74
|
comment_created:
|
83
75
|
email_intro: "%{resource_title} 已被评论。您可以阅读此页面中的评论:"
|
84
76
|
email_outro: 您收到此通知是因为您正在关注"%{resource_title}"或其作者。您可以从上一个链接取消关注它。
|
@@ -89,18 +81,8 @@ zh-CN:
|
|
89
81
|
email_outro: 您收到此通知是因为您的评论已被回复。
|
90
82
|
email_subject: "%{author_name} 在 %{resource_title} 回复了您的评论"
|
91
83
|
notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> 回复了您在 <a href="%{resource_path}">%{resource_title}</a>
|
92
|
-
user_group_mentioned:
|
93
|
-
email_intro: 已经提到您所属的组
|
94
|
-
email_outro: 您收到此通知是因为您是在 %{group_name} 中提及的组 %{resource_title} 的成员。
|
95
|
-
email_subject: 您已在 %{resource_title} 中被提及为 %{group_name} 的成员
|
96
|
-
notification_title: 您在 <a href="%{resource_path}">%{resource_title}中提到</a> <a href="%{author_path}">%{author_name} %{author_nickname}</a> 作为 <a href="%{group_path}">%{group_name} %{group_nickname}</a>
|
97
84
|
user_mentioned:
|
98
85
|
email_intro: 您已被提到。
|
99
86
|
email_outro: 您收到此通知是因为您已在 %{resource_title} 中被提及。
|
100
87
|
email_subject: 您已在 %{resource_title} 中被提及了
|
101
88
|
notification_title: 您在 <a href="%{resource_path}">%{resource_title}中提到</a> <a href="%{author_path}">%{author_name} %{author_nickname}</a>
|
102
|
-
metrics:
|
103
|
-
comments:
|
104
|
-
description: 与会者生成的评论数
|
105
|
-
object: 评论
|
106
|
-
title: 评论
|
data/config/locales/zh-TW.yml
CHANGED
@@ -6,7 +6,6 @@ zh-TW:
|
|
6
6
|
decidim/comments/comment_created_event: 評論
|
7
7
|
decidim/comments/comment_upvoted_event: 評論已獲得讚同
|
8
8
|
decidim/comments/reply_created_event: 評論回覆
|
9
|
-
decidim/comments/user_group_mentioned_event: 提及
|
10
9
|
decidim/comments/user_mentioned_event: 提及
|
11
10
|
activerecord:
|
12
11
|
models:
|
@@ -44,8 +43,6 @@ zh-TW:
|
|
44
43
|
label: 評論
|
45
44
|
placeholder: 你有什麼想法?
|
46
45
|
form_error: 文字為必填欄位,且不可超過 %{length} 個字元。
|
47
|
-
user_group_id:
|
48
|
-
label: 評論者:
|
49
46
|
opinion:
|
50
47
|
label: 關於此議題,您的意見
|
51
48
|
negative: 負面
|
@@ -118,11 +115,6 @@ zh-TW:
|
|
118
115
|
email_outro: 您收到此通知是因為您正在關注%{author_name}。您可以從他們的個人資料頁面取消關注該用戶。
|
119
116
|
email_subject: '%{author_name} 在%{resource_title} 發表了一則新的評論'
|
120
117
|
notification_title: 在<a href="%{resource_path}">%{resource_title}</a>中,<a href="%{author_path}">%{author_name} %{author_nickname}</a>有了一個新的評論。
|
121
|
-
comment_by_followed_user_group:
|
122
|
-
email_intro: '%{author_name} 群組在%{resource_title} 中留下了一則評論。您可以在此頁面中閱讀它:'
|
123
|
-
email_outro: 您收到此通知是因為您正在關注%{author_name}。您可以從其個人資料頁面取消關注此群組。
|
124
|
-
email_subject: '%{author_name} 在%{resource_title} 發表了一則新的評論'
|
125
|
-
notification_title: 在<a href="%{resource_path}">%{resource_title}</a>中,<a href="%{author_path}">%{author_name} %{author_nickname}</a>有了一個新的評論。
|
126
118
|
comment_created:
|
127
119
|
email_intro: "%{resource_title} 已被評論。您可以在此頁面中閱讀評論:"
|
128
120
|
email_outro: 您收到此通知是因為您正在關注「%{resource_title}」或其作者。您可以從上面的連結取消關注。
|
@@ -143,21 +135,11 @@ zh-TW:
|
|
143
135
|
email_outro: 你收到此通知是因為有人回覆了你的評論。
|
144
136
|
email_subject: "%{author_name} 回覆了你在 %{resource_title} 中的評論。"
|
145
137
|
notification_title: <a href="%{author_path}">%{author_name} %{author_nickname}</a> 在 <a href="%{resource_path}">%{resource_title}</a> 中回覆了你的評論。
|
146
|
-
user_group_mentioned:
|
147
|
-
email_intro: 你所屬的群組被提及了
|
148
|
-
email_outro: 你收到了這個通知,因為你是 %{group_name} 的成員,而該小組在 %{resource_title} 中被提及。
|
149
|
-
email_subject: 你作為 %{group_name} 的成員在 %{resource_title} 中被提及
|
150
|
-
notification_title: 你作為<a href="%{group_path}">%{group_name} %{group_nickname}</a>的成員,被<a href="%{author_path}">%{author_name} %{author_nickname}</a>在<a href="%{resource_path}">%{resource_title}</a>中提及
|
151
138
|
user_mentioned:
|
152
139
|
email_intro: 您已被提及
|
153
140
|
email_outro: 您收到了此通知,因為您被提及在 %{resource_title} 中。
|
154
141
|
email_subject: 您被提及在 %{resource_title} 中
|
155
142
|
notification_title: 您被 <a href="%{author_path}">%{author_name} %{author_nickname}</a> 在 <a href="%{resource_path}">%{resource_title}</a> 中提及。
|
156
|
-
metrics:
|
157
|
-
comments:
|
158
|
-
description: 參與者產生的評論數量
|
159
|
-
object: 評論
|
160
|
-
title: 評論
|
161
143
|
errors:
|
162
144
|
messages:
|
163
145
|
cannot_have_comments: 無法評論
|
@@ -1,9 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class FixUserGroupsIdsInComments < ActiveRecord::Migration[5.2]
|
4
|
+
class UserGroup < ApplicationRecord
|
5
|
+
self.table_name = :decidim_users
|
6
|
+
self.inheritance_column = nil # disable the default inheritance
|
7
|
+
|
8
|
+
default_scope { where(type: "Decidim::UserGroup") }
|
9
|
+
end
|
10
|
+
|
4
11
|
# rubocop:disable Rails/SkipsModelValidations
|
5
12
|
def change
|
6
|
-
|
13
|
+
UserGroup.find_each do |group|
|
7
14
|
old_id = group.extended_data["old_user_group_id"]
|
8
15
|
next unless old_id
|
9
16
|
|
@@ -22,12 +22,9 @@ module Decidim
|
|
22
22
|
field :sgid, GraphQL::Types::String, "The Comment's signed global id", null: false
|
23
23
|
field :up_voted, GraphQL::Types::Boolean, "Check if the current user has upvoted the comment", null: false
|
24
24
|
field :up_votes, GraphQL::Types::Int, "The number of comment's upVotes", null: false, method: :up_votes_count
|
25
|
+
field :url, GraphQL::Types::String, "The URL for this meeting", null: false, method: :reported_content_url
|
25
26
|
field :user_allowed_to_comment, GraphQL::Types::Boolean, "Check if the current user can comment", null: false
|
26
27
|
|
27
|
-
def author
|
28
|
-
object.user_group || object.author
|
29
|
-
end
|
30
|
-
|
31
28
|
def sgid
|
32
29
|
object.to_sgid.to_s
|
33
30
|
end
|
@@ -7,29 +7,23 @@ module Decidim
|
|
7
7
|
include Decidim::Api::Types::BaseInterface
|
8
8
|
description "A commentable interface"
|
9
9
|
|
10
|
-
field :id, GraphQL::Types::ID, "The commentable's ID", null: false
|
11
|
-
field :type, GraphQL::Types::String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`", method: :commentable_type, null: false
|
12
10
|
field :accepts_new_comments, GraphQL::Types::Boolean, "Whether the object can have new comments or not", method: :accepts_new_comments?, null: false
|
13
|
-
field :comments_have_alignment, GraphQL::Types::Boolean, "Whether the object comments have alignment or not", method: :comments_have_alignment?, null: false
|
14
|
-
field :comments_have_votes, GraphQL::Types::Boolean, "Whether the object comments have votes or not", method: :comments_have_votes?, null: false
|
15
|
-
field :total_comments_count, GraphQL::Types::Int, description: "The number of comments in all levels this resource holds", method: :comments_count, null: false
|
16
|
-
field :has_comments, GraphQL::Types::Boolean, "Check if the commentable has comments", null: false
|
17
|
-
field :user_allowed_to_comment, GraphQL::Types::Boolean, "Check if the current user can comment", null: false
|
18
11
|
field :comments, [Decidim::Comments::CommentType, { null: false }], "The list of replies in this comment", null: false do
|
19
12
|
argument :order_by, GraphQL::Types::String, "Order the comments", required: false
|
20
13
|
argument :single_comment_id, GraphQL::Types::String, "ID of the single comment to look at", required: false
|
21
14
|
end
|
15
|
+
field :comments_have_alignment, GraphQL::Types::Boolean, "Whether the object comments have alignment or not", method: :comments_have_alignment?, null: false
|
16
|
+
field :comments_have_votes, GraphQL::Types::Boolean, "Whether the object comments have votes or not", method: :comments_have_votes?, null: false
|
17
|
+
field :has_comments, GraphQL::Types::Boolean, "Check if the commentable has comments", method: :has_comments?, null: false
|
18
|
+
field :id, GraphQL::Types::ID, "The commentable's ID", null: false
|
19
|
+
field :total_comments_count, GraphQL::Types::Int, description: "The number of comments in all levels this resource holds", method: :comments_count, null: false
|
20
|
+
field :type, GraphQL::Types::String, "The commentable's class name. i.e. `Decidim::ParticipatoryProcess`", method: :commentable_type, null: false
|
21
|
+
field :user_allowed_to_comment, GraphQL::Types::Boolean, "Check if the current user can comment", null: false
|
22
22
|
|
23
23
|
def comments(order_by: nil, single_comment_id: nil)
|
24
24
|
SortedComments.for(object, order_by:, id: single_comment_id).not_hidden
|
25
25
|
end
|
26
26
|
|
27
|
-
# rubocop:disable Naming/PredicateName
|
28
|
-
def has_comments
|
29
|
-
object.comment_threads.not_hidden.size.positive?
|
30
|
-
end
|
31
|
-
# rubocop:enable Naming/PredicateName
|
32
|
-
|
33
27
|
def user_allowed_to_comment
|
34
28
|
object.commentable? && object.user_allowed_to_comment?(context[:current_user])
|
35
29
|
end
|
@@ -8,12 +8,11 @@ module Decidim
|
|
8
8
|
field :add_comment, Decidim::Comments::CommentType, description: "Add a new comment to a commentable", null: true do
|
9
9
|
argument :alignment, GraphQL::Types::Int, "The comment's alignment. Can be 0 (neutral), 1 (in favor) or -1 (against)'", default_value: 0, required: false
|
10
10
|
argument :body, GraphQL::Types::String, "The comments's body", required: true
|
11
|
-
argument :user_group_id, GraphQL::Types::ID, "The comment's user group id. Replaces the author.", required: false
|
12
11
|
end
|
13
12
|
field :id, GraphQL::Types::ID, "The Commentable's unique ID", null: false
|
14
13
|
|
15
|
-
def add_comment(body:, alignment: nil
|
16
|
-
params = { "comment" => { "body" => body, "alignment" => alignment, "
|
14
|
+
def add_comment(body:, alignment: nil)
|
15
|
+
params = { "comment" => { "body" => body, "alignment" => alignment, "commentable" => object } }
|
17
16
|
form = Decidim::Comments::CommentForm.from_params(params).with_context(
|
18
17
|
current_organization: context[:current_organization],
|
19
18
|
current_user: context[:current_user],
|
@@ -19,10 +19,6 @@ module Decidim
|
|
19
19
|
},
|
20
20
|
alignment: resource.alignment,
|
21
21
|
depth: resource.depth,
|
22
|
-
user_group: {
|
23
|
-
id: resource.user_group.try(:id),
|
24
|
-
name: resource.user_group.try(:name) || empty_translatable
|
25
|
-
},
|
26
22
|
commentable_id: resource.decidim_commentable_id,
|
27
23
|
commentable_type: resource.decidim_commentable_type,
|
28
24
|
root_commentable_url:
|
@@ -20,10 +20,6 @@ module Decidim
|
|
20
20
|
},
|
21
21
|
alignment: resource.comment.alignment,
|
22
22
|
depth: resource.comment.depth,
|
23
|
-
user_group: {
|
24
|
-
id: resource.comment.user_group.try(:id),
|
25
|
-
name: resource.comment.user_group.try(:name)
|
26
|
-
},
|
27
23
|
commentable_id: resource.comment.decidim_commentable_id,
|
28
24
|
commentable_type: resource.comment.decidim_commentable_type,
|
29
25
|
root_commentable_url:
|
@@ -35,9 +35,12 @@ module Decidim
|
|
35
35
|
end
|
36
36
|
|
37
37
|
initializer "decidim_comments.stats" do
|
38
|
-
Decidim.stats.register :comments_count,
|
38
|
+
Decidim.stats.register :comments_count,
|
39
|
+
priority: StatsRegistry::HIGH_PRIORITY,
|
40
|
+
icon_name: "chat-1-line",
|
41
|
+
tooltip_key: "comments_count" do |organization|
|
39
42
|
Decidim.component_manifests.sum do |component|
|
40
|
-
component.stats.filter(tag: :comments).with_context(organization.published_components).map { |_name, value| value }.sum
|
43
|
+
component.stats.filter(tag: :comments).with_context(organization.published_components).map { |_name, value| value }.compact_blank.sum
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
@@ -56,23 +59,6 @@ module Decidim
|
|
56
59
|
Decidim.icons.register(name: "edit-line", icon: "edit-line", description: "Edit comment button", **common_parameters)
|
57
60
|
end
|
58
61
|
|
59
|
-
initializer "decidim_comments.register_metrics" do
|
60
|
-
Decidim.metrics_registry.register(:comments) do |metric_registry|
|
61
|
-
metric_registry.manager_class = "Decidim::Comments::Metrics::CommentsMetricManage"
|
62
|
-
|
63
|
-
metric_registry.settings do |settings|
|
64
|
-
settings.attribute :highlighted, type: :boolean, default: false
|
65
|
-
settings.attribute :scopes, type: :array, default: %w(home participatory_process)
|
66
|
-
settings.attribute :weight, type: :integer, default: 6
|
67
|
-
settings.attribute :stat_block, type: :string, default: "small"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
Decidim.metrics_operation.register(:participants, :comments) do |metric_operation|
|
72
|
-
metric_operation.manager_class = "Decidim::Comments::Metrics::CommentParticipantsMetricMeasure"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
62
|
initializer "decidim_comments.register_resources" do
|
77
63
|
Decidim.register_resource(:comment) do |resource|
|
78
64
|
resource.model_class_name = "Decidim::Comments::Comment"
|
@@ -86,7 +72,7 @@ module Decidim
|
|
86
72
|
Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Comments::Engine.root}/app/views") # for partials
|
87
73
|
end
|
88
74
|
|
89
|
-
initializer "decidim_comments.
|
75
|
+
initializer "decidim_comments.shakapacker.assets_path" do
|
90
76
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
91
77
|
end
|
92
78
|
|
@@ -19,7 +19,7 @@ FactoryBot.define do
|
|
19
19
|
else
|
20
20
|
evaluator.body
|
21
21
|
end
|
22
|
-
comment.body = Decidim::ContentProcessor.
|
22
|
+
comment.body = Decidim::ContentProcessor.parse(comment.body, current_organization: comment.root_commentable.organization).rewrite
|
23
23
|
end
|
24
24
|
|
25
25
|
trait :deleted do
|
@@ -17,11 +17,6 @@ shared_context "when it is a comment event" do
|
|
17
17
|
|
18
18
|
let(:extra) { { comment_id: comment.id } }
|
19
19
|
let(:resource_title) { decidim_sanitize_translated(resource.title) }
|
20
|
-
let(:user_group) do
|
21
|
-
user_group = create(:user_group, :verified, organization:, users: [comment_author])
|
22
|
-
comment.update!(user_group:)
|
23
|
-
user_group
|
24
|
-
end
|
25
20
|
end
|
26
21
|
|
27
22
|
shared_examples_for "a comment event" do
|
@@ -29,11 +24,7 @@ shared_examples_for "a comment event" do
|
|
29
24
|
|
30
25
|
describe "author" do
|
31
26
|
it "returns the comment author" do
|
32
|
-
|
33
|
-
expect(subject.author).to eq(user_group_author)
|
34
|
-
else
|
35
|
-
expect(subject.author).to eq(comment_author)
|
36
|
-
end
|
27
|
+
expect(subject.author).to eq(comment_author)
|
37
28
|
end
|
38
29
|
end
|
39
30
|
|
@@ -11,13 +11,11 @@ RSpec.shared_context "when creating a comment" do
|
|
11
11
|
let(:commentable) { dummy_resource }
|
12
12
|
let(:body) { Faker::Lorem.paragraph }
|
13
13
|
let(:alignment) { 1 }
|
14
|
-
let(:user_group_id) { nil }
|
15
14
|
let(:form_params) do
|
16
15
|
{
|
17
16
|
"comment" => {
|
18
17
|
"body" => body,
|
19
18
|
"alignment" => alignment,
|
20
|
-
"user_group_id" => user_group_id,
|
21
19
|
"commentable" => commentable
|
22
20
|
}
|
23
21
|
}
|
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.31.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2025-09-
|
13
|
+
date: 2025-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim-core
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.31.0.rc1
|
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.31.0.rc1
|
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.31.0.rc1
|
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.31.0.rc1
|
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.31.0.rc1
|
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.31.0.rc1
|
77
77
|
description: Pluggable comments system for some components.
|
78
78
|
email:
|
79
79
|
- josepjaume@gmail.com
|
@@ -126,14 +126,12 @@ files:
|
|
126
126
|
- app/controllers/decidim/comments/comments_controller.rb
|
127
127
|
- app/controllers/decidim/comments/votes_controller.rb
|
128
128
|
- app/events/decidim/comments/comment_by_followed_user_event.rb
|
129
|
-
- app/events/decidim/comments/comment_by_followed_user_group_event.rb
|
130
129
|
- app/events/decidim/comments/comment_created_event.rb
|
131
130
|
- app/events/decidim/comments/comment_downvoted_event.rb
|
132
131
|
- app/events/decidim/comments/comment_event.rb
|
133
132
|
- app/events/decidim/comments/comment_upvoted_event.rb
|
134
133
|
- app/events/decidim/comments/comment_voted_event.rb
|
135
134
|
- app/events/decidim/comments/reply_created_event.rb
|
136
|
-
- app/events/decidim/comments/user_group_mentioned_event.rb
|
137
135
|
- app/events/decidim/comments/user_mentioned_event.rb
|
138
136
|
- app/forms/decidim/comments/comment_form.rb
|
139
137
|
- app/helpers/decidim/comments/comment_cells_helper.rb
|
@@ -151,8 +149,6 @@ files:
|
|
151
149
|
- app/packs/src/decidim/comments/comments_mobile_modal.js
|
152
150
|
- app/packs/stylesheets/comments.scss
|
153
151
|
- app/permissions/decidim/comments/permissions.rb
|
154
|
-
- app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb
|
155
|
-
- app/queries/decidim/comments/metrics/comments_metric_manage.rb
|
156
152
|
- app/queries/decidim/comments/sorted_comments.rb
|
157
153
|
- app/resolvers/decidim/comments/vote_comment_resolver.rb
|
158
154
|
- app/scrubbers/decidim/comments/user_input_scrubber.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Decidim
|
4
|
-
module Comments
|
5
|
-
module Metrics
|
6
|
-
# Searches for Participants in the following actions
|
7
|
-
# - Leave a comment (Comments)
|
8
|
-
class CommentParticipantsMetricMeasure < Decidim::MetricMeasure
|
9
|
-
def valid?
|
10
|
-
super && @resource.is_a?(Decidim::Participable)
|
11
|
-
end
|
12
|
-
|
13
|
-
def calculate
|
14
|
-
cumulative_users = []
|
15
|
-
quantity_users = []
|
16
|
-
|
17
|
-
retrieve_comments_for_organization.each do |comment|
|
18
|
-
related_object = comment.root_commentable
|
19
|
-
next unless related_object
|
20
|
-
next unless check_participatory_space(@resource, related_object)
|
21
|
-
|
22
|
-
cumulative_users << comment.decidim_author_id
|
23
|
-
quantity_users << comment.decidim_author_id if comment.created_at >= start_time
|
24
|
-
end
|
25
|
-
{
|
26
|
-
cumulative_users: cumulative_users.uniq,
|
27
|
-
quantity_users: quantity_users.uniq
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def check_participatory_space(participatory_space, related_object)
|
34
|
-
return related_object.participatory_space == participatory_space if related_object.respond_to?(:participatory_space)
|
35
|
-
return related_object == participatory_space if related_object.is_a?(Decidim::Participable)
|
36
|
-
|
37
|
-
false
|
38
|
-
end
|
39
|
-
|
40
|
-
def retrieve_comments_for_organization
|
41
|
-
user_ids = Decidim::User.where(organization: @resource.organization).pluck(:id)
|
42
|
-
Decidim::Comments::Comment.includes(:root_commentable).not_hidden.not_deleted
|
43
|
-
.where(decidim_comments_comments: { created_at: ..end_time })
|
44
|
-
.where(decidim_comments_comments: { decidim_author_id: user_ids })
|
45
|
-
.where(decidim_comments_comments: { decidim_author_type: "Decidim::UserBaseEntity" })
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|