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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db61183a2914f1449e47ae59e79af732d2298593b617dccd1f729cdb84201957
4
- data.tar.gz: b5822d26479e2a25527c45037210d4594fff730ed10f4ce0ef9e29a9e7c1377d
3
+ metadata.gz: f5e4186412267c1d490b61e28cb302d2ff11b7c162b2012306b36b74a87c6eb6
4
+ data.tar.gz: 6a3ae0d23d4917e2e8e6cd2fdef71d16b503f04bcc348e014194cf1381116139
5
5
  SHA512:
6
- metadata.gz: c414291891ac6ad8f8904d6e97599e9bbab52f7c07b4e93dfb60dace6abb80f2042834d82edf080a9cf365fbfdce35613edc8f76b831ae95746c6b11beb833dd
7
- data.tar.gz: 53112244ce496b3920f0da1cf74ad31608c19b790d9085053bfbba4e56df39d8a3634f30203905d11c0208649e4d4d1b9d8749d78d4942f2bbbccd5608b38c26
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 class="input-hidden" value="" <%= "disabled selected hidden" %>> <%= t("decidim.components.comment.sort_by") %> </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 order_value == order %>
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">
@@ -108,7 +108,7 @@ module Decidim
108
108
  end
109
109
 
110
110
  def order
111
- options[:order]
111
+ options[:order] || "older"
112
112
  end
113
113
 
114
114
  def decidim
@@ -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
- else
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
 
@@ -175,7 +175,7 @@
175
175
  }
176
176
 
177
177
  &-author-name {
178
- @apply text-secondary font-semibold;
178
+ @apply text-gray-2 font-semibold;
179
179
  }
180
180
 
181
181
  &-author-selected {
@@ -10,6 +10,7 @@
10
10
  $comments.html(commentsHtml);
11
11
 
12
12
  // Re-mount the component
13
+ component.order = "<%= order %>"
13
14
  component.mountComponent();
14
15
 
15
16
  // Update the comments count
@@ -67,7 +67,7 @@ de:
67
67
  comment:
68
68
  alignment:
69
69
  against: Gegen
70
- in_favor: Zugunsten
70
+ in_favor: Dafür
71
71
  answers:
72
72
  one: "%{count} Antwort"
73
73
  other: "%{count} Antworten"
@@ -122,7 +122,7 @@ eu:
122
122
  title:
123
123
  one: "Iruzkin bat"
124
124
  other: "%{count} iruzkin"
125
- top_comment_label: Bozkatuenak
125
+ top_comment_label: Babes gehien galdu dituztenak
126
126
  down_vote_button:
127
127
  label:
128
128
  one: Ez dut atsegin botoia. %{count} ez-atsegin
@@ -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"
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-comments version.
5
5
  module Comments
6
6
  def self.version
7
- "0.31.0.rc1"
7
+ "0.31.0"
8
8
  end
9
9
  end
10
10
  end
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.rc1
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-09-25 00:00:00.000000000 Z
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.rc1
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.rc1
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.rc1
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.rc1
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.rc1
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.rc1
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