decidim-comments 0.31.0.rc1 → 0.31.0
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/comments/order_control.erb +4 -6
- data/app/cells/decidim/comments/comments_cell.rb +1 -1
- data/app/models/decidim/comments/comment.rb +3 -1
- data/app/packs/src/decidim/comments/comments.component.js +13 -0
- data/app/packs/stylesheets/comments.scss +1 -1
- data/app/views/decidim/comments/comments/reload.js.erb +1 -0
- data/config/locales/de.yml +1 -1
- data/config/locales/eu.yml +1 -1
- data/db/data/20251117070404_update_user_groups_references.rb +82 -0
- data/lib/decidim/comments/engine.rb +6 -0
- data/lib/decidim/comments/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5e4186412267c1d490b61e28cb302d2ff11b7c162b2012306b36b74a87c6eb6
|
|
4
|
+
data.tar.gz: 6a3ae0d23d4917e2e8e6cd2fdef71d16b503f04bcc348e014194cf1381116139
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5aedd08f5540046b8494b47cfe19c96d58a42f01a0d9ce6cf4de8f0674bf08ea9d697ebbdea836bd93e4af6c6aea731cfa1c44527b465de76861500275d730ec
|
|
7
|
+
data.tar.gz: 6c0fea854c82c501f661b13b78cb586b73acc8e4ec5475afdda1cc3f4e32167e51a434828e54949f9a0c9f0351479b2b4d1804ec42940eef343a4339365448e9
|
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
<%= form_with url: "#", data: { controller: :sort_comments } do %>
|
|
3
3
|
<div class="md:hidden">
|
|
4
4
|
<select id="order-mobile" aria-label="<%= t("decidim.components.comment.sort_by") %>" data-mobile-order-comment-select="true">
|
|
5
|
-
<option
|
|
5
|
+
<option value="" disabled hidden <%= "selected" if params[:order].blank? %>>
|
|
6
|
+
<%= t("decidim.components.comment.sort_by") %>
|
|
7
|
+
</option>
|
|
6
8
|
<% available_orders.each do |order_value| %>
|
|
7
9
|
<option
|
|
8
10
|
value="<%= order_value %>"
|
|
9
|
-
<%= "selected" if
|
|
10
|
-
<% if order == nil && order_value == "older" || order_value == order %>
|
|
11
|
-
class="selected"
|
|
12
|
-
<% end %>
|
|
11
|
+
<%= "class = 'selected' selected" if params[:order] == order_value %>
|
|
13
12
|
data-order-comment-url="<%= decidim_comments.comments_path(commentable_gid: model.to_signed_global_id.to_s, order: order_value || "older", reload: 1) %>">
|
|
14
13
|
<%= t("decidim.components.comment_order_selector.order.#{order_value}") %>
|
|
15
14
|
</option>
|
|
16
15
|
<% end %>
|
|
17
16
|
</select>
|
|
18
17
|
</div>
|
|
19
|
-
<% order = "older" if order.nil? %>
|
|
20
18
|
<div class="hidden md:block">
|
|
21
19
|
<label for="order" class="comments-label-dropdown"><%= t("decidim.components.comment.sort_by") %></label>
|
|
22
20
|
<select id="order" aria-label="<%= t("decidim.components.comment.sort_by") %>" data-desktop-order-comment-select="true">
|
|
@@ -144,8 +144,10 @@ module Decidim
|
|
|
144
144
|
|
|
145
145
|
if root_commentable.respond_to?(:polymorphic_resource_url)
|
|
146
146
|
root_commentable.polymorphic_resource_url(url_params)
|
|
147
|
-
|
|
147
|
+
elsif root_commentable.respond_to?(:reported_content_url)
|
|
148
148
|
root_commentable.reported_content_url(url_params)
|
|
149
|
+
else
|
|
150
|
+
"/"
|
|
149
151
|
end
|
|
150
152
|
end
|
|
151
153
|
|
|
@@ -426,7 +426,20 @@ export default class CommentsComponent {
|
|
|
426
426
|
});
|
|
427
427
|
});
|
|
428
428
|
|
|
429
|
+
mobileOrderSelect.addEventListener("focus", function () {
|
|
430
|
+
const olderOption = mobileOrderSelect.querySelector('option[value="older"]');
|
|
431
|
+
if (!mobileOrderSelect.value) {
|
|
432
|
+
olderOption.style.fontWeight = "bold"
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
|
|
429
436
|
mobileOrderSelect.addEventListener("change", function(event) {
|
|
437
|
+
const olderOption = mobileOrderSelect.querySelector('option[value="older"]');
|
|
438
|
+
|
|
439
|
+
if (!olderOption.selected) {
|
|
440
|
+
olderOption.style.fontWeight = "normal"
|
|
441
|
+
}
|
|
442
|
+
|
|
430
443
|
const selectedOption = mobileOrderSelect.querySelector(`[value=${event.target.value}]`);
|
|
431
444
|
const orderUrl = selectedOption.dataset.orderCommentUrl;
|
|
432
445
|
|
data/config/locales/de.yml
CHANGED
data/config/locales/eu.yml
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UpdateUserGroupsReferences < ActiveRecord::Migration[7.2]
|
|
4
|
+
def up
|
|
5
|
+
Rails.logger.info "Starting comment body updates..."
|
|
6
|
+
|
|
7
|
+
updated_count = 0
|
|
8
|
+
skipped_count = 0
|
|
9
|
+
error_count = 0
|
|
10
|
+
|
|
11
|
+
Decidim::Comments::Comment.find_each do |comment|
|
|
12
|
+
next if comment.body.blank?
|
|
13
|
+
|
|
14
|
+
updated_body = process_comment_body(comment.body)
|
|
15
|
+
body_changed = updated_body != comment.body
|
|
16
|
+
|
|
17
|
+
if body_changed
|
|
18
|
+
comment.update_column(:body, updated_body) # rubocop:disable Rails/SkipsModelValidations
|
|
19
|
+
updated_count += 1
|
|
20
|
+
Rails.logger.info "✓ Updated comment ##{comment.id}"
|
|
21
|
+
else
|
|
22
|
+
skipped_count += 1
|
|
23
|
+
end
|
|
24
|
+
rescue StandardError => e
|
|
25
|
+
error_count += 1
|
|
26
|
+
Rails.logger.error "✗ Error updating comment ##{comment.id}: #{e.message}"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
log_summary(updated_count, skipped_count, error_count)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def down
|
|
33
|
+
raise ActiveRecord::IrreversibleMigration
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def process_comment_body(body)
|
|
39
|
+
updated_body = {}
|
|
40
|
+
|
|
41
|
+
body.each do |locale, text|
|
|
42
|
+
updated_body[locale] = if locale == "machine_translations" && text.is_a?(Hash)
|
|
43
|
+
process_machine_translations(text)
|
|
44
|
+
else
|
|
45
|
+
replace_user_group_references(text)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
updated_body
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def process_machine_translations(translations)
|
|
53
|
+
updated_translations = {}
|
|
54
|
+
|
|
55
|
+
translations.each do |translation_locale, translation_text|
|
|
56
|
+
next if translation_text.blank?
|
|
57
|
+
|
|
58
|
+
updated_translations[translation_locale] = replace_user_group_references(translation_text)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
updated_translations
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def replace_user_group_references(text)
|
|
65
|
+
return text if text.blank?
|
|
66
|
+
|
|
67
|
+
text.gsub(
|
|
68
|
+
%r{gid://([^/]+)/Decidim::UserGroup/(\d+)},
|
|
69
|
+
'gid://\1/Decidim::User/\2'
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def log_summary(updated_count, skipped_count, error_count)
|
|
74
|
+
Rails.logger.info "=" * 50
|
|
75
|
+
Rails.logger.info "Comment body update completed!"
|
|
76
|
+
Rails.logger.info "=" * 50
|
|
77
|
+
Rails.logger.info "Updated: #{updated_count}"
|
|
78
|
+
Rails.logger.info "Skipped: #{skipped_count}"
|
|
79
|
+
Rails.logger.info "Errors: #{error_count}"
|
|
80
|
+
Rails.logger.info "=" * 50
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -59,6 +59,12 @@ module Decidim
|
|
|
59
59
|
Decidim.icons.register(name: "edit-line", icon: "edit-line", description: "Edit comment button", **common_parameters)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
initializer "decidim_comments.data_migrate", after: "decidim_core.data_migrate" do
|
|
63
|
+
DataMigrate.configure do |config|
|
|
64
|
+
config.data_migrations_path << root.join("db/data").to_s
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
62
68
|
initializer "decidim_comments.register_resources" do
|
|
63
69
|
Decidim.register_resource(:comment) do |resource|
|
|
64
70
|
resource.model_class_name = "Decidim::Comments::Comment"
|
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.31.0
|
|
4
|
+
version: 0.31.0
|
|
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-
|
|
13
|
+
date: 2025-11-20 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.31.0
|
|
21
|
+
version: 0.31.0
|
|
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.31.0
|
|
28
|
+
version: 0.31.0
|
|
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.31.0
|
|
55
|
+
version: 0.31.0
|
|
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.31.0
|
|
62
|
+
version: 0.31.0
|
|
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.31.0
|
|
69
|
+
version: 0.31.0
|
|
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.31.0
|
|
76
|
+
version: 0.31.0
|
|
77
77
|
description: Pluggable comments system for some components.
|
|
78
78
|
email:
|
|
79
79
|
- josepjaume@gmail.com
|
|
@@ -253,6 +253,7 @@ files:
|
|
|
253
253
|
- config/locales/vi.yml
|
|
254
254
|
- config/locales/zh-CN.yml
|
|
255
255
|
- config/locales/zh-TW.yml
|
|
256
|
+
- db/data/20251117070404_update_user_groups_references.rb
|
|
256
257
|
- db/migrate/20161130143508_create_comments.rb
|
|
257
258
|
- db/migrate/20161214082645_add_depth_to_comments.rb
|
|
258
259
|
- db/migrate/20161216102820_add_alignment_to_comments.rb
|