decidim-comments 0.27.8 → 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 +7 -9
- 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 +2 -16
- 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
@@ -1 +1,20 @@
|
|
1
|
-
import "src/decidim/comments/comments.component"
|
1
|
+
import CommentsComponent from "src/decidim/comments/comments.component"
|
2
|
+
|
3
|
+
window.Decidim.CommentsComponent = CommentsComponent;
|
4
|
+
|
5
|
+
const commentsInitializer = () => {
|
6
|
+
// Mount comments component
|
7
|
+
$("[data-decidim-comments]").each((_i, el) => {
|
8
|
+
const $el = $(el);
|
9
|
+
let comments = $(el).data("comments");
|
10
|
+
if (!comments) {
|
11
|
+
comments = new CommentsComponent($el, $el.data("decidim-comments"));
|
12
|
+
}
|
13
|
+
comments.mountComponent();
|
14
|
+
$(el).data("comments", comments);
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
// If no jQuery is used the Tribute feature used in comments to autocomplete
|
19
|
+
// mentions stops working
|
20
|
+
$(() => commentsInitializer());
|
@@ -0,0 +1,327 @@
|
|
1
|
+
.comments {
|
2
|
+
&__container {
|
3
|
+
@apply md:mt-12;
|
4
|
+
}
|
5
|
+
|
6
|
+
.add-comment {
|
7
|
+
@apply mt-12;
|
8
|
+
|
9
|
+
.remaining-character-count {
|
10
|
+
@apply block text-right text-sm text-gray-2;
|
11
|
+
}
|
12
|
+
|
13
|
+
.form__wrapper {
|
14
|
+
@apply pt-0;
|
15
|
+
}
|
16
|
+
|
17
|
+
a {
|
18
|
+
@apply text-secondary underline font-semibold;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
&__header {
|
23
|
+
@apply flex flex-col md:flex-row md:items-center gap-x-2 mb-4;
|
24
|
+
}
|
25
|
+
|
26
|
+
.author__avatar-container {
|
27
|
+
@apply w-8 h-8;
|
28
|
+
}
|
29
|
+
|
30
|
+
.tribute-container {
|
31
|
+
@apply w-full relative;
|
32
|
+
|
33
|
+
#results {
|
34
|
+
@apply absolute max-h-[225px] top-full left-0 right-0 p-0 my-2 rounded z-50 overflow-y-scroll bg-white;
|
35
|
+
|
36
|
+
border: 1px solid rgba(33, 33, 33, 0.1);
|
37
|
+
|
38
|
+
li {
|
39
|
+
@apply flex items-center gap-2 cursor-pointer px-4 py-2;
|
40
|
+
}
|
41
|
+
|
42
|
+
li:hover {
|
43
|
+
@apply cursor-pointer;
|
44
|
+
|
45
|
+
background-color: rgba(123, 123, 123, 0.1);
|
46
|
+
}
|
47
|
+
|
48
|
+
img {
|
49
|
+
@apply rounded-full w-6 h-6 object-cover;
|
50
|
+
}
|
51
|
+
|
52
|
+
span,
|
53
|
+
strong {
|
54
|
+
@apply font-semibold text-sm text-secondary;
|
55
|
+
}
|
56
|
+
|
57
|
+
small {
|
58
|
+
@apply font-normal text-gray-2 text-xs;
|
59
|
+
}
|
60
|
+
|
61
|
+
svg {
|
62
|
+
@apply w-4 h-4 text-primary fill-current;
|
63
|
+
}
|
64
|
+
|
65
|
+
.is-group {
|
66
|
+
@apply ml-auto flex items-center gap-1;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
.comment {
|
73
|
+
@apply rounded-lg border-2 border-background p-3 pl-6;
|
74
|
+
|
75
|
+
&__header {
|
76
|
+
@apply flex items-center gap-x-2 mb-2 -ml-10 relative;
|
77
|
+
|
78
|
+
a[href^="/profile"] > span:first-child {
|
79
|
+
@apply z-10;
|
80
|
+
}
|
81
|
+
|
82
|
+
&--edited {
|
83
|
+
@apply text-sm font-semibold;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
/* overwrite default dropdown styles */
|
88
|
+
[data-target*="dropdown"] {
|
89
|
+
@apply md:flex w-auto cursor-pointer text-sm text-secondary;
|
90
|
+
}
|
91
|
+
|
92
|
+
/* overwrite default dropdown styles */
|
93
|
+
[id*="dropdown-menu"][aria-hidden="true"] {
|
94
|
+
@apply md:hidden;
|
95
|
+
}
|
96
|
+
|
97
|
+
&__footer-grid {
|
98
|
+
@apply grid grid-cols-2 items-center mt-4;
|
99
|
+
}
|
100
|
+
|
101
|
+
&-reply {
|
102
|
+
@apply rounded-lg border-2 border-background ml-3 relative;
|
103
|
+
}
|
104
|
+
|
105
|
+
&-reply:empty {
|
106
|
+
@apply hidden;
|
107
|
+
}
|
108
|
+
|
109
|
+
&-reply::after {
|
110
|
+
@apply bg-background-3 inline-block absolute top-8 h-4/5 w-px -z-10;
|
111
|
+
|
112
|
+
content: "";
|
113
|
+
}
|
114
|
+
|
115
|
+
&-reply &,
|
116
|
+
& &-reply {
|
117
|
+
@apply border-0 pr-0 mt-4;
|
118
|
+
}
|
119
|
+
|
120
|
+
&-thread {
|
121
|
+
@apply mb-8;
|
122
|
+
|
123
|
+
.button[aria-expanded="false"] {
|
124
|
+
svg:first-of-type {
|
125
|
+
@apply block;
|
126
|
+
}
|
127
|
+
|
128
|
+
svg:last-of-type {
|
129
|
+
@apply hidden;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
.button[aria-expanded="true"] {
|
134
|
+
svg:first-of-type {
|
135
|
+
@apply hidden;
|
136
|
+
}
|
137
|
+
|
138
|
+
svg:last-of-type {
|
139
|
+
@apply block;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
&__as {
|
145
|
+
@apply my-4;
|
146
|
+
}
|
147
|
+
|
148
|
+
.add-comment {
|
149
|
+
@apply w-full;
|
150
|
+
}
|
151
|
+
|
152
|
+
.comment__votes {
|
153
|
+
@apply justify-self-end;
|
154
|
+
|
155
|
+
.comment__votes--up {
|
156
|
+
@apply mr-2;
|
157
|
+
}
|
158
|
+
|
159
|
+
.button_to:first-child,
|
160
|
+
button:first-child,
|
161
|
+
button:nth-child(2),
|
162
|
+
.button_to:nth-child(2) {
|
163
|
+
svg:first-child {
|
164
|
+
@apply block;
|
165
|
+
}
|
166
|
+
|
167
|
+
svg:nth-child(2) {
|
168
|
+
@apply hidden;
|
169
|
+
}
|
170
|
+
|
171
|
+
.is-vote-selected {
|
172
|
+
svg:first-child {
|
173
|
+
@apply hidden;
|
174
|
+
}
|
175
|
+
|
176
|
+
svg:nth-child(2) {
|
177
|
+
@apply block;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
.is-vote-notselected {
|
182
|
+
svg:first-child {
|
183
|
+
@apply block;
|
184
|
+
}
|
185
|
+
|
186
|
+
svg:nth-child(2) {
|
187
|
+
@apply hidden;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
.button_to:nth-child(2) {
|
193
|
+
svg:first-child {
|
194
|
+
@apply block;
|
195
|
+
}
|
196
|
+
|
197
|
+
svg:nth-child(2) {
|
198
|
+
@apply hidden;
|
199
|
+
}
|
200
|
+
|
201
|
+
.is-vote-selected {
|
202
|
+
svg:first-child {
|
203
|
+
@apply hidden;
|
204
|
+
}
|
205
|
+
|
206
|
+
svg:nth-child(2) {
|
207
|
+
@apply block;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
.is-vote-notselected {
|
212
|
+
svg:first-child {
|
213
|
+
@apply block;
|
214
|
+
}
|
215
|
+
|
216
|
+
svg:nth-child(2) {
|
217
|
+
@apply hidden;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
.comment__votes--count {
|
223
|
+
@apply text-gray-2 text-sm;
|
224
|
+
}
|
225
|
+
|
226
|
+
.button_to {
|
227
|
+
@apply inline-block;
|
228
|
+
}
|
229
|
+
|
230
|
+
/* override button default styles */
|
231
|
+
.button[disabled] {
|
232
|
+
@apply border-0 bg-transparent;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
&-order-by {
|
237
|
+
@apply ml-auto grid grid-cols-4 place-items-center mt-4 md:mt-0;
|
238
|
+
}
|
239
|
+
|
240
|
+
&__actions {
|
241
|
+
@apply flex items-center gap-4;
|
242
|
+
|
243
|
+
.button[aria-expanded="false"] {
|
244
|
+
svg:first-of-type {
|
245
|
+
@apply block;
|
246
|
+
}
|
247
|
+
|
248
|
+
svg:last-of-type {
|
249
|
+
@apply hidden;
|
250
|
+
}
|
251
|
+
|
252
|
+
span:first-of-type {
|
253
|
+
@apply block;
|
254
|
+
}
|
255
|
+
|
256
|
+
span:last-of-type {
|
257
|
+
@apply hidden;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
.button[aria-expanded="true"] {
|
262
|
+
svg:first-of-type {
|
263
|
+
@apply hidden;
|
264
|
+
}
|
265
|
+
|
266
|
+
svg:last-of-type {
|
267
|
+
@apply block;
|
268
|
+
}
|
269
|
+
|
270
|
+
span:first-of-type {
|
271
|
+
@apply hidden;
|
272
|
+
}
|
273
|
+
|
274
|
+
span:last-of-type {
|
275
|
+
@apply block;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
&__content {
|
281
|
+
&--label {
|
282
|
+
@apply inline-block mb-2;
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
&__form {
|
287
|
+
&-label {
|
288
|
+
@apply font-semibold text-lg text-gray-2;
|
289
|
+
}
|
290
|
+
|
291
|
+
&-submit {
|
292
|
+
@apply flex flex-col md:flex-row justify-between items-stretch md:items-end gap-4 mt-4;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
&__opinion {
|
297
|
+
&-container {
|
298
|
+
@apply flex mt-2 w-full md:w-fit;
|
299
|
+
|
300
|
+
button {
|
301
|
+
@apply grow border border-gray first-of-type:rounded-l last-of-type:rounded-r inline-flex justify-center items-center gap-1 px-4 py-1.5 text-sm text-gray-2 -ml-px first:ml-0 transition-all;
|
302
|
+
|
303
|
+
svg {
|
304
|
+
@apply fill-current;
|
305
|
+
}
|
306
|
+
|
307
|
+
&:hover,
|
308
|
+
&.is-active {
|
309
|
+
@apply border-secondary text-secondary bg-background-4;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
&-label {
|
315
|
+
@apply text-sm text-gray-2;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
&__deleted,
|
320
|
+
&__moderated {
|
321
|
+
@apply font-bold;
|
322
|
+
}
|
323
|
+
|
324
|
+
.comment__content > * {
|
325
|
+
@apply text-md;
|
326
|
+
}
|
327
|
+
}
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
record = Decidim::Metric.find_or_initialize_by(day: @day.to_s, metric_type: @metric_name,
|
19
19
|
participatory_space_type: space_type, participatory_space_id: space_id,
|
20
20
|
organization: @organization, decidim_category_id: category_id,
|
21
|
-
related_object_type
|
21
|
+
related_object_type:, related_object_id:)
|
22
22
|
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
23
23
|
record.save!
|
24
24
|
end
|
@@ -45,11 +45,19 @@ module Decidim
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def count_replies(comment)
|
49
|
+
if comment.comment_threads.size.positive?
|
50
|
+
comment.comment_threads.size + comment.comment_threads.sum { |reply| count_replies(reply) }
|
51
|
+
else
|
52
|
+
0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
48
56
|
private
|
49
57
|
|
50
58
|
def base_scope
|
51
59
|
id = @options[:id]
|
52
|
-
return Comment.where(root_commentable: commentable, id:
|
60
|
+
return Comment.where(root_commentable: commentable, id:) if id.present?
|
53
61
|
|
54
62
|
after = @options[:after]
|
55
63
|
if after.present?
|
@@ -59,7 +67,7 @@ module Decidim
|
|
59
67
|
)
|
60
68
|
end
|
61
69
|
|
62
|
-
Comment.where(commentable:
|
70
|
+
Comment.where(commentable:)
|
63
71
|
end
|
64
72
|
|
65
73
|
def order_by_older(scope)
|
@@ -81,14 +89,6 @@ module Decidim
|
|
81
89
|
count_replies(comment)
|
82
90
|
end.reverse
|
83
91
|
end
|
84
|
-
|
85
|
-
def count_replies(comment)
|
86
|
-
if comment.comment_threads.size.positive?
|
87
|
-
comment.comment_threads.size + comment.comment_threads.sum { |reply| count_replies(reply) }
|
88
|
-
else
|
89
|
-
0
|
90
|
-
end
|
91
|
-
end
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -7,7 +7,7 @@ module Decidim
|
|
7
7
|
#
|
8
8
|
# - A user is mentioned in the comment
|
9
9
|
# - My comment is replied
|
10
|
-
# - A user I
|
10
|
+
# - A user I am following has created a comment/reply
|
11
11
|
# - A new comment has been created on a resource, and I should be notified.
|
12
12
|
#
|
13
13
|
# A given user will only receive one of these notifications, for a given
|
@@ -46,7 +46,7 @@ module Decidim
|
|
46
46
|
affected_users = mentioned_users - already_notified_users
|
47
47
|
@already_notified_users += affected_users
|
48
48
|
|
49
|
-
notify(:user_mentioned, affected_users:
|
49
|
+
notify(:user_mentioned, affected_users:)
|
50
50
|
end
|
51
51
|
|
52
52
|
def notify_mentioned_groups
|
@@ -56,7 +56,7 @@ module Decidim
|
|
56
56
|
affected_users = group.accepted_users - already_notified_users
|
57
57
|
@already_notified_users += affected_users
|
58
58
|
|
59
|
-
notify(:user_group_mentioned, affected_users
|
59
|
+
notify(:user_group_mentioned, affected_users:, extra: { group_id: group.id })
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -68,14 +68,14 @@ module Decidim
|
|
68
68
|
affected_users = [comment.commentable.author] - already_notified_users
|
69
69
|
@already_notified_users += affected_users
|
70
70
|
|
71
|
-
notify(:reply_created, affected_users:
|
71
|
+
notify(:reply_created, affected_users:)
|
72
72
|
end
|
73
73
|
|
74
74
|
def notify_author_followers
|
75
75
|
followers = comment.author.followers - already_notified_users
|
76
76
|
@already_notified_users += followers
|
77
77
|
|
78
|
-
notify(:comment_by_followed_user, followers:
|
78
|
+
notify(:comment_by_followed_user, followers:)
|
79
79
|
end
|
80
80
|
|
81
81
|
def notify_user_group_followers
|
@@ -84,7 +84,7 @@ module Decidim
|
|
84
84
|
followers = comment.user_group.followers - already_notified_users
|
85
85
|
@already_notified_users += followers
|
86
86
|
|
87
|
-
notify(:comment_by_followed_user_group, followers:
|
87
|
+
notify(:comment_by_followed_user_group, followers:)
|
88
88
|
end
|
89
89
|
|
90
90
|
# Notifies the users the `comment.commentable` resource implements as necessary.
|
@@ -92,7 +92,7 @@ module Decidim
|
|
92
92
|
followers = comment.commentable.users_to_notify_on_comment_created - already_notified_users
|
93
93
|
@already_notified_users += followers
|
94
94
|
|
95
|
-
notify(:comment_created, followers:
|
95
|
+
notify(:comment_created, followers:)
|
96
96
|
end
|
97
97
|
|
98
98
|
# Creates the notifications for the given user IDS and the given event.
|
@@ -110,7 +110,7 @@ module Decidim
|
|
110
110
|
event_class = "Decidim::Comments::#{event.to_s.camelcase}Event".constantize
|
111
111
|
data = {
|
112
112
|
event: "decidim.events.comments.#{event}",
|
113
|
-
event_class
|
113
|
+
event_class:,
|
114
114
|
resource: comment.root_commentable,
|
115
115
|
extra: {
|
116
116
|
comment_id: comment.id
|
@@ -1,15 +1,10 @@
|
|
1
1
|
<div class="row column">
|
2
|
-
<%= form.check_box :comments_enabled, label: t(".enabled"),
|
2
|
+
<%= form.check_box :comments_enabled, label: t(".enabled"), "data-toggle": "customize_comments_times-div" %>
|
3
3
|
</div>
|
4
4
|
|
5
5
|
<div id="customize_comments_times-div" data-toggler=".hide" class="row column <%= @form.comments_enabled ? nil : "hide" %>">
|
6
|
-
<div class="
|
7
|
-
|
8
|
-
<%= form.datetime_field :comments_start_time, label: t(".start_time") %>
|
9
|
-
</div>
|
10
|
-
|
11
|
-
<div class="columns xlarge-6">
|
12
|
-
<%= form.datetime_field :comments_end_time, label: t(".end_time") %>
|
13
|
-
</div>
|
6
|
+
<div class="mb-4">
|
7
|
+
<%= form.datetime_field :comments_start_time, label: t(".start_time") %>
|
14
8
|
</div>
|
9
|
+
<%= form.datetime_field :comments_end_time, label: t(".end_time") %>
|
15
10
|
</div>
|
@@ -1 +1 @@
|
|
1
|
-
<%= inline_comments_for(commentable, order:
|
1
|
+
<%= inline_comments_for(commentable, order:) %>
|
@@ -1,5 +1,3 @@
|
|
1
|
-
<div class="
|
2
|
-
|
3
|
-
<%= t("decidim.components.comment.deleted_at", date: l(comment.deleted_at, format: :decidim_short)) %>
|
4
|
-
</div>
|
1
|
+
<div class="comment__deleted">
|
2
|
+
<%= t("decidim.components.comment.deleted_at", date: l(comment.deleted_at, format: :decidim_short)) %>
|
5
3
|
</div>
|
@@ -1,5 +1,3 @@
|
|
1
|
-
<div class="
|
2
|
-
|
3
|
-
<%= t("decidim.components.comment.moderated_at", date: l(comment.moderation.hidden_at, format: :decidim_short)) %>
|
4
|
-
</div>
|
1
|
+
<div class="comment__moderated">
|
2
|
+
<%= t("decidim.components.comment.moderated_at", date: l(comment.moderation.hidden_at, format: :decidim_short)) %>
|
5
3
|
</div>
|
@@ -10,13 +10,15 @@
|
|
10
10
|
|
11
11
|
var hideButton = $("#comment_" + <%= root_comment.id %>).find(".comment__hide").first();
|
12
12
|
hideButton.find(".show-comment-replies").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);
|
16
16
|
}
|
17
17
|
|
18
|
+
Rails.fire(document, "comments:loaded", {
|
19
|
+
commentsIds: [<%= @comment.id %>, <%= @comment.commentable.id %>]
|
20
|
+
});
|
21
|
+
|
18
22
|
// Update the comments count
|
19
23
|
$(".comments-count", $comments).text(<%== t("decidim.components.comments.title", count: @comments_count).to_json %>);
|
20
|
-
|
21
|
-
Decidim.addInputEmoji();
|
22
24
|
}());
|
@@ -5,13 +5,16 @@ $(() => {
|
|
5
5
|
const $comment = $(`#comment_${commentId}`);
|
6
6
|
const $commentReply = $(`#comment${commentId}-reply`);
|
7
7
|
const $content = $("> .comment__content", $comment);
|
8
|
-
const sectionsToDelete = ["header", "footer", "additionalreply"];
|
8
|
+
const sectionsToDelete = ["header", "footer-grid", "reply", "additionalreply"];
|
9
9
|
|
10
10
|
sectionsToDelete.forEach((section) => {
|
11
11
|
$(`> .comment__${section}`, $comment).remove();
|
12
12
|
});
|
13
13
|
$commentReply.remove();
|
14
14
|
$content.replaceWith(deleteDataHtml);
|
15
|
+
Rails.fire(document, "comments:loaded", {
|
16
|
+
commentsIds: [commentId]
|
17
|
+
});
|
15
18
|
|
16
19
|
$(".comments-count", $(`#${rootCommentableId}`)).text(<%== t("decidim.components.comments.title", count: @comment.root_commentable.comments_count).to_json %>);
|
17
20
|
});
|
@@ -4,9 +4,11 @@
|
|
4
4
|
var $comments = $("#" + rootCommentableId);
|
5
5
|
var component = $comments.data("comments");
|
6
6
|
|
7
|
-
$(".loading-comments").addClass("
|
7
|
+
$(".loading-comments").addClass("hidden");
|
8
|
+
var commentsIds = [];
|
8
9
|
<% @comments.each do |comment| %>
|
9
10
|
var commentId = <%= comment.id.to_json %>;
|
11
|
+
commentsIds.push(commentId);
|
10
12
|
var commentHtml = '<%== j(render comment).strip %>';
|
11
13
|
var inReplyTo = <%== (reply?(comment) ? comment.commentable.id : nil).to_json %>;
|
12
14
|
|
@@ -19,6 +21,11 @@
|
|
19
21
|
}
|
20
22
|
}
|
21
23
|
<% end %>
|
24
|
+
if (commentsIds.length) {
|
25
|
+
Rails.fire(document, "comments:loaded", {
|
26
|
+
commentsIds: commentsIds
|
27
|
+
});
|
28
|
+
}
|
22
29
|
|
23
30
|
// Update the comments count
|
24
31
|
$(".comments-count", $comments).text(<%== t("decidim.components.comments.title", count: @comments_count).to_json %>);
|
@@ -6,11 +6,10 @@
|
|
6
6
|
component.unmountComponent();
|
7
7
|
|
8
8
|
var commentsHtml = '<%== j(render partial: "comments").strip %>';
|
9
|
-
$(".loading-comments").addClass("
|
9
|
+
$(".loading-comments").addClass("hidden");
|
10
10
|
$comments.replaceWith(commentsHtml);
|
11
11
|
|
12
12
|
$comments = $("#" + rootCommentableId);
|
13
|
-
$comments.foundation();
|
14
13
|
|
15
14
|
// Re-create the component
|
16
15
|
component = new Decidim.CommentsComponent($comments, $comments.data("decidim-comments"));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
$(() => {
|
2
|
-
var rootCommentableId = <%== "comments-for-#{@
|
2
|
+
var rootCommentableId = <%== "comments-for-#{@commentable.class.name.demodulize}-#{@commentable.id}".to_json %>;
|
3
3
|
var $comments = $("#" + rootCommentableId);
|
4
4
|
var config = $comments.data("decidim-comments");
|
5
5
|
|
@@ -12,11 +12,12 @@ $(() => {
|
|
12
12
|
|
13
13
|
$comment.replaceWith(commentHtml);
|
14
14
|
|
15
|
-
$comments = $("#" + rootCommentableId);
|
16
|
-
$comments.foundation();
|
17
|
-
|
18
15
|
// Re-create the component
|
19
16
|
component = new Decidim.CommentsComponent($comments, $comments.data("decidim-comments"));
|
20
17
|
component.mountComponent();
|
21
18
|
$comments.data("comments", component);
|
19
|
+
|
20
|
+
Rails.fire(document, "comments:loaded", {
|
21
|
+
commentsIds: [commentId]
|
22
|
+
});
|
22
23
|
});
|
@@ -3,12 +3,12 @@
|
|
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 = $("> .comment__footer .comment__votes", $comment);
|
7
|
-
var $upVote = $(".comment__votes--up", $votes);
|
8
|
-
var $downVote = $(".comment__votes--down", $votes);
|
6
|
+
var $votes = $("> .comment__footer > .comment__footer-grid .comment__votes", $comment);
|
7
|
+
var $upVote = $(".js-comment__votes--up", $votes);
|
8
|
+
var $downVote = $(".js-comment__votes--down", $votes);
|
9
9
|
|
10
|
-
$("
|
11
|
-
$("
|
10
|
+
$("span", $upVote).text(upVotes);
|
11
|
+
$("span", $downVote).text(downVotes);
|
12
12
|
|
13
13
|
$upVote.removeClass("is-vote-selected is-vote-notselected").removeAttr("disabled");
|
14
14
|
$downVote.removeClass("is-vote-selected is-vote-notselected").removeAttr("disabled");
|