decidim-comments 0.23.1 → 0.24.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
  3. data/app/assets/javascripts/decidim/comments/comments.component.js.es6 +292 -0
  4. data/app/assets/javascripts/decidim/comments/comments.component.test.js +581 -0
  5. data/app/assets/javascripts/decidim/comments/comments.js.erb +1 -1
  6. data/app/cells/decidim/comments/comment/actions.erb +7 -0
  7. data/app/cells/decidim/comments/comment/alignment_badge.erb +4 -0
  8. data/app/cells/decidim/comments/comment/author.erb +1 -0
  9. data/app/cells/decidim/comments/comment/show.erb +40 -0
  10. data/app/cells/decidim/comments/comment/utilities.erb +13 -0
  11. data/app/cells/decidim/comments/comment/votes.erb +25 -0
  12. data/app/cells/decidim/comments/comment_card_cell.rb +22 -0
  13. data/app/cells/decidim/comments/comment_cell.rb +142 -8
  14. data/app/cells/decidim/comments/comment_form/comment_as.erb +10 -0
  15. data/app/cells/decidim/comments/comment_form/show.erb +24 -0
  16. data/app/cells/decidim/comments/comment_form_cell.rb +94 -0
  17. data/app/cells/decidim/comments/comment_m/top.erb +1 -1
  18. data/app/cells/decidim/comments/comment_thread/show.erb +6 -0
  19. data/app/cells/decidim/comments/comment_thread/title.erb +3 -0
  20. data/app/cells/decidim/comments/comment_thread_cell.rb +30 -0
  21. data/app/cells/decidim/comments/comments/add_comment.erb +30 -0
  22. data/app/cells/decidim/comments/comments/blocked_comments_warning.erb +3 -0
  23. data/app/cells/decidim/comments/comments/order_control.erb +37 -0
  24. data/app/cells/decidim/comments/comments/show.erb +32 -0
  25. data/app/cells/decidim/comments/comments/single_comment_warning.erb +9 -0
  26. data/app/cells/decidim/comments/comments/user_comments_blocked_warning.erb +3 -0
  27. data/app/cells/decidim/comments/comments_cell.rb +134 -0
  28. data/app/commands/decidim/comments/vote_comment.rb +34 -10
  29. data/app/controllers/decidim/comments/application_controller.rb +16 -0
  30. data/app/controllers/decidim/comments/comments_controller.rb +122 -0
  31. data/app/controllers/decidim/comments/votes_controller.rb +41 -0
  32. data/app/events/decidim/comments/comment_created_event.rb +1 -1
  33. data/app/events/decidim/comments/comment_downvoted_event.rb +8 -0
  34. data/app/events/decidim/comments/comment_event.rb +0 -15
  35. data/app/events/decidim/comments/comment_upvoted_event.rb +8 -0
  36. data/app/events/decidim/comments/comment_voted_event.rb +26 -0
  37. data/app/forms/decidim/comments/comment_form.rb +6 -2
  38. data/app/models/decidim/comments/comment.rb +33 -11
  39. data/app/models/decidim/comments/seed.rb +1 -1
  40. data/app/permissions/decidim/comments/permissions.rb +59 -0
  41. data/app/queries/decidim/comments/metrics/comment_participants_metric_measure.rb +2 -2
  42. data/app/queries/decidim/comments/metrics/comments_metric_manage.rb +5 -6
  43. data/app/queries/decidim/comments/sorted_comments.rb +18 -14
  44. data/app/views/decidim/comments/comments/_comment.html.erb +5 -0
  45. data/app/views/decidim/comments/comments/_comments.html.erb +1 -0
  46. data/app/views/decidim/comments/comments/create.js.erb +16 -0
  47. data/app/views/decidim/comments/comments/error.js.erb +1 -0
  48. data/app/views/decidim/comments/comments/index.js.erb +24 -0
  49. data/app/views/decidim/comments/comments/reload.js.erb +21 -0
  50. data/app/views/decidim/comments/votes/create.js.erb +23 -0
  51. data/app/views/decidim/comments/votes/error.js.erb +1 -0
  52. data/config/locales/ar.yml +0 -2
  53. data/config/locales/ca.yml +17 -2
  54. data/config/locales/cs.yml +20 -3
  55. data/config/locales/de.yml +46 -30
  56. data/config/locales/el.yml +0 -2
  57. data/config/locales/en.yml +17 -2
  58. data/config/locales/es-MX.yml +17 -2
  59. data/config/locales/es-PY.yml +17 -2
  60. data/config/locales/es.yml +17 -2
  61. data/config/locales/eu.yml +0 -2
  62. data/config/locales/fi-plain.yml +17 -2
  63. data/config/locales/fi.yml +17 -2
  64. data/config/locales/fr-CA.yml +17 -2
  65. data/config/locales/fr.yml +17 -2
  66. data/config/locales/gl.yml +20 -2
  67. data/config/locales/hu.yml +0 -2
  68. data/config/locales/id-ID.yml +0 -2
  69. data/config/locales/is-IS.yml +0 -1
  70. data/config/locales/it.yml +5 -2
  71. data/config/locales/ja.yml +14 -10
  72. data/config/locales/lv.yml +0 -2
  73. data/config/locales/nl.yml +7 -9
  74. data/config/locales/no.yml +0 -2
  75. data/config/locales/pl.yml +22 -4
  76. data/config/locales/pt-BR.yml +0 -2
  77. data/config/locales/pt.yml +0 -2
  78. data/config/locales/ro-RO.yml +0 -2
  79. data/config/locales/ru.yml +0 -2
  80. data/config/locales/si-LK.yml +1 -0
  81. data/config/locales/sk.yml +0 -2
  82. data/config/locales/sv.yml +7 -2
  83. data/config/locales/sw-KE.yml +1 -0
  84. data/config/locales/tr-TR.yml +60 -35
  85. data/config/locales/uk.yml +0 -1
  86. data/config/locales/zh-CN.yml +0 -2
  87. data/lib/decidim/api/add_comment_type.rb +13 -0
  88. data/lib/decidim/api/comment_mutation_type.rb +22 -0
  89. data/lib/decidim/api/comment_type.rb +89 -0
  90. data/lib/decidim/api/commentable_interface.rb +50 -0
  91. data/lib/decidim/api/commentable_mutation_type.rb +30 -0
  92. data/{app/types/decidim/comments → lib/decidim/api}/commentable_type.rb +2 -5
  93. data/lib/decidim/comments.rb +1 -3
  94. data/lib/decidim/comments/api.rb +12 -0
  95. data/lib/decidim/comments/comments_helper.rb +10 -52
  96. data/lib/decidim/comments/engine.rb +9 -7
  97. data/lib/decidim/comments/mutation_extensions.rb +22 -22
  98. data/lib/decidim/comments/query_extensions.rb +12 -14
  99. data/lib/decidim/comments/test.rb +1 -0
  100. data/lib/decidim/comments/test/shared_examples/comment_voted_event.rb +65 -0
  101. data/lib/decidim/comments/version.rb +1 -1
  102. metadata +72 -69
  103. data/app/assets/javascripts/decidim/comments/bundle.js +0 -268
  104. data/app/frontend/application/apollo_client.ts +0 -12
  105. data/app/frontend/application/application.component.test.tsx +0 -23
  106. data/app/frontend/application/application.component.tsx +0 -35
  107. data/app/frontend/application/icon.component.test.tsx +0 -38
  108. data/app/frontend/application/icon.component.tsx +0 -46
  109. data/app/frontend/comments/add_comment_form.component.test.tsx +0 -265
  110. data/app/frontend/comments/add_comment_form.component.tsx +0 -482
  111. data/app/frontend/comments/comment.component.test.tsx +0 -490
  112. data/app/frontend/comments/comment.component.tsx +0 -677
  113. data/app/frontend/comments/comment_order_selector.component.test.tsx +0 -29
  114. data/app/frontend/comments/comment_order_selector.component.tsx +0 -106
  115. data/app/frontend/comments/comment_thread.component.test.tsx +0 -82
  116. data/app/frontend/comments/comment_thread.component.tsx +0 -81
  117. data/app/frontend/comments/comments.component.test.tsx +0 -150
  118. data/app/frontend/comments/comments.component.tsx +0 -289
  119. data/app/frontend/comments/down_vote_button.component.test.tsx +0 -59
  120. data/app/frontend/comments/down_vote_button.component.tsx +0 -133
  121. data/app/frontend/comments/up_vote_button.component.test.tsx +0 -59
  122. data/app/frontend/comments/up_vote_button.component.tsx +0 -133
  123. data/app/frontend/comments/vote_button.component.tsx +0 -50
  124. data/app/frontend/comments/vote_button_component.test.tsx +0 -64
  125. data/app/frontend/entry.ts +0 -38
  126. data/app/frontend/entry_test.ts +0 -6
  127. data/app/frontend/fragments/add_comment_form_commentable.fragment.graphql +0 -4
  128. data/app/frontend/fragments/add_comment_form_session.fragment.graphql +0 -6
  129. data/app/frontend/fragments/comment.fragment.graphql +0 -14
  130. data/app/frontend/fragments/comment_data.fragment.graphql +0 -27
  131. data/app/frontend/fragments/comment_thread.fragment.graphql +0 -6
  132. data/app/frontend/fragments/down_vote_button.fragment.graphql +0 -6
  133. data/app/frontend/fragments/up_vote_button.fragment.graphql +0 -6
  134. data/app/frontend/mutations/add_comment.mutation.graphql +0 -9
  135. data/app/frontend/mutations/down_vote.mutation.graphql +0 -9
  136. data/app/frontend/mutations/up_vote.mutation.graphql +0 -9
  137. data/app/frontend/queries/comments.query.graphql +0 -26
  138. data/app/frontend/support/asset_url.ts +0 -11
  139. data/app/frontend/support/generate_comments_data.ts +0 -49
  140. data/app/frontend/support/generate_user_data.ts +0 -14
  141. data/app/frontend/support/generate_user_group_data.ts +0 -14
  142. data/app/frontend/support/graphql_transformer.js +0 -32
  143. data/app/frontend/support/load_translations.ts +0 -48
  144. data/app/frontend/support/require_all.ts +0 -10
  145. data/app/frontend/support/resolve_graphql_query.ts +0 -37
  146. data/app/frontend/support/schema.ts +0 -2026
  147. data/app/types/decidim/comments/commentable_interface.rb +0 -61
  148. data/app/types/decidim/comments/commentable_mutation_type.rb +0 -33
  149. data/lib/decidim/comments/api/add_comment_type.rb +0 -13
  150. data/lib/decidim/comments/api/comment_mutation_type.rb +0 -20
  151. data/lib/decidim/comments/api/comment_type.rb +0 -89
@@ -1,5 +1,5 @@
1
1
  // = require_self
2
- // = require ./bundle
2
+ // = require decidim/comments/comments.component
3
3
 
4
4
  window.DecidimComments = window.DecidimComments || {};
5
5
 
@@ -0,0 +1,7 @@
1
+ <div class="comment__actions">
2
+ <% if can_reply? %>
3
+ <button class="comment__reply muted-link" aria-controls="<%= reply_id %>" data-toggle="<%= reply_id %>">
4
+ <%= icon "pencil", class: "icon--small", role: "none presentation" %>&nbsp;<%= t("decidim.components.comment.reply") %>
5
+ </button>
6
+ <% end %>
7
+ </div>
@@ -0,0 +1,4 @@
1
+ <span>
2
+ <span class="<%= alignment_badge_classes %>"><%= alignment_badge_label %></span>
3
+ &nbsp;
4
+ </span>
@@ -0,0 +1 @@
1
+ <%== cell("decidim/author", author_presenter).profile %>
@@ -0,0 +1,40 @@
1
+ <%= content_tag :div, id: "comment_#{model.id}", class: comment_classes, data: { comment_id: model.id } do %>
2
+ <div class="comment__header">
3
+ <div class="author-data">
4
+ <div class="author-data__main">
5
+ <%= render :author %>
6
+ <span>
7
+ <%= time_tag created_at, l(created_at, format: :decidim_short) %>
8
+ </span>
9
+ </div>
10
+ <div class="author-data__extra">
11
+ <%= render :utilities %>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ <div class="comment__content">
16
+ <%= alignment_badge %>
17
+ <%= comment_body %>
18
+ </div>
19
+ <div class="comment__footer">
20
+ <%= render :actions %>
21
+ <%= votes %>
22
+ </div>
23
+ <div id="comment-<%= model.id %>-replies">
24
+ <% if has_replies? %>
25
+ <% replies.each do |reply| %>
26
+ <%= cell("decidim/comments/comment", reply, root_depth: root_depth, order: order) %>
27
+ <% end %>
28
+ <% end %>
29
+ </div>
30
+ <% if can_reply? %>
31
+ <div class="comment__additionalreply<%= " hide" unless has_replies? %>">
32
+ <button class="comment__reply muted-link" aria-controls="<%= reply_id %>" data-toggle="<%= reply_id %>">
33
+ <%= icon "pencil", class: "icon--small", role: "none presentation" %>&nbsp;<%= t("decidim.components.comment.reply") %>
34
+ </button>
35
+ </div>
36
+ <div class="add-comment hide" id="<%= reply_id %>" data-toggler=".hide">
37
+ <%== cell("decidim/comments/comment_form", model, root_depth: root_depth, order: order) %>
38
+ </div>
39
+ <% end %>
40
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <button type="button" class="link-alt" data-open="<%= current_user.present? ? "flagModalComment#{model.id}" : "loginModal" %>" title="<%= t("decidim.components.comment.report.title") %>" aria-controls="<%= current_user.present? ? "flagModalComment#{model.id}" : "loginModal" %>" aria-haspopup="true" tabindex="0">
2
+ <%= icon "flag", aria_hidden: true, class: "icon--small", role: "none presentation", "aria-hidden": true %>
3
+ <span class="show-for-sr"><%= t("decidim.components.comment.report.title") %></span>
4
+ </button>
5
+
6
+ <%= link_to "#{commentable_path("commentId" => model.id)}#comment_#{model.id}", title: t("decidim.components.comment.single_comment_link_title") do %>
7
+ <span class="show-for-sr"><%= t("decidim.components.comment.single_comment_link_title") %></span>
8
+ <%= icon "link-intact", class: "icon--small", role: "none presentation" %>
9
+ <% end %>
10
+
11
+ <% if current_user.present? %>
12
+ <%= cell("decidim/flag_modal", model, modal_id: "flagModalComment#{model.id}") %>
13
+ <% end %>
@@ -0,0 +1,25 @@
1
+ <div class="comment__votes">
2
+ <% if user_signed_in? %>
3
+ <%= button_to decidim_comments.comment_votes_path(model, weight: 1), remote: true, disabled: voted_down?, class: votes_up_classes, title: t("decidim.components.up_vote_button.text") do %>
4
+ <span class="show-for-sr"><%= t("decidim.components.up_vote_button.text") %></span>
5
+ <%= icon "chevron-top", class: "icon--small", role: "none presentation" %>
6
+ <span class="comment__votes--count"><%= up_votes_count %></span>
7
+ <% end %>
8
+ <%= button_to decidim_comments.comment_votes_path(model, weight: -1), remote: true, disabled: voted_up?, class: votes_down_classes, title: t("decidim.components.down_vote_button.text") do %>
9
+ <span class="show-for-sr"><%= t("decidim.components.down_vote_button.text") %></span>
10
+ <%= icon "chevron-bottom", class: "icon--small", role: "none presentation" %>
11
+ <span class="comment__votes--count"><%= down_votes_count %></span>
12
+ <% end %>
13
+ <% else %>
14
+ <button class="<%= votes_up_classes %> " title="<%= t("decidim.components.up_vote_button.text") %>" data-open="loginModal">
15
+ <span class="show-for-sr"><%= t("decidim.components.up_vote_button.text") %></span>
16
+ <%= icon "chevron-top", class: "icon--small", role: "none presentation" %>
17
+ <span class="comment__votes--count"><%= up_votes_count %></span>
18
+ </button>
19
+ <button class="<%= votes_down_classes %> " title="<%= t("decidim.components.down_vote_button.text") %>" data-open="loginModal">
20
+ <span class="show-for-sr"><%= t("decidim.components.down_vote_button.text") %></span>
21
+ <%= icon "chevron-bottom", class: "icon--small", role: "none presentation" %>
22
+ <span class="comment__votes--count"><%= down_votes_count %></span>
23
+ </button>
24
+ <% end %>
25
+ </div>
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Comments
5
+ # This cell renders the comment card for an instance of a Comment
6
+ # the default size is the Medium Card (:m)
7
+ class CommentCardCell < Decidim::ViewModel
8
+ include CommentCellsHelper
9
+ include Cell::ViewModel::Partial
10
+
11
+ def show
12
+ cell card_size, model, options
13
+ end
14
+
15
+ private
16
+
17
+ def card_size
18
+ "decidim/comments/comment_m"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -2,20 +2,154 @@
2
2
 
3
3
  module Decidim
4
4
  module Comments
5
- # This cell renders the comment card for an instance of a Comment
6
- # the default size is the Medium Card (:m)
5
+ # A cell to display a single comment.
7
6
  class CommentCell < Decidim::ViewModel
8
- include CommentCellsHelper
9
- include Cell::ViewModel::Partial
7
+ include ActionView::Helpers::DateHelper
8
+ include Decidim::IconHelper
9
+ include Decidim::ResourceHelper
10
10
 
11
- def show
12
- cell card_size, model, options
11
+ delegate :current_user, :user_signed_in?, to: :controller
12
+
13
+ property :root_commentable
14
+ property :created_at
15
+ property :alignment
16
+ property :translated_body
17
+ property :comment_threads
18
+ property :accepts_new_comments?
19
+
20
+ def alignment_badge
21
+ return unless [-1, 1].include?(alignment)
22
+
23
+ render :alignment_badge
24
+ end
25
+
26
+ def votes
27
+ return unless root_commentable.comments_have_votes?
28
+
29
+ render :votes
13
30
  end
14
31
 
15
32
  private
16
33
 
17
- def card_size
18
- "decidim/comments/comment_m"
34
+ def decidim_comments
35
+ Decidim::Comments::Engine.routes.url_helpers
36
+ end
37
+
38
+ def comment_body
39
+ Decidim::ContentProcessor.render(translated_body)
40
+ end
41
+
42
+ def replies
43
+ SortedComments.for(model, order_by: order)
44
+ end
45
+
46
+ def order
47
+ options[:order] || "older"
48
+ end
49
+
50
+ def reply_id
51
+ "comment#{model.id}-reply"
52
+ end
53
+
54
+ def can_reply?
55
+ user_signed_in? && accepts_new_comments? &&
56
+ root_commentable.user_allowed_to_comment?(current_user)
57
+ end
58
+
59
+ def author_presenter
60
+ if model.author.respond_to?(:official?) && model.author.official?
61
+ Decidim::Core::OfficialAuthorPresenter.new
62
+ elsif model.user_group
63
+ model.user_group.presenter
64
+ else
65
+ model.author.presenter
66
+ end
67
+ end
68
+
69
+ def comment_classes
70
+ classes = ["comment"]
71
+ if nested?
72
+ classes << "comment--nested"
73
+ classes << "comment--nested--alt" if nested_level_even?
74
+ end
75
+ classes.join(" ")
76
+ end
77
+
78
+ def alignment_badge_classes
79
+ classes = %w(label alignment)
80
+ case alignment
81
+ when 1
82
+ classes << "success"
83
+ when -1
84
+ classes << "alert"
85
+ end
86
+ classes.join(" ")
87
+ end
88
+
89
+ def alignment_badge_label
90
+ if alignment == 1
91
+ I18n.t("decidim.components.comment.alignment.in_favor")
92
+ else
93
+ I18n.t("decidim.components.comment.alignment.against")
94
+ end
95
+ end
96
+
97
+ def votes_up_classes
98
+ classes = ["comment__votes--up"]
99
+ classes << "is-vote-selected" if voted_up?
100
+ classes << "is-vote-notselected" if voted_down?
101
+ classes.join(" ")
102
+ end
103
+
104
+ def votes_down_classes
105
+ classes = ["comment__votes--down"]
106
+ classes << "is-vote-selected" if voted_down?
107
+ classes << "is-vote-notselected" if voted_up?
108
+ classes.join(" ")
109
+ end
110
+
111
+ def commentable_path(params = {})
112
+ if root_commentable.is_a?(Decidim::Budgets::Project)
113
+ resource_locator([root_commentable.budget, root_commentable]).path(params)
114
+ else
115
+ resource_locator(root_commentable).path(params)
116
+ end
117
+ end
118
+
119
+ def up_votes_count
120
+ model.up_votes.count
121
+ end
122
+
123
+ def down_votes_count
124
+ model.down_votes.count
125
+ end
126
+
127
+ def root_depth
128
+ options[:root_depth] || 0
129
+ end
130
+
131
+ def depth
132
+ model.depth - root_depth
133
+ end
134
+
135
+ def voted_up?
136
+ model.up_voted_by?(current_user)
137
+ end
138
+
139
+ def voted_down?
140
+ model.down_voted_by?(current_user)
141
+ end
142
+
143
+ def nested?
144
+ depth.positive?
145
+ end
146
+
147
+ def nested_level_even?
148
+ depth.even?
149
+ end
150
+
151
+ def has_replies?
152
+ model.comment_threads.any?
19
153
  end
20
154
  end
21
155
  end
@@ -0,0 +1,10 @@
1
+ <div class="field">
2
+ <label for="<%= comment_as_id %>">
3
+ <%= t("decidim.components.add_comment_form.form.user_group_id.label") %>
4
+ </label>
5
+ <select id="<%= comment_as_id %>" name="comment[user_group_id]">
6
+ <% comment_as_options.each do |option| %>
7
+ <option value="<%= option[1] %>"><%= option[0] %></option>
8
+ <% end %>
9
+ </select>
10
+ </div>
@@ -0,0 +1,24 @@
1
+ <%= form_for(form_object, url: decidim_comments.comments_path(order: order), method: :post, remote: true, html: { id: form_id }) do |form| %>
2
+ <%= form.hidden_field :commentable_gid, id: nil %>
3
+ <%= form.hidden_field :alignment, id: nil, class: "alignment-input" %>
4
+ <%= comment_as_for(form) %>
5
+ <div class="field">
6
+ <label class="show-for-sr" for="<%= add_comment_id %>">
7
+ <%= t("decidim.components.add_comment_form.form.body.label") %>
8
+ </label>
9
+ <div class="hashtags__container">
10
+ <%= form.text_area(
11
+ :body,
12
+ id: add_comment_id,
13
+ rows: 4,
14
+ maxlength: comments_max_length,
15
+ required: true,
16
+ placeholder: t("decidim.components.add_comment_form.form.body.placeholder"),
17
+ label: false,
18
+ data: { remaining_characters: "##{add_comment_id}-remaining-characters" }
19
+ ) %>
20
+ </div>
21
+ <button type="submit" class="button button--sc" disabled="disabled"><%= t("decidim.components.add_comment_form.form.submit") %></button>
22
+ <span id="<%= add_comment_id %>-remaining-characters" class="remaining-character-count"></span>
23
+ </div>
24
+ <% end %>
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Comments
5
+ # A cell to display a form for adding a new comment.
6
+ class CommentFormCell < Decidim::ViewModel
7
+ delegate :current_user, :user_signed_in?, to: :controller
8
+
9
+ def comment_as_for(form)
10
+ return if verified_user_groups.blank?
11
+
12
+ # Note that the form.select does not seem to work correctly in the cell
13
+ # context. The Rails form builder tries to call @template.select which
14
+ # is not available for the cell objects.
15
+ render view: :comment_as, locals: { form: form }
16
+ end
17
+
18
+ private
19
+
20
+ def decidim_comments
21
+ Decidim::Comments::Engine.routes.url_helpers
22
+ end
23
+
24
+ def order
25
+ options[:order] || "older"
26
+ end
27
+
28
+ def commentable_type
29
+ model.commentable_type
30
+ end
31
+
32
+ def form_id
33
+ "new_comment_for_#{commentable_type.demodulize}_#{model.id}"
34
+ end
35
+
36
+ def add_comment_id
37
+ "add-comment-#{commentable_type.demodulize}-#{model.id}"
38
+ end
39
+
40
+ def comment_as_id
41
+ "add-comment-#{commentable_type.demodulize}-#{model.id}-user-group-id"
42
+ end
43
+
44
+ def root_depth
45
+ options[:root_depth] || 0
46
+ end
47
+
48
+ def form_object
49
+ Decidim::Comments::CommentForm.new(
50
+ commentable_gid: model.to_signed_global_id.to_s,
51
+ alignment: 0
52
+ )
53
+ end
54
+
55
+ def verified_user_groups
56
+ return [] unless current_user
57
+
58
+ @verified_user_groups ||= Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
59
+ end
60
+
61
+ def comment_as_options
62
+ [[current_user.name, ""]] + verified_user_groups.map do |group|
63
+ [group.name, group.id]
64
+ end
65
+ end
66
+
67
+ def comments_max_length
68
+ return 1000 unless model.respond_to?(:component)
69
+ return component_comments_max_length if component_comments_max_length
70
+ return organization_comments_max_length if organization_comments_max_length
71
+
72
+ 1000
73
+ end
74
+
75
+ def component_comments_max_length
76
+ return unless model.component&.settings.respond_to?(:comments_max_length)
77
+
78
+ model.component.settings.comments_max_length if model.component.settings.comments_max_length.positive?
79
+ end
80
+
81
+ def organization_comments_max_length
82
+ return unless organization
83
+
84
+ organization.comments_max_length if organization.comments_max_length.positive?
85
+ end
86
+
87
+ def organization
88
+ return model.organization if model.respond_to?(:organization)
89
+
90
+ model.component.organization if model.component.organization.comments_max_length.positive?
91
+ end
92
+ end
93
+ end
94
+ end
@@ -1,7 +1,7 @@
1
1
  <div class="card__top">
2
2
  <% if render_space? %>
3
3
  <div class="card__content text-small">
4
- <span class="muted"><%= searchable_resource_human_name(model.root_commentable.class) %>:</span>&nbsp;<%= link_to root_commentable_title, resource_link_path, class: "card__link text-ellipsis" %>
4
+ <span class="muted"><%= searchable_resource_human_name(model.root_commentable.class, count: 1) %>:</span>&nbsp;<%= link_to root_commentable_title, resource_link_path, class: "card__link text-ellipsis" %>
5
5
  </div>
6
6
  <% end %>
7
7
  </div>
@@ -0,0 +1,6 @@
1
+ <div>
2
+ <%= title %>
3
+ <div class="comment-thread">
4
+ <%= cell("decidim/comments/comment", model, root_depth: model.depth, order: order) %>
5
+ </div>
6
+ </div>