decidim-comments 0.29.4 → 0.30.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/actions.erb +0 -8
- data/app/cells/decidim/comments/comment/show.erb +41 -5
- data/app/cells/decidim/comments/comment_cell.rb +37 -1
- data/app/cells/decidim/comments/comment_form/comment_as.erb +24 -6
- data/app/cells/decidim/comments/comment_form/opinion.erb +0 -4
- data/app/cells/decidim/comments/comment_form/show.erb +31 -29
- data/app/cells/decidim/comments/comment_form_cell.rb +7 -2
- data/app/cells/decidim/comments/comment_thread/show.erb +2 -2
- data/app/cells/decidim/comments/comments/add_comment.erb +12 -14
- data/app/cells/decidim/comments/comments/comments_in_single_column.erb +6 -0
- data/app/cells/decidim/comments/comments/order_control.erb +32 -9
- data/app/cells/decidim/comments/comments/show.erb +28 -1
- data/app/cells/decidim/comments/comments_cell.rb +53 -14
- data/app/cells/decidim/comments/edit_comment_modal_form_cell.rb +1 -1
- data/app/cells/decidim/comments/two_columns_comments/column.erb +20 -0
- data/app/cells/decidim/comments/two_columns_comments/show.erb +11 -0
- data/app/cells/decidim/comments/two_columns_comments_cell.rb +86 -0
- data/app/controllers/decidim/comments/comments_controller.rb +1 -2
- data/app/forms/decidim/comments/comment_form.rb +14 -0
- data/app/models/decidim/comments/comment.rb +10 -8
- data/app/packs/entrypoints/decidim_comments.js +1 -0
- data/app/packs/src/decidim/comments/comments.component.js +151 -25
- data/app/packs/src/decidim/comments/comments.component.test.js +2 -1
- data/app/packs/src/decidim/comments/comments.js +95 -12
- data/app/packs/src/decidim/comments/comments_dropdown.js +57 -0
- data/app/packs/src/decidim/comments/comments_mobile_modal.js +46 -0
- data/app/packs/stylesheets/comments.scss +203 -50
- data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +1 -1
- data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +22 -17
- data/app/views/decidim/comments/comments/_comments.html.erb +1 -0
- data/app/views/decidim/comments/comments/create.js.erb +9 -1
- data/app/views/decidim/comments/comments/index.js.erb +0 -3
- data/app/views/decidim/comments/comments/reload.js.erb +7 -3
- data/app/views/decidim/comments/comments/update.js.erb +3 -1
- data/config/locales/ar.yml +0 -1
- data/config/locales/bg.yml +0 -1
- data/config/locales/ca.yml +35 -4
- data/config/locales/cs.yml +37 -4
- data/config/locales/de.yml +35 -4
- data/config/locales/el.yml +0 -1
- data/config/locales/en.yml +35 -4
- data/config/locales/es-MX.yml +35 -4
- data/config/locales/es-PY.yml +35 -4
- data/config/locales/es.yml +35 -4
- data/config/locales/eu.yml +55 -24
- data/config/locales/fi-plain.yml +35 -2
- data/config/locales/fi.yml +36 -3
- data/config/locales/fr-CA.yml +8 -4
- data/config/locales/fr.yml +8 -4
- data/config/locales/gl.yml +0 -1
- data/config/locales/hu.yml +0 -1
- data/config/locales/id-ID.yml +0 -1
- data/config/locales/is-IS.yml +0 -1
- data/config/locales/it.yml +1 -2
- data/config/locales/ja.yml +34 -4
- data/config/locales/lb.yml +0 -1
- data/config/locales/lt.yml +1 -2
- 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 +1 -3
- data/config/locales/pt-BR.yml +0 -1
- data/config/locales/pt.yml +0 -1
- data/config/locales/ro-RO.yml +57 -60
- data/config/locales/ru.yml +0 -1
- data/config/locales/sk.yml +0 -1
- data/config/locales/sv.yml +19 -4
- data/config/locales/tr-TR.yml +1 -2
- data/config/locales/uk.yml +0 -1
- data/config/locales/zh-CN.yml +0 -1
- data/config/locales/zh-TW.yml +0 -1
- data/decidim-comments.gemspec +1 -1
- data/lib/decidim/api/comment_mutation_type.rb +2 -2
- data/lib/decidim/api/comment_type.rb +12 -45
- data/lib/decidim/api/commentable_interface.rb +4 -16
- data/lib/decidim/api/commentable_mutation_type.rb +2 -3
- data/lib/decidim/comments/commentable.rb +11 -0
- data/lib/decidim/comments/comments_helper.rb +1 -1
- data/lib/decidim/comments/engine.rb +7 -1
- data/lib/decidim/comments/test/factories.rb +8 -0
- data/lib/decidim/comments/test/shared_examples/comment_event.rb +1 -1
- data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +2 -2
- data/lib/decidim/comments/test/shared_examples/create_comment_context.rb +1 -1
- data/lib/decidim/comments/test/shared_examples/translatable_comment.rb +2 -2
- data/lib/decidim/comments/version.rb +1 -1
- metadata +17 -12
- data/app/cells/decidim/comments/comments/inline.erb +0 -28
- data/config/locales/ca-IT.yml +0 -178
@@ -0,0 +1,46 @@
|
|
1
|
+
// The code: 1. Manages a responsive "Add Comment" modal: Opens fullscreen on mobile (<= sm) and closes it via a "close" button.
|
2
|
+
// 2. Handles dropdown menus: Dynamically updates button content based on user selection, hides selected items, and manages dropdown visibility.
|
3
|
+
// This creates a responsive, interactive comment interface with mobile-friendly design and dynamic user group selection.
|
4
|
+
|
5
|
+
import { screens } from "tailwindcss/defaultTheme"
|
6
|
+
import { initializeCommentsDropdown } from "../../decidim/comments/comments_dropdown";
|
7
|
+
|
8
|
+
// Add comment card for mobile
|
9
|
+
const addCommentMobile = function (addCommentCard) {
|
10
|
+
const smBreakpoint = parseInt(screens.sm.replace("px", ""), 10);
|
11
|
+
if (window.matchMedia(`(max-width: ${smBreakpoint}px)`).matches) {
|
12
|
+
addCommentCard.classList.remove("hidden");
|
13
|
+
addCommentCard.classList.add("fullscreen");
|
14
|
+
}
|
15
|
+
};
|
16
|
+
|
17
|
+
const closeAddComment = function (addCommentCard) {
|
18
|
+
addCommentCard.classList.add("hidden");
|
19
|
+
addCommentCard.classList.remove("fullscreen");
|
20
|
+
}
|
21
|
+
|
22
|
+
document.addEventListener("DOMContentLoaded", () => {
|
23
|
+
// Add comment card for mobile
|
24
|
+
const addCommentCard = document.getElementById("add-comment-anchor");
|
25
|
+
if (addCommentCard) {
|
26
|
+
document.querySelectorAll(".add-comment-mobile").forEach((addButtonMobile) => {
|
27
|
+
addButtonMobile.addEventListener("click", () => {
|
28
|
+
addCommentMobile(addCommentCard);
|
29
|
+
});
|
30
|
+
});
|
31
|
+
}
|
32
|
+
|
33
|
+
// Close comment modal
|
34
|
+
const closeButton = document.querySelector(
|
35
|
+
"#add-comment-anchor .close-add-comment-fullscreen"
|
36
|
+
);
|
37
|
+
if (closeButton) {
|
38
|
+
closeButton.addEventListener("click", () =>
|
39
|
+
closeAddComment(addCommentCard)
|
40
|
+
);
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
// Initialize dropdown menu
|
45
|
+
initializeCommentsDropdown(document);
|
46
|
+
});
|
@@ -1,13 +1,19 @@
|
|
1
|
+
@import "stylesheets/decidim/_tribute.scss";
|
2
|
+
|
1
3
|
.comments {
|
2
4
|
&__container {
|
3
5
|
@apply md:mt-12;
|
4
6
|
}
|
5
7
|
|
6
8
|
.add-comment {
|
7
|
-
@apply mt-12;
|
9
|
+
@apply mt-12 md:bg-gray-5 p-0 md:px-4 md:pb-6 md:pt-1 rounded-lg w-full;
|
10
|
+
|
11
|
+
.new_comment {
|
12
|
+
@apply w-full;
|
13
|
+
}
|
8
14
|
|
9
15
|
.remaining-character-count {
|
10
|
-
@apply block text-
|
16
|
+
@apply block text-left text-sm text-gray-2 mx-4 md:m-0;
|
11
17
|
}
|
12
18
|
|
13
19
|
.form__wrapper {
|
@@ -19,61 +25,62 @@
|
|
19
25
|
}
|
20
26
|
}
|
21
27
|
|
28
|
+
.account-message {
|
29
|
+
a {
|
30
|
+
@apply text-secondary underline font-semibold;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
22
34
|
&__header {
|
23
|
-
@apply flex
|
35
|
+
@apply flex justify-between md:flex-row md:items-center mb-4;
|
36
|
+
|
37
|
+
option {
|
38
|
+
&.selected {
|
39
|
+
@apply font-bold;
|
40
|
+
}
|
41
|
+
}
|
24
42
|
}
|
25
43
|
|
26
44
|
.author__avatar-container {
|
27
45
|
@apply w-8 h-8;
|
28
46
|
}
|
29
47
|
|
30
|
-
.
|
31
|
-
|
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;
|
48
|
+
.comments-section {
|
49
|
+
&__header {
|
50
|
+
@apply flex items-center justify-center space-x-2 p-4 bg-secondary/5 rounded-b-md mb-4;
|
44
51
|
|
45
|
-
|
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;
|
52
|
+
svg {
|
53
|
+
@apply w-6 h-6 mr-2 fill-secondary;
|
55
54
|
}
|
55
|
+
}
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
&__title {
|
58
|
+
@apply text-md font-semibold text-secondary;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
.comments-two-columns {
|
64
|
+
.most-upvoted-label {
|
65
|
+
@apply px-2 mb-2;
|
66
|
+
}
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
input[type="radio"] {
|
69
|
+
&:not(.reset-defaults) {
|
70
|
+
@apply inline-block mr-0;
|
68
71
|
}
|
69
72
|
}
|
70
73
|
}
|
71
74
|
|
72
75
|
.comment {
|
73
|
-
@apply rounded-lg border-2 border-background p-3 pl-6;
|
76
|
+
@apply rounded-lg border-2 border-background-5 p-3 pl-6;
|
77
|
+
|
78
|
+
&.top-comment {
|
79
|
+
@apply border-gray-2;
|
80
|
+
}
|
74
81
|
|
75
82
|
&__header {
|
76
|
-
@apply flex items-center gap-x-2 mb-2
|
83
|
+
@apply flex items-center gap-x-2 mb-2 relative;
|
77
84
|
|
78
85
|
a[href^="/profile"] > span:first-child {
|
79
86
|
@apply z-10;
|
@@ -82,11 +89,30 @@
|
|
82
89
|
&--edited {
|
83
90
|
@apply text-sm font-semibold;
|
84
91
|
}
|
92
|
+
|
93
|
+
/* affects the left margin of the avatar in the comment replies */
|
94
|
+
& ~ [data-comment-footer] {
|
95
|
+
.comment__header {
|
96
|
+
@apply -ml-10;
|
97
|
+
}
|
98
|
+
|
99
|
+
[data-target*="dropdown-menu-add-comment"] {
|
100
|
+
@apply w-full flex items-center justify-between gap-2 px-0 pt-2 pb-0 first-of-type:[&>svg]:block last-of-type:[&>svg]:hidden;
|
101
|
+
|
102
|
+
> svg {
|
103
|
+
@apply w-6 h-6 flex-none text-secondary fill-current;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
85
107
|
}
|
86
108
|
|
87
109
|
/* overwrite default dropdown styles */
|
88
110
|
[data-target*="dropdown"] {
|
89
111
|
@apply md:flex w-auto cursor-pointer text-sm text-secondary;
|
112
|
+
|
113
|
+
> svg {
|
114
|
+
@apply h-3 w-3;
|
115
|
+
}
|
90
116
|
}
|
91
117
|
|
92
118
|
/* overwrite default dropdown styles */
|
@@ -95,11 +121,11 @@
|
|
95
121
|
}
|
96
122
|
|
97
123
|
&__footer-grid {
|
98
|
-
@apply grid
|
124
|
+
@apply grid items-center mt-4;
|
99
125
|
}
|
100
126
|
|
101
127
|
&-reply {
|
102
|
-
@apply rounded-lg border-2 border-background ml-3 relative;
|
128
|
+
@apply rounded-lg border-2 border-background-5 ml-3 relative;
|
103
129
|
}
|
104
130
|
|
105
131
|
&-reply:empty {
|
@@ -107,7 +133,7 @@
|
|
107
133
|
}
|
108
134
|
|
109
135
|
&-reply::after {
|
110
|
-
@apply bg-background-
|
136
|
+
@apply bg-background-5 inline-block absolute top-8 h-4/5 w-px -z-10;
|
111
137
|
|
112
138
|
content: "";
|
113
139
|
}
|
@@ -142,7 +168,27 @@
|
|
142
168
|
}
|
143
169
|
|
144
170
|
&__as {
|
145
|
-
@apply my-4;
|
171
|
+
@apply my-4 px-4 md:p-0;
|
172
|
+
|
173
|
+
&-author-container {
|
174
|
+
@apply flex justify-between items-center;
|
175
|
+
}
|
176
|
+
|
177
|
+
&-author-info {
|
178
|
+
@apply flex items-center gap-2;
|
179
|
+
}
|
180
|
+
|
181
|
+
&-author-name {
|
182
|
+
@apply text-secondary font-semibold;
|
183
|
+
}
|
184
|
+
|
185
|
+
&-author-selected {
|
186
|
+
@apply flex flex-col;
|
187
|
+
|
188
|
+
.author__avatar-container {
|
189
|
+
@apply -mt-3.5;
|
190
|
+
}
|
191
|
+
}
|
146
192
|
}
|
147
193
|
|
148
194
|
.add-comment {
|
@@ -156,10 +202,8 @@
|
|
156
202
|
@apply mr-2;
|
157
203
|
}
|
158
204
|
|
159
|
-
|
160
|
-
|
161
|
-
button:nth-child(2),
|
162
|
-
.button_to:nth-child(2) {
|
205
|
+
> :first-child,
|
206
|
+
> :nth-child(2) {
|
163
207
|
svg:first-child {
|
164
208
|
@apply block;
|
165
209
|
}
|
@@ -189,7 +233,7 @@
|
|
189
233
|
}
|
190
234
|
}
|
191
235
|
|
192
|
-
|
236
|
+
> :nth-child(2) {
|
193
237
|
svg:first-child {
|
194
238
|
@apply block;
|
195
239
|
}
|
@@ -234,11 +278,15 @@
|
|
234
278
|
}
|
235
279
|
|
236
280
|
&-order-by {
|
237
|
-
@apply ml-auto
|
281
|
+
@apply ml-auto flex place-items-center md:mt-0;
|
282
|
+
|
283
|
+
> form {
|
284
|
+
@apply flex;
|
285
|
+
}
|
238
286
|
}
|
239
287
|
|
240
288
|
&__actions {
|
241
|
-
@apply flex items-center gap-4;
|
289
|
+
@apply flex items-center justify-center gap-4;
|
242
290
|
|
243
291
|
.button[aria-expanded="false"] {
|
244
292
|
svg:first-of-type {
|
@@ -277,6 +325,50 @@
|
|
277
325
|
}
|
278
326
|
}
|
279
327
|
|
328
|
+
&__reply-button {
|
329
|
+
@apply flex items-center justify-center;
|
330
|
+
|
331
|
+
.button[aria-expanded="false"] {
|
332
|
+
svg:first-of-type {
|
333
|
+
@apply block;
|
334
|
+
}
|
335
|
+
|
336
|
+
svg:last-of-type {
|
337
|
+
@apply hidden;
|
338
|
+
}
|
339
|
+
|
340
|
+
span:first-of-type {
|
341
|
+
@apply block;
|
342
|
+
}
|
343
|
+
|
344
|
+
span:last-of-type {
|
345
|
+
@apply hidden;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
.button[aria-expanded="true"] {
|
350
|
+
svg:first-of-type {
|
351
|
+
@apply hidden;
|
352
|
+
}
|
353
|
+
|
354
|
+
svg:last-of-type {
|
355
|
+
@apply block;
|
356
|
+
}
|
357
|
+
|
358
|
+
span:first-of-type {
|
359
|
+
@apply hidden;
|
360
|
+
}
|
361
|
+
|
362
|
+
span:last-of-type {
|
363
|
+
@apply block;
|
364
|
+
}
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
&__votes-actions {
|
369
|
+
@apply flex justify-between;
|
370
|
+
}
|
371
|
+
|
280
372
|
&__content {
|
281
373
|
&--label {
|
282
374
|
@apply inline-block mb-2;
|
@@ -289,7 +381,15 @@
|
|
289
381
|
}
|
290
382
|
|
291
383
|
&-submit {
|
292
|
-
@apply flex flex-col md:flex-row justify-between items-stretch md:items-end gap-4 mt-4;
|
384
|
+
@apply flex flex-col md:flex-row md:justify-between items-stretch md:items-end gap-4 mt-4;
|
385
|
+
}
|
386
|
+
|
387
|
+
&-mobile-banner {
|
388
|
+
@apply flex relative md:hidden h-[72px] border-b border-gray justify-center items-center;
|
389
|
+
|
390
|
+
.close-button {
|
391
|
+
@apply absolute top-7 right-6 [&_svg]:w-4 [&_svg]:h-4;
|
392
|
+
}
|
293
393
|
}
|
294
394
|
}
|
295
395
|
|
@@ -325,3 +425,56 @@
|
|
325
425
|
@apply text-md;
|
326
426
|
}
|
327
427
|
}
|
428
|
+
|
429
|
+
.comments-label-dropdown {
|
430
|
+
@apply mr-2 mt-2;
|
431
|
+
}
|
432
|
+
|
433
|
+
[id*="dropdown-menu-add-comment"] {
|
434
|
+
@apply flex flex-col py-0 mx-0 border-t-0 border-gray-3 cursor-pointer;
|
435
|
+
|
436
|
+
&[aria-hidden="true"] {
|
437
|
+
@apply hidden;
|
438
|
+
}
|
439
|
+
}
|
440
|
+
|
441
|
+
[data-target*="dropdown-menu-add-comment"] {
|
442
|
+
@apply w-full flex items-center justify-between mb-4 gap-2 px-0 pt-2 pb-0 first-of-type:[&>svg]:block last-of-type:[&>svg]:hidden;
|
443
|
+
|
444
|
+
& > span {
|
445
|
+
@apply hidden font-semibold text-secondary;
|
446
|
+
|
447
|
+
&:only-of-type,
|
448
|
+
&.is-active {
|
449
|
+
@apply flex items-center gap-2 [&_svg]:fill-current;
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
> svg {
|
454
|
+
@apply w-6 h-6 flex-none text-secondary fill-current;
|
455
|
+
}
|
456
|
+
|
457
|
+
&[aria-expanded="false"] > svg:last-of-type,
|
458
|
+
&[aria-expanded="true"] > svg:first-of-type {
|
459
|
+
@apply hidden;
|
460
|
+
}
|
461
|
+
|
462
|
+
&[aria-expanded="true"] > svg:last-of-type,
|
463
|
+
&[aria-expanded="false"] > svg:first-of-type {
|
464
|
+
@apply block;
|
465
|
+
}
|
466
|
+
}
|
467
|
+
|
468
|
+
.publish-comment-button {
|
469
|
+
@apply md:relative fixed inset-x-0 bottom-0 z-30 md:z-0 flex flex-row items-center md:items-end md:justify-end font-semibold justify-around bg-white md:bg-transparent gap-4 md:gap-0 p-4 md:p-0 shadow-inner md:shadow-none first:[&>*]:grow md:first:[&>*]:grow-0 h-14 md:h-fit first:[&>button]:py-3;
|
470
|
+
}
|
471
|
+
|
472
|
+
.fullscreen {
|
473
|
+
@apply fixed md:relative inset-0 w-screen md:w-full h-screen bg-white z-50 p-0 overflow-auto md:overflow-hidden rounded-none;
|
474
|
+
}
|
475
|
+
|
476
|
+
.comments {
|
477
|
+
.fullscreen.add-comment {
|
478
|
+
@apply mt-0;
|
479
|
+
}
|
480
|
+
}
|
@@ -40,7 +40,7 @@ module Decidim
|
|
40
40
|
def retrieve_comments_for_organization
|
41
41
|
user_ids = Decidim::User.where(organization: @resource.organization).pluck(:id)
|
42
42
|
Decidim::Comments::Comment.includes(:root_commentable).not_hidden.not_deleted
|
43
|
-
.where(
|
43
|
+
.where(decidim_comments_comments: { created_at: ..end_time })
|
44
44
|
.where(decidim_comments_comments: { decidim_author_id: user_ids })
|
45
45
|
.where(decidim_comments_comments: { decidim_author_type: "Decidim::UserBaseEntity" })
|
46
46
|
end
|
@@ -14,10 +14,10 @@ module Decidim
|
|
14
14
|
next if cumulative_value.zero?
|
15
15
|
|
16
16
|
quantity_value = results[:quantity] || 0
|
17
|
-
space_type, space_id,
|
17
|
+
space_type, space_id, taxonomy_id, related_object_type, related_object_id = key
|
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
|
-
organization: @organization,
|
20
|
+
organization: @organization, decidim_taxonomy_id: taxonomy_id,
|
21
21
|
related_object_type:, related_object_id:)
|
22
22
|
record.assign_attributes(cumulative: cumulative_value, quantity: quantity_value)
|
23
23
|
record.save!
|
@@ -29,7 +29,7 @@ module Decidim
|
|
29
29
|
# Creates a Hashed structure with comments grouped by
|
30
30
|
#
|
31
31
|
# - ParticipatorySpace (type & ID)
|
32
|
-
# -
|
32
|
+
# - Taxonomy (ID)
|
33
33
|
# - RelatedObject (type & ID)
|
34
34
|
#
|
35
35
|
def query
|
@@ -39,14 +39,15 @@ module Decidim
|
|
39
39
|
related_object = comment.root_commentable
|
40
40
|
next grouped_comments unless related_object
|
41
41
|
|
42
|
-
|
43
|
-
next grouped_comments unless group_key
|
42
|
+
group_keys = generate_group_keys(related_object)
|
44
43
|
|
45
|
-
grouped_comments
|
46
|
-
grouped_comments[group_key][:cumulative] += 1
|
47
|
-
grouped_comments[group_key][:quantity] += 1 if comment.created_at >= start_time
|
44
|
+
next grouped_comments unless group_keys
|
48
45
|
|
49
|
-
|
46
|
+
group_keys.map do |group_key|
|
47
|
+
grouped_comments[group_key] ||= { cumulative: 0, quantity: 0 }
|
48
|
+
grouped_comments[group_key][:cumulative] += 1
|
49
|
+
grouped_comments[group_key][:quantity] += 1 if comment.created_at >= start_time
|
50
|
+
end
|
50
51
|
end
|
51
52
|
|
52
53
|
@query
|
@@ -60,22 +61,26 @@ module Decidim
|
|
60
61
|
user_ids = Decidim::User.select(:id).where(organization: @organization).collect(&:id)
|
61
62
|
user_group_ids = Decidim::UserGroup.select(:id).where(organization: @organization).collect(&:id)
|
62
63
|
Decidim::Comments::Comment.includes(:root_commentable).not_hidden.not_deleted
|
63
|
-
.where(
|
64
|
+
.where(decidim_comments_comments: { created_at: ..end_time })
|
64
65
|
.where("decidim_comments_comments.decidim_author_id IN (?) OR
|
65
66
|
decidim_comments_comments.decidim_user_group_id IN (?)", user_ids, user_group_ids)
|
66
67
|
end
|
67
68
|
|
68
69
|
# Generates a group key from the related object of a Comment
|
69
|
-
def
|
70
|
+
def generate_group_keys(related_object)
|
70
71
|
participatory_space = retrieve_participatory_space(related_object)
|
71
72
|
return unless participatory_space
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
return unless related_object.respond_to?(:taxonomies)
|
75
|
+
|
76
|
+
taxonomy_ids = related_object.taxonomies.pluck(:id)
|
77
|
+
taxonomy_ids.each_with_object([]) do |taxonomy_id, group_keys|
|
78
|
+
group_key = []
|
79
|
+
group_key += [participatory_space.class.name, participatory_space.id]
|
80
|
+
group_key += [taxonomy_id]
|
81
|
+
group_key += [related_object.class.name, related_object.id]
|
82
|
+
group_keys << group_key
|
83
|
+
end
|
79
84
|
end
|
80
85
|
|
81
86
|
# Gets current ParticipatorySpace of a given 'related_object'
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= inline_comments_for(commentable, order:) %>
|
@@ -2,6 +2,7 @@
|
|
2
2
|
var rootCommentableId = <%== "comments-for-#{@comment.root_commentable.commentable_type.demodulize}-#{@comment.root_commentable.id}".to_json %>;
|
3
3
|
var commentHtml = '<%== j(render @comment).strip %>';
|
4
4
|
var inReplyTo = <%== (reply?(@comment) ? @commentable.id : nil).to_json %>;
|
5
|
+
var alignment = <%= @comment.alignment.nil? ? "null" : @comment.alignment %>;
|
5
6
|
|
6
7
|
var $comments = $("#" + rootCommentableId);
|
7
8
|
var component = $comments.data("comments");
|
@@ -12,7 +13,7 @@
|
|
12
13
|
hideButton.find("[data-show-comment-reply]").first().html('<%= t("decidim.components.comment.show_replies", count: Decidim::Comments::SortedComments.for(root_comment.reload).size) %>');
|
13
14
|
|
14
15
|
} else {
|
15
|
-
component.addThread(commentHtml, true);
|
16
|
+
component.addThread(commentHtml, alignment, true);
|
16
17
|
}
|
17
18
|
|
18
19
|
Rails.fire(document, "comments:loaded", {
|
@@ -21,4 +22,11 @@
|
|
21
22
|
|
22
23
|
// Update the comments count
|
23
24
|
$(".comments-count", $comments).text(<%== t("decidim.components.comments.title", count: @comments_count).to_json %>);
|
25
|
+
|
26
|
+
var $addCommentCard = $("#add-comment-anchor");
|
27
|
+
|
28
|
+
if ($addCommentCard.hasClass("fullscreen")) {
|
29
|
+
$addCommentCard.addClass("hidden");
|
30
|
+
$addCommentCard.removeClass("fullscreen");
|
31
|
+
}
|
24
32
|
}());
|
@@ -5,7 +5,6 @@
|
|
5
5
|
var component = $comments.data("comments");
|
6
6
|
|
7
7
|
$(".loading-comments").addClass("hidden");
|
8
|
-
|
9
8
|
var commentsIds = [];
|
10
9
|
<% @comments.each do |comment| %>
|
11
10
|
var commentId = <%= comment.id.to_json %>;
|
@@ -23,8 +22,6 @@
|
|
23
22
|
}
|
24
23
|
<% end %>
|
25
24
|
if (commentsIds.length) {
|
26
|
-
component.lastCommentId = <%= @comments.last&.id || 0 %>;
|
27
|
-
|
28
25
|
Rails.fire(document, "comments:loaded", {
|
29
26
|
commentsIds: commentsIds
|
30
27
|
});
|
@@ -5,12 +5,16 @@
|
|
5
5
|
var component = $comments.data("comments");
|
6
6
|
component.unmountComponent();
|
7
7
|
|
8
|
-
var commentsHtml = '<%== j(
|
8
|
+
var commentsHtml = '<%== j(render partial: "comments").strip %>';
|
9
9
|
$(".loading-comments").addClass("hidden");
|
10
|
-
$comments.
|
10
|
+
$comments.replaceWith(commentsHtml);
|
11
11
|
|
12
|
-
|
12
|
+
$comments = $("#" + rootCommentableId);
|
13
|
+
|
14
|
+
// Re-create the component
|
15
|
+
component = new Decidim.CommentsComponent($comments, $comments.data("decidim-comments"));
|
13
16
|
component.mountComponent();
|
17
|
+
$comments.data("comments", component);
|
14
18
|
|
15
19
|
// Update the comments count
|
16
20
|
$(".comments-count", $comments).text(<%== t("decidim.components.comments.title", count: @comments_count).to_json %>);
|
@@ -2,8 +2,8 @@ $(() => {
|
|
2
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
|
-
var component = $comments.data("comments");
|
6
5
|
|
6
|
+
component = new Decidim.CommentsComponent($comments, config);
|
7
7
|
component.unmountComponent();
|
8
8
|
|
9
9
|
var commentHtml = '<%== j(render partial: "edited_comment", locals: { comment: @comment }).strip %>';
|
@@ -19,7 +19,9 @@ $(() => {
|
|
19
19
|
$comment.replaceWith(commentHtml);
|
20
20
|
|
21
21
|
// Re-create the component
|
22
|
+
component = new Decidim.CommentsComponent($comments, $comments.data("decidim-comments"));
|
22
23
|
component.mountComponent();
|
24
|
+
$comments.data("comments", component);
|
23
25
|
|
24
26
|
Rails.fire(document, "comments:loaded", {
|
25
27
|
commentsIds: [commentId]
|
data/config/locales/ar.yml
CHANGED
@@ -92,7 +92,6 @@ ar:
|
|
92
92
|
comments:
|
93
93
|
blocked_comments_for_unauthorized_user_warning: يجب أن تكون عضوا محققا من أجل التعليق حالياً، ولكن يمكنك قراءة ما سبق.
|
94
94
|
blocked_comments_for_user_warning: لا يمكنك التعليق في هذه اللحظة ، ولكن يمكنك قراءة التعليقات السابقة.
|
95
|
-
blocked_comments_warning: التعليقات معطلة في هذا الوقت ، لكن يمكنك قراءة التعليقات السابقة.
|
96
95
|
comment_details_title: تفاصيل التعليق
|
97
96
|
loading: جارٍ تحميل التعليقات ...
|
98
97
|
single_comment_warning: <a href="%{url}"> عرض جميع التعليقات</a>
|
data/config/locales/bg.yml
CHANGED
@@ -103,7 +103,6 @@ bg:
|
|
103
103
|
comments:
|
104
104
|
blocked_comments_for_unauthorized_user_warning: Трябва да сте верифицирани, за да коментирате в този момент, но можете да прочетете предишните.
|
105
105
|
blocked_comments_for_user_warning: Понастоящем не можете да коментирате, но можете да прочетете предходните коментари.
|
106
|
-
blocked_comments_warning: Коментарите в момента са деактивирани, но можете да прочетете предишните.
|
107
106
|
comment_details_title: Детайли за коментара
|
108
107
|
loading: Коментарите се зареждат...
|
109
108
|
single_comment_warning: <a href="%{url}">Вижте всички коментари</a>
|