decidim-proposals 0.23.6 → 0.24.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
  3. data/app/assets/stylesheets/decidim/proposals/_proposals.css.scss +1 -0
  4. data/app/assets/stylesheets/decidim/proposals/proposals/_preview.css.scss +3 -0
  5. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +3 -3
  6. data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +3 -0
  7. data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +15 -0
  8. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +5 -0
  9. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +1 -0
  10. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +19 -0
  11. data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
  12. data/app/cells/decidim/proposals/proposal_activity_cell.rb +5 -13
  13. data/app/cells/decidim/proposals/proposal_m_cell.rb +23 -2
  14. data/app/cells/decidim/proposals/proposals_picker_cell.rb +1 -1
  15. data/app/cells/decidim/proposals/reported_content/show.erb +4 -0
  16. data/app/cells/decidim/proposals/reported_content_cell.rb +13 -0
  17. data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
  18. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +6 -4
  19. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -30
  20. data/app/controllers/decidim/proposals/proposals_controller.rb +9 -12
  21. data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
  22. data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +1 -3
  23. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +3 -2
  24. data/app/forms/decidim/proposals/proposal_form.rb +15 -5
  25. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -1
  26. data/app/helpers/decidim/proposals/admin/filterable_helper.rb +1 -1
  27. data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +1 -1
  28. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +8 -8
  29. data/app/helpers/decidim/proposals/application_helper.rb +5 -2
  30. data/app/helpers/decidim/proposals/map_helper.rb +25 -8
  31. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -44
  32. data/app/helpers/decidim/proposals/proposals_helper.rb +3 -6
  33. data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
  34. data/app/models/decidim/proposals/proposal.rb +18 -10
  35. data/app/permissions/decidim/proposals/admin/permissions.rb +2 -2
  36. data/app/permissions/decidim/proposals/permissions.rb +3 -2
  37. data/app/presenters/decidim/proposals/proposal_presenter.rb +4 -4
  38. data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +4 -4
  39. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +6 -6
  40. data/app/services/decidim/proposals/collaborative_draft_search.rb +1 -1
  41. data/app/services/decidim/proposals/diff_renderer.rb +7 -11
  42. data/app/services/decidim/proposals/proposal_builder.rb +2 -3
  43. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
  44. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +5 -1
  45. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +1 -1
  46. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +2 -7
  47. data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +14 -0
  48. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +1 -3
  49. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
  50. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -7
  51. data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
  52. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +2 -2
  53. data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
  54. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
  55. data/app/views/decidim/proposals/proposals/edit.html.erb +1 -3
  56. data/app/views/decidim/proposals/proposals/index.html.erb +1 -1
  57. data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
  58. data/app/views/decidim/proposals/proposals/show.html.erb +2 -8
  59. data/config/locales/ar.yml +2 -23
  60. data/config/locales/bg.yml +0 -4
  61. data/config/locales/ca.yml +9 -32
  62. data/config/locales/cs.yml +49 -56
  63. data/config/locales/de.yml +23 -30
  64. data/config/locales/el.yml +2 -29
  65. data/config/locales/en.yml +23 -30
  66. data/config/locales/es-MX.yml +3 -31
  67. data/config/locales/es-PY.yml +3 -31
  68. data/config/locales/es.yml +3 -31
  69. data/config/locales/eu.yml +2 -23
  70. data/config/locales/fi-plain.yml +18 -29
  71. data/config/locales/fi.yml +18 -29
  72. data/config/locales/fr-CA.yml +19 -30
  73. data/config/locales/fr.yml +19 -30
  74. data/config/locales/gl.yml +4 -97
  75. data/config/locales/hu.yml +2 -23
  76. data/config/locales/id-ID.yml +2 -23
  77. data/config/locales/is-IS.yml +0 -8
  78. data/config/locales/it.yml +4 -29
  79. data/config/locales/ja.yml +2 -29
  80. data/config/locales/lv.yml +2 -22
  81. data/config/locales/nl.yml +13 -30
  82. data/config/locales/no.yml +2 -23
  83. data/config/locales/pl.yml +13 -33
  84. data/config/locales/pt-BR.yml +2 -22
  85. data/config/locales/pt.yml +2 -29
  86. data/config/locales/ro-RO.yml +2 -84
  87. data/config/locales/ru.yml +0 -8
  88. data/config/locales/sk.yml +5 -23
  89. data/config/locales/sv.yml +7 -38
  90. data/config/locales/tr-TR.yml +17 -29
  91. data/config/locales/uk.yml +0 -8
  92. data/config/locales/zh-CN.yml +2 -29
  93. data/db/migrate/20200915151348_fix_proposals_data_to_ensure_title_and_body_are_hashes.rb +37 -0
  94. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_filter.rb +0 -0
  95. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_sort.rb +3 -5
  96. data/lib/decidim/api/proposal_type.rb +56 -0
  97. data/lib/decidim/api/proposals_type.rb +43 -0
  98. data/lib/decidim/content_renderers/proposal_renderer.rb +1 -1
  99. data/lib/decidim/proposals/api.rb +10 -0
  100. data/lib/decidim/proposals/component.rb +30 -19
  101. data/lib/decidim/proposals/engine.rb +6 -27
  102. data/lib/decidim/proposals/proposal_creator.rb +98 -0
  103. data/lib/decidim/proposals/test/factories.rb +22 -8
  104. data/lib/decidim/proposals/version.rb +1 -1
  105. data/lib/decidim/proposals.rb +2 -0
  106. metadata +50 -38
  107. data/app/commands/decidim/proposals/create_proposal_export.rb +0 -37
  108. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -0
  109. data/app/queries/decidim/proposals/similar_collaborative_drafts.rb +0 -52
  110. data/app/types/decidim/proposals/proposal_type.rb +0 -70
  111. data/app/types/decidim/proposals/proposals_type.rb +0 -41
  112. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +0 -13
  113. data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +0 -21
  114. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +0 -24
  115. data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +0 -1
  116. data/db/migrate/20210318082934_fix_counters_for_copied_proposals.rb +0 -16
@@ -32,7 +32,7 @@ module Decidim
32
32
  #
33
33
  # step - A symbol of the target step
34
34
  def proposal_wizard_step_name(step)
35
- t("decidim.proposals.#{type_of}.wizard_steps.#{step}")
35
+ t("decidim.proposals.proposals.wizard_steps.#{step}")
36
36
  end
37
37
 
38
38
  # Returns the page title of the given step, translated
@@ -48,7 +48,7 @@ module Decidim
48
48
  action_name
49
49
  end
50
50
 
51
- t("decidim.proposals.#{type_of}.#{step_title}.title")
51
+ t("decidim.proposals.proposals.#{step_title}.title")
52
52
  end
53
53
 
54
54
  # Returns the list item of the given step, in html
@@ -56,8 +56,6 @@ module Decidim
56
56
  # step - A symbol of the target step
57
57
  # current_step - A symbol of the current step
58
58
  def proposal_wizard_stepper_step(step, current_step)
59
- return if step == :step_4 && type_of == :collaborative_drafts
60
-
61
59
  attributes = { class: proposal_wizard_step_classes(step, current_step).to_s }
62
60
  step_title = proposal_wizard_step_name(step)
63
61
  if step.to_s.split("_").last.to_i == proposal_wizard_step_number(current_step)
@@ -99,7 +97,7 @@ module Decidim
99
97
  end
100
98
 
101
99
  def proposal_wizard_steps_title
102
- t("title", scope: "decidim.proposals.#{type_of}.wizard_steps")
100
+ t("title", scope: "decidim.proposals.proposals.wizard_steps")
103
101
  end
104
102
 
105
103
  # Returns a boolean if the step has a help text defined
@@ -128,58 +126,30 @@ module Decidim
128
126
  private
129
127
 
130
128
  def total_steps
131
- case type_of
132
- when :collaborative_drafts
133
- 3
134
- when :proposals
135
- 4
136
- else
137
- 4
138
- end
129
+ 4
139
130
  end
140
131
 
141
132
  def wizard_aside_info_text
142
- case type_of
143
- when :collaborative_drafts
144
- t("info", scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe
145
- else
146
- t("info", scope: "decidim.proposals.proposals.wizard_aside").html_safe
147
- end
133
+ t("info", scope: "decidim.proposals.proposals.wizard_aside").html_safe
148
134
  end
149
135
 
150
136
  # Renders the back link except for step_2: compare
151
137
  def proposal_wizard_aside_link_to_back(step)
152
- url = case step
153
- when :step_1
154
- proposals_path
155
- when :step_3
156
- compare_proposal_path
157
- when :step_4
158
- edit_draft_proposal_path
159
- end
160
- url
138
+ case step
139
+ when :step_1
140
+ proposals_path
141
+ when :step_3
142
+ compare_proposal_path
143
+ when :step_4
144
+ edit_draft_proposal_path
145
+ end
161
146
  end
162
147
 
163
148
  def wizard_aside_back_text(from = nil)
164
149
  key = "back"
165
150
  key = "back_from_#{from}" if from
166
151
 
167
- case type_of
168
- when :collaborative_drafts
169
- t(key, scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe
170
- else
171
- t(key, scope: "decidim.proposals.proposals.wizard_aside").html_safe
172
- end
173
- end
174
-
175
- def type_of
176
- if ["Decidim::Proposals::CollaborativeDraftForm"].include? @form.class.name
177
- :collaborative_drafts
178
- elsif @collaborative_draft.present?
179
- :collaborative_drafts
180
- else
181
- :proposals
182
- end
152
+ t(key, scope: "decidim.proposals.proposals.wizard_aside").html_safe
183
153
  end
184
154
  end
185
155
  end
@@ -4,13 +4,10 @@ module Decidim
4
4
  module Proposals
5
5
  # Simple helpers to handle markup variations for proposals
6
6
  module ProposalsHelper
7
- def proposal_reason_callout_args
7
+ def proposal_reason_callout_announcement
8
8
  {
9
- announcement: {
10
- title: proposal_reason_callout_title,
11
- body: decidim_sanitize(translated_attribute(@proposal.answer))
12
- },
13
- callout_class: proposal_reason_callout_class
9
+ title: proposal_reason_callout_title,
10
+ body: decidim_sanitize(translated_attribute(@proposal.answer))
14
11
  }
15
12
  end
16
13
 
@@ -58,6 +58,16 @@ module Decidim
58
58
  def reported_content_url
59
59
  ResourceLocatorPresenter.new(self).url
60
60
  end
61
+
62
+ # Public: Overrides the `reported_attributes` Reportable concern method.
63
+ def reported_attributes
64
+ [:body]
65
+ end
66
+
67
+ # Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
68
+ def reported_searchable_content_extras
69
+ [authors.map(&:name).join("\n")]
70
+ end
61
71
  end
62
72
  end
63
73
  end
@@ -69,12 +69,13 @@ module Decidim
69
69
  scope :drafts, -> { where(published_at: nil) }
70
70
  scope :except_drafts, -> { where.not(published_at: nil) }
71
71
  scope :published, -> { where.not(published_at: nil) }
72
+ scope :order_by_most_recent, -> { order(created_at: :desc) }
72
73
  scope :sort_by_valuation_assignments_count_asc, lambda {
73
- order(sort_by_valuation_assignments_count_nulls_last_query + "ASC NULLS FIRST")
74
+ order("#{sort_by_valuation_assignments_count_nulls_last_query}ASC NULLS FIRST")
74
75
  }
75
76
 
76
77
  scope :sort_by_valuation_assignments_count_desc, lambda {
77
- order(sort_by_valuation_assignments_count_nulls_last_query + "DESC NULLS LAST")
78
+ order("#{sort_by_valuation_assignments_count_nulls_last_query}DESC NULLS LAST")
78
79
  }
79
80
 
80
81
  def self.with_valuation_assigned_to(user, space)
@@ -106,7 +107,7 @@ module Decidim
106
107
  return unless author.is_a?(Decidim::User)
107
108
 
108
109
  joins(:coauthorships)
109
- .where("decidim_coauthorships.coauthorable_type = ?", name)
110
+ .where(decidim_coauthorships: { coauthorable_type: name })
110
111
  .where("decidim_coauthorships.decidim_author_id = ? AND decidim_coauthorships.decidim_author_type = ? ", author.id, author.class.base_class.name)
111
112
  end
112
113
 
@@ -227,6 +228,16 @@ module Decidim
227
228
  ResourceLocatorPresenter.new(self).url
228
229
  end
229
230
 
231
+ # Public: Overrides the `reported_attributes` Reportable concern method.
232
+ def reported_attributes
233
+ [:title, :body]
234
+ end
235
+
236
+ # Public: Overrides the `reported_searchable_content_extras` Reportable concern method.
237
+ def reported_searchable_content_extras
238
+ [authors.map(&:name).join("\n")]
239
+ end
240
+
230
241
  # Public: Whether the proposal is official or not.
231
242
  def official?
232
243
  authors.first.is_a?(Decidim::Organization)
@@ -286,7 +297,7 @@ module Decidim
286
297
 
287
298
  # Defines the base query so that ransack can actually sort by this value
288
299
  def self.sort_by_valuation_assignments_count_nulls_last_query
289
- <<-SQL
300
+ <<-SQL.squish
290
301
  (
291
302
  SELECT COUNT(decidim_proposals_valuation_assignments.id)
292
303
  FROM decidim_proposals_valuation_assignments
@@ -298,7 +309,7 @@ module Decidim
298
309
 
299
310
  # method to filter by assigned valuator role ID
300
311
  def self.valuator_role_ids_has(value)
301
- query = <<-SQL
312
+ query = <<-SQL.squish
302
313
  :value = any(
303
314
  (SELECT decidim_proposals_valuation_assignments.valuator_role_id
304
315
  FROM decidim_proposals_valuation_assignments
@@ -326,10 +337,6 @@ module Decidim
326
337
  ")
327
338
  end
328
339
 
329
- ransacker :state do
330
- Arel.sql("CASE WHEN state = 'withdrawn' THEN 'withdrawn' WHEN state_published_at IS NULL THEN NULL ELSE state END")
331
- end
332
-
333
340
  ransacker :title do
334
341
  Arel.sql(%{("decidim_proposals_proposals"."title")::text})
335
342
  end
@@ -339,7 +346,7 @@ module Decidim
339
346
  end
340
347
 
341
348
  ransacker :is_emendation do |_parent|
342
- query = <<-SQL
349
+ query = <<-SQL.squish
343
350
  (
344
351
  SELECT EXISTS (
345
352
  SELECT 1 FROM decidim_amendments
@@ -367,6 +374,7 @@ module Decidim
367
374
  # Checks whether the proposal is inside the time window to be editable or not once published.
368
375
  def within_edit_time_limit?
369
376
  return true if draft?
377
+ return true if component.settings.proposal_edit_time == "infinite"
370
378
 
371
379
  limit = updated_at + component.settings.proposal_edit_before_minutes.minutes
372
380
  Time.current < limit
@@ -57,9 +57,9 @@ module Decidim
57
57
  # Only admin users can publish many answers at once
58
58
  toggle_allow(user.admin?) if permission_action.subject == :proposals && permission_action.action == :publish_answers
59
59
 
60
- if permission_action.subject == :participatory_texts && participatory_texts_are_enabled?
60
+ if permission_action.subject == :participatory_texts && participatory_texts_are_enabled? && permission_action.action == :manage
61
61
  # Every user allowed by the space can manage (import, update and publish) participatory texts to proposals
62
- allow! if permission_action.action == :manage
62
+ allow!
63
63
  end
64
64
 
65
65
  permission_action
@@ -10,9 +10,10 @@ module Decidim
10
10
  return Decidim::Proposals::Admin::Permissions.new(user, permission_action, context).permissions if permission_action.scope == :admin
11
11
  return permission_action if permission_action.scope != :public
12
12
 
13
- if permission_action.subject == :proposal
13
+ case permission_action.subject
14
+ when :proposal
14
15
  apply_proposal_permissions(permission_action)
15
- elsif permission_action.subject == :collaborative_draft
16
+ when :collaborative_draft
16
17
  apply_collaborative_draft_permissions(permission_action)
17
18
  else
18
19
  permission_action
@@ -100,13 +100,13 @@ module Decidim
100
100
  private
101
101
 
102
102
  def sanitize_unordered_lists(text)
103
- text.gsub(%r{(?=.*<\/ul>)(?!.*?<li>.*?<\/ol>.*?<\/ul>)<li>}) { |li| li + "• " }
103
+ text.gsub(%r{(?=.*</ul>)(?!.*?<li>.*?</ol>.*?</ul>)<li>}) { |li| "#{li}• " }
104
104
  end
105
105
 
106
106
  def sanitize_ordered_lists(text)
107
107
  i = 0
108
108
 
109
- text.gsub(%r{(?=.*<\/ol>)(?!.*?<li>.*?<\/ul>.*?<\/ol>)<li>}) do |li|
109
+ text.gsub(%r{(?=.*</ol>)(?!.*?<li>.*?</ul>.*?</ol>)<li>}) do |li|
110
110
  i += 1
111
111
 
112
112
  li + "#{i}. "
@@ -114,11 +114,11 @@ module Decidim
114
114
  end
115
115
 
116
116
  def add_line_feeds_to_paragraphs(text)
117
- text.gsub("</p>") { |p| p + "\n\n" }
117
+ text.gsub("</p>") { |p| "#{p}\n\n" }
118
118
  end
119
119
 
120
120
  def add_line_feeds_to_list_items(text)
121
- text.gsub("</li>") { |li| li + "\n" }
121
+ text.gsub("</li>") { |li| "#{li}\n" }
122
122
  end
123
123
 
124
124
  # Adds line feeds after the paragraph and list item closing tags.
@@ -17,8 +17,8 @@ module Decidim
17
17
  cumulative_users |= retrieve_drafts_followers.pluck(:decidim_user_id)
18
18
 
19
19
  quantity_users = []
20
- quantity_users |= retrieve_proposals_followers(true).pluck(:decidim_user_id)
21
- quantity_users |= retrieve_drafts_followers(true).pluck(:decidim_user_id)
20
+ quantity_users |= retrieve_proposals_followers(from_start: true).pluck(:decidim_user_id)
21
+ quantity_users |= retrieve_drafts_followers(from_start: true).pluck(:decidim_user_id)
22
22
 
23
23
  {
24
24
  cumulative_users: cumulative_users.uniq,
@@ -28,7 +28,7 @@ module Decidim
28
28
 
29
29
  private
30
30
 
31
- def retrieve_proposals_followers(from_start = false)
31
+ def retrieve_proposals_followers(from_start: false)
32
32
  @proposals_followers ||= Decidim::Follow.where(followable: retrieve_proposals).joins(:user)
33
33
  .where("decidim_follows.created_at <= ?", end_time)
34
34
 
@@ -37,7 +37,7 @@ module Decidim
37
37
  @proposals_followers
38
38
  end
39
39
 
40
- def retrieve_drafts_followers(from_start = false)
40
+ def retrieve_drafts_followers(from_start: false)
41
41
  @drafts_followers ||= Decidim::Follow.where(followable: retrieve_collaborative_drafts).joins(:user)
42
42
  .where("decidim_follows.created_at <= ?", end_time)
43
43
  return @drafts_followers.where("decidim_follows.created_at >= ?", start_time) if from_start
@@ -19,9 +19,9 @@ module Decidim
19
19
  cumulative_users |= retrieve_proposals.pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguosity must be called this way
20
20
 
21
21
  quantity_users = []
22
- quantity_users |= retrieve_votes(true).pluck(:decidim_author_id)
23
- quantity_users |= retrieve_endorsements(true).pluck(:decidim_author_id)
24
- quantity_users |= retrieve_proposals(true).pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguosity must be called this way
22
+ quantity_users |= retrieve_votes(from_start: true).pluck(:decidim_author_id)
23
+ quantity_users |= retrieve_endorsements(from_start: true).pluck(:decidim_author_id)
24
+ quantity_users |= retrieve_proposals(from_start: true).pluck("decidim_coauthorships.decidim_author_id") # To avoid ambiguosity must be called this way
25
25
 
26
26
  {
27
27
  cumulative_users: cumulative_users.uniq,
@@ -31,7 +31,7 @@ module Decidim
31
31
 
32
32
  private
33
33
 
34
- def retrieve_proposals(from_start = false)
34
+ def retrieve_proposals(from_start: false)
35
35
  @proposals ||= Decidim::Proposals::Proposal.where(component: @resource).joins(:coauthorships)
36
36
  .includes(:votes, :endorsements)
37
37
  .where(decidim_coauthorships: {
@@ -49,7 +49,7 @@ module Decidim
49
49
  @proposals
50
50
  end
51
51
 
52
- def retrieve_votes(from_start = false)
52
+ def retrieve_votes(from_start: false)
53
53
  @votes ||= Decidim::Proposals::ProposalVote.joins(:proposal).where(proposal: retrieve_proposals).joins(:author)
54
54
  .where("decidim_proposals_proposal_votes.created_at <= ?", end_time)
55
55
 
@@ -58,7 +58,7 @@ module Decidim
58
58
  @votes
59
59
  end
60
60
 
61
- def retrieve_endorsements(from_start = false)
61
+ def retrieve_endorsements(from_start: false)
62
62
  @endorsements ||= Decidim::Endorsement.joins("INNER JOIN decidim_proposals_proposals proposals ON resource_id = proposals.id")
63
63
  .where(resource: retrieve_proposals)
64
64
  .where("decidim_endorsements.created_at <= ?", end_time)
@@ -21,7 +21,7 @@ module Decidim
21
21
  # translated.
22
22
  def search_search_text
23
23
  query
24
- .where("title::text ILIKE ?", "%#{search_text}%")
24
+ .where("title ILIKE ?", "%#{search_text}%")
25
25
  .or(query.where("body ILIKE ?", "%#{search_text}%"))
26
26
  end
27
27
 
@@ -42,15 +42,7 @@ module Decidim
42
42
  # Returns and Array of two Strings.
43
43
  def parse_values(attribute, values)
44
44
  values = [amended_previous_value(attribute), values[1]] if proposal&.emendation?
45
- if attribute == :body
46
- values = values.map do |value|
47
- if value.is_a?(Hash)
48
- value.values.map { |subvalue| normalize_line_endings(subvalue) }
49
- else
50
- normalize_line_endings(value)
51
- end
52
- end
53
- end
45
+ values = values.map { |value| normalize_line_endings(value) } if attribute == :body
54
46
  values
55
47
  end
56
48
 
@@ -66,8 +58,12 @@ module Decidim
66
58
  end
67
59
 
68
60
  # Returns a String with the newline escape sequences normalized.
69
- def normalize_line_endings(string)
70
- Decidim::ContentParsers::NewlineParser.new(string, context: {}).rewrite
61
+ def normalize_line_endings(value)
62
+ if value.is_a?(Hash)
63
+ value.values.map { |subvalue| normalize_line_endings(subvalue) }
64
+ else
65
+ Decidim::ContentParsers::NewlineParser.new(value, context: {}).rewrite
66
+ end
71
67
  end
72
68
 
73
69
  def proposal
@@ -68,10 +68,9 @@ module Decidim
68
68
  "answered_at",
69
69
  "decidim_component_id",
70
70
  "reference",
71
- "comments_count",
71
+ "proposal_votes_count",
72
72
  "endorsements_count",
73
- "proposal_notes_count",
74
- "proposal_votes_count"
73
+ "proposal_notes_count"
75
74
  ).merge(
76
75
  "category" => original_proposal.category
77
76
  ).merge(
@@ -5,12 +5,19 @@
5
5
  <% if component_settings.participatory_texts_enabled? %>
6
6
  <%= link_to t("actions.participatory_texts", scope: "decidim.proposals"), participatory_texts_path, id: "participatory_texts", class: "button tiny button--simple" %>
7
7
  <% end %>
8
- <%= link_to t("actions.import", scope: "decidim.proposals", name: t("models.proposal.name", scope: "decidim.proposals.admin")), new_proposals_import_path, class: "button tiny button--simple" if allowed_to? :import, :proposals %>
9
8
 
10
9
  <% if allowed_to? :export, :proposals %>
11
10
  <%= export_dropdown %>
12
11
  <% end %>
13
12
 
13
+ <% if allowed_to? :import, :proposals %>
14
+ <%= import_dropdown do %>
15
+ <% content_tag :li do %>
16
+ <% link_to t("actions.import", scope: "decidim.proposals", name: t("models.proposal.name", scope: "decidim.proposals.admin")), new_proposals_import_path %>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
20
+
14
21
  <% if allowed_to? :create, :proposal %>
15
22
  <%= link_to t("actions.new", scope: "decidim.proposals"), new_proposal_path, class: "button tiny button--simple" %>
16
23
  <% end %>
@@ -16,9 +16,11 @@
16
16
  <%= translated_attribute proposal.category.name %>
17
17
  <% end %>
18
18
  </td>
19
+
19
20
  <%= td_resource_scope_for(proposal.scope) %>
21
+
20
22
  <td>
21
- <strong class="<%= proposal_state_css_class proposal.state %>">
23
+ <strong class="<%= proposal_state_css_class proposal %>">
22
24
  <%= t("decidim/amendment", scope: "activerecord.models", count: 1) if proposal.emendation? %>
23
25
  <%= proposal_complete_state proposal %>
24
26
  </strong>
@@ -61,6 +63,8 @@
61
63
  <td class="table-list__actions">
62
64
  <% if allowed_to? :edit, :proposal, proposal: proposal %>
63
65
  <%= icon_link_to "pencil", edit_proposal_path(proposal), t("actions.edit_proposal", scope: "decidim.proposals"), class: "action-icon--edit-proposal" %>
66
+ <% else %>
67
+ <span class="action-space icon"></span>
64
68
  <% end %>
65
69
 
66
70
  <%= icon_with_link_to_proposal(proposal) %>
@@ -2,7 +2,7 @@
2
2
  <% if @form.origin_components.any? %>
3
3
  <div class="card">
4
4
  <div class="card-divider">
5
- <h2 class="card-title"><%= title %></h2>
5
+ <h2 class="card-title"><%= t(".title") %></h2>
6
6
  </div>
7
7
 
8
8
  <div class="card-section">
@@ -2,17 +2,12 @@
2
2
  <div class="m-bottom">
3
3
  <%= link_to :back do %>
4
4
  <%= icon "chevron-left", class: "icon--small", role: "img", "aria-hidden": true %>
5
- <%= wizard_aside_back_text("collaborative_draft") %>
5
+ <%= t("back_from_collaborative_draft", scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe %>
6
6
  <% end %>
7
7
  </div>
8
8
  <div class="section">
9
9
  <p>
10
- <%= wizard_aside_info_text %>
10
+ <%= t("info", scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe %>
11
11
  </p>
12
12
  </div>
13
- <div class="show-for-large">
14
- <div><%= proposal_wizard_steps_title %></div>
15
- <div><%= proposal_wizard_current_step_of(@step) %></div>
16
- <%= proposal_wizard_stepper(@step) %>
17
- </div>
18
13
  </div>
@@ -0,0 +1,14 @@
1
+ <% if translated_attribute(component_settings.new_proposal_help_text).present? %>
2
+ <%= cell("decidim/announcement", component_settings.new_proposal_help_text) %>
3
+ <% end %>
4
+
5
+ <% if proposal_wizard_step_help_text?(@step) %>
6
+ <div class="proposal_wizard_help_text">
7
+ <% callout_step_help_text_class ||= nil %>
8
+ <%= cell("decidim/announcement", component_settings.try("proposal_wizard_#{@step}_help_text"), callout_class: callout_step_help_text_class) %>
9
+ </div>
10
+ <% end %>
11
+
12
+ <h2 class="section-heading">
13
+ <%= t(".title") %>
14
+ </h2>
@@ -13,9 +13,7 @@
13
13
  <div class="row">
14
14
  <div class="columns large-6 medium-centered">
15
15
  <div class="card">
16
- <% if translated_attribute(component_settings.new_proposal_help_text).present? %>
17
- <%= render partial: "decidim/shared/announcement", locals: { announcement: component_settings.new_proposal_help_text } %>
18
- <% end %>
16
+ <%= cell("decidim/announcement", component_settings.new_proposal_help_text) %>
19
17
 
20
18
  <div class="card__content">
21
19
  <%= decidim_form_for(@form) do |form| %>
@@ -1,26 +1,18 @@
1
- <% add_decidim_page_title(proposal_wizard_step_title(action_name)) %>
1
+ <% add_decidim_page_title(t("decidim.proposals.collaborative_drafts.wizard_header.title")) %>
2
2
 
3
3
  <div class="row">
4
4
  <%= render partial: "wizard_aside" %>
5
5
 
6
6
  <div class="columns large-6">
7
- <%= render partial: "decidim/proposals/proposals/wizard_header" %>
7
+ <%= render partial: "wizard_header" %>
8
8
 
9
9
  <div class="card">
10
10
  <div class="card__content">
11
- <%= decidim_form_for(@form, url: compare_collaborative_drafts_path, method: :get) do |form| %>
12
- <%= form_required_explanation %>
13
-
14
- <div class="field">
15
- <%= form.text_field :title %>
16
- </div>
17
-
18
- <div class="field">
19
- <%= form.text_area :body, rows: 10 %>
20
- </div>
11
+ <%= decidim_form_for(@form) do |form| %>
12
+ <%= render partial: "edit_form_fields", locals: { form: form } %>
21
13
 
22
14
  <div class="actions">
23
- <%= form.submit t("decidim.proposals.collaborative_drafts.new.send"), class: "button expanded mt-s mb-none", data: { disable: true } %>
15
+ <%= form.submit t(".send"), class: "button expanded mt-s mb-none", data: { disable: true } %>
24
16
  </div>
25
17
  <% end %>
26
18
  </div>
@@ -125,10 +125,4 @@
125
125
  <%= attachments_for @collaborative_draft %>
126
126
  <%= comments_for @collaborative_draft %>
127
127
 
128
- <%=
129
- render partial: "decidim/shared/flag_modal", locals: {
130
- reportable: @collaborative_draft,
131
- form: @report_form,
132
- url: decidim.report_path(sgid: @collaborative_draft.to_sgid.to_s)
133
- }
134
- %>
128
+ <%= cell("decidim/flag_modal", @collaborative_draft) %>
@@ -0,0 +1,3 @@
1
+ <div class="column dynamic-map-instructions">
2
+ <%== t(".instructions") %>
3
+ </div>
@@ -25,7 +25,7 @@
25
25
  <div class="field">
26
26
  <%= form.label :suggested_hashtags, nil, for: nil %>
27
27
  <div class="checkboxes hashtags">
28
- <%= form.collection_check_boxes :suggested_hashtags, @form.component_suggested_hashtags.map {|hashtag| [hashtag.downcase, "##{hashtag}"]}, :first, :last do |option|
28
+ <%= form.collection_check_boxes :suggested_hashtags, @form.component_suggested_hashtags.map { |hashtag| [hashtag.downcase, "##{hashtag}"] }, :first, :last do |option|
29
29
  option.label { option.check_box(checked: @form.suggested_hashtag_checked?(option.value)) + option.text }
30
30
  end %>
31
31
  </div>
@@ -38,7 +38,7 @@
38
38
  </div>
39
39
 
40
40
  <div class="field" id="address_input">
41
- <%= form.geocoding_field :address %>
41
+ <%= form.geocoding_field :address, placeholder: t("decidim.proposals.proposals.placeholder.address") %>
42
42
  </div>
43
43
  <% end %>
44
44