decidim-proposals 0.27.10 → 0.28.0.rc4

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.
Files changed (281) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/proposals/collaborative_draft_cell.rb +1 -1
  3. data/app/cells/decidim/proposals/collaborative_draft_l_cell.rb +16 -0
  4. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal/show.erb +4 -12
  5. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +0 -29
  6. data/app/cells/decidim/proposals/collaborative_draft_metadata_cell.rb +30 -0
  7. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +2 -8
  8. data/app/cells/decidim/proposals/cost_report/show.erb +5 -34
  9. data/app/cells/decidim/proposals/cost_report_cell.rb +0 -13
  10. data/app/cells/decidim/proposals/highlighted_proposals_for_component/show.erb +29 -17
  11. data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +34 -8
  12. data/app/cells/decidim/proposals/irreversible_action_modal/show.erb +9 -17
  13. data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +7 -9
  14. data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +21 -31
  15. data/app/cells/decidim/proposals/participatory_text_proposal/show.erb +5 -9
  16. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +0 -9
  17. data/app/cells/decidim/proposals/proposal_activity_cell.rb +1 -12
  18. data/app/cells/decidim/proposals/proposal_cell.rb +6 -1
  19. data/app/cells/decidim/proposals/proposal_l_cell.rb +47 -0
  20. data/app/cells/decidim/proposals/proposal_link_to_collaborative_draft_cell.rb +6 -4
  21. data/app/cells/decidim/proposals/proposal_link_to_rejected_emendation_cell.rb +9 -7
  22. data/app/cells/decidim/proposals/proposal_linked_resources/show.erb +3 -8
  23. data/app/cells/decidim/proposals/proposal_metadata_cell.rb +61 -0
  24. data/app/cells/decidim/proposals/proposal_s_cell.rb +21 -0
  25. data/app/cells/decidim/proposals/proposals_picker/show.erb +13 -13
  26. data/app/cells/decidim/proposals/proposals_picker_cell.rb +15 -38
  27. data/app/commands/decidim/proposals/accept_access_to_collaborative_draft.rb +1 -1
  28. data/app/commands/decidim/proposals/admin/answer_proposal.rb +1 -1
  29. data/app/commands/decidim/proposals/admin/assign_proposals_to_valuator.rb +3 -3
  30. data/app/commands/decidim/proposals/admin/create_proposal.rb +2 -2
  31. data/app/commands/decidim/proposals/admin/create_proposal_note.rb +4 -4
  32. data/app/commands/decidim/proposals/admin/discard_participatory_text.rb +1 -1
  33. data/app/commands/decidim/proposals/admin/import_participatory_text.rb +1 -1
  34. data/app/commands/decidim/proposals/admin/import_proposals.rb +2 -13
  35. data/app/commands/decidim/proposals/admin/merge_proposals.rb +1 -1
  36. data/app/commands/decidim/proposals/admin/notify_proposal_answer.rb +3 -3
  37. data/app/commands/decidim/proposals/admin/publish_answers.rb +1 -1
  38. data/app/commands/decidim/proposals/admin/publish_participatory_text.rb +2 -2
  39. data/app/commands/decidim/proposals/admin/split_proposals.rb +1 -1
  40. data/app/commands/decidim/proposals/admin/unassign_proposals_from_valuator.rb +2 -2
  41. data/app/commands/decidim/proposals/admin/update_participatory_text.rb +1 -1
  42. data/app/commands/decidim/proposals/admin/update_proposal.rb +5 -1
  43. data/app/commands/decidim/proposals/admin/update_proposal_scope.rb +1 -1
  44. data/app/commands/decidim/proposals/create_collaborative_draft.rb +13 -3
  45. data/app/commands/decidim/proposals/create_proposal.rb +14 -5
  46. data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
  47. data/app/commands/decidim/proposals/publish_proposal.rb +1 -1
  48. data/app/commands/decidim/proposals/reject_access_to_collaborative_draft.rb +1 -1
  49. data/app/commands/decidim/proposals/request_access_to_collaborative_draft.rb +1 -1
  50. data/app/commands/decidim/proposals/unvote_proposal.rb +2 -2
  51. data/app/commands/decidim/proposals/update_collaborative_draft.rb +12 -2
  52. data/app/commands/decidim/proposals/update_proposal.rb +16 -14
  53. data/app/commands/decidim/proposals/vote_proposal.rb +2 -2
  54. data/app/controllers/concerns/decidim/proposals/admin/filterable.rb +4 -13
  55. data/app/controllers/decidim/proposals/admin/proposal_answers_controller.rb +2 -2
  56. data/app/controllers/decidim/proposals/admin/proposal_notes_controller.rb +1 -1
  57. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +2 -2
  58. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +3 -9
  59. data/app/controllers/decidim/proposals/proposal_votes_controller.rb +3 -3
  60. data/app/controllers/decidim/proposals/proposals_controller.rb +42 -12
  61. data/app/events/decidim/proposals/accepted_proposal_event.rb +1 -1
  62. data/app/events/decidim/proposals/admin/proposal_note_created_event.rb +1 -1
  63. data/app/events/decidim/proposals/admin/update_proposal_category_event.rb +1 -1
  64. data/app/events/decidim/proposals/admin/update_proposal_scope_event.rb +1 -1
  65. data/app/events/decidim/proposals/collaborative_draft_access_accepted_event.rb +1 -1
  66. data/app/events/decidim/proposals/collaborative_draft_access_rejected_event.rb +1 -1
  67. data/app/events/decidim/proposals/collaborative_draft_access_request_event.rb +1 -1
  68. data/app/events/decidim/proposals/collaborative_draft_access_requested_event.rb +1 -1
  69. data/app/events/decidim/proposals/collaborative_draft_access_requester_accepted_event.rb +1 -1
  70. data/app/events/decidim/proposals/collaborative_draft_access_requester_rejected_event.rb +1 -1
  71. data/app/events/decidim/proposals/collaborative_draft_withdrawn_event.rb +1 -1
  72. data/app/events/decidim/proposals/evaluating_proposal_event.rb +1 -1
  73. data/app/events/decidim/proposals/proposal_endorsed_event.rb +1 -1
  74. data/app/events/decidim/proposals/proposal_mentioned_event.rb +1 -1
  75. data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
  76. data/app/events/decidim/proposals/rejected_proposal_event.rb +1 -1
  77. data/app/forms/decidim/proposals/admin/import_participatory_text_form.rb +1 -1
  78. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +2 -2
  79. data/app/forms/decidim/proposals/admin/proposal_form.rb +1 -1
  80. data/app/forms/decidim/proposals/admin/proposals_fork_form.rb +1 -1
  81. data/app/forms/decidim/proposals/admin/valuation_assignment_form.rb +1 -1
  82. data/app/forms/decidim/proposals/proposal_form.rb +9 -27
  83. data/app/helpers/decidim/proposals/admin/proposal_bulk_actions_helper.rb +1 -1
  84. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +13 -13
  85. data/app/helpers/decidim/proposals/application_helper.rb +80 -28
  86. data/app/helpers/decidim/proposals/collaborative_draft_helper.rb +44 -4
  87. data/app/helpers/decidim/proposals/map_helper.rb +3 -4
  88. data/app/helpers/decidim/proposals/participatory_texts_helper.rb +1 -9
  89. data/app/helpers/decidim/proposals/proposal_cells_helper.rb +1 -1
  90. data/app/helpers/decidim/proposals/proposal_votes_helper.rb +2 -24
  91. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -81
  92. data/app/helpers/decidim/proposals/proposals_helper.rb +0 -12
  93. data/app/jobs/decidim/proposals/hide_all_created_by_author_job.rb +20 -0
  94. data/app/jobs/decidim/proposals/notify_proposals_mentioned_job.rb +1 -1
  95. data/app/jobs/decidim/proposals/settings_change_job.rb +2 -2
  96. data/app/models/decidim/proposals/collaborative_draft.rb +4 -16
  97. data/app/models/decidim/proposals/proposal.rb +33 -16
  98. data/app/models/decidim/proposals/proposal_vote.rb +3 -3
  99. data/app/models/decidim/proposals/valuation_assignment.rb +1 -2
  100. data/app/packs/documents/decidim/proposals/participatory_texts/participatory_text.md +9 -4
  101. data/app/packs/entrypoints/decidim_proposals.js +4 -0
  102. data/app/packs/entrypoints/decidim_proposals_admin.js +0 -1
  103. data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_accepted_proposals.svg +68 -1
  104. data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_proposal_votes.svg +34 -1
  105. data/app/packs/images/decidim/gamification/badges/decidim_gamification_badges_proposals.svg +64 -1
  106. data/app/packs/src/decidim/proposals/add_proposal.js +25 -39
  107. data/app/packs/src/decidim/proposals/admin/proposals.js +0 -7
  108. data/app/packs/src/decidim/proposals/choose_proposals.js +20 -0
  109. data/app/packs/stylesheets/decidim/proposals/proposals.scss +97 -0
  110. data/app/permissions/decidim/proposals/admin/permissions.rb +3 -3
  111. data/app/permissions/decidim/proposals/permissions.rb +1 -10
  112. data/app/presenters/decidim/proposals/admin_log/proposal_note_presenter.rb +2 -2
  113. data/app/presenters/decidim/proposals/admin_log/proposal_presenter.rb +7 -3
  114. data/app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb +2 -2
  115. data/app/presenters/decidim/proposals/admin_log/value_types/proposal_title_body_presenter.rb +3 -1
  116. data/app/presenters/decidim/proposals/log/resource_presenter.rb +22 -0
  117. data/app/presenters/decidim/proposals/log/valuation_assignment_presenter.rb +1 -1
  118. data/app/presenters/decidim/proposals/proposal_presenter.rb +6 -2
  119. data/app/services/decidim/proposals/diff_renderer.rb +3 -3
  120. data/app/services/decidim/proposals/proposal_builder.rb +6 -6
  121. data/app/views/decidim/proposals/admin/participatory_texts/_article-preview.html.erb +2 -4
  122. data/app/views/decidim/proposals/admin/participatory_texts/_bulk-actions.html.erb +2 -2
  123. data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +58 -46
  124. data/app/views/decidim/proposals/admin/participatory_texts/new_import.html.erb +31 -33
  125. data/app/views/decidim/proposals/admin/proposal_answers/_form.html.erb +17 -11
  126. data/app/views/decidim/proposals/admin/proposal_notes/_form.html.erb +5 -6
  127. data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +28 -36
  128. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +27 -30
  129. data/app/views/decidim/proposals/admin/proposals/_documents.html.erb +13 -0
  130. data/app/views/decidim/proposals/admin/proposals/_endorsers.html.erb +25 -0
  131. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +70 -90
  132. data/app/views/decidim/proposals/admin/proposals/_meetings.html.erb +13 -0
  133. data/app/views/decidim/proposals/admin/proposals/_photos.html.erb +13 -0
  134. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +31 -25
  135. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_assign_to_valuator.html.erb +3 -3
  136. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_dropdown.html.erb +3 -2
  137. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_merge.html.erb +4 -4
  138. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_publish_answers.html.erb +3 -3
  139. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_recategorize.html.erb +3 -3
  140. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_scope-change.html.erb +4 -8
  141. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_split.html.erb +3 -3
  142. data/app/views/decidim/proposals/admin/proposals/bulk_actions/_unassign_from_valuator.html.erb +3 -3
  143. data/app/views/decidim/proposals/admin/proposals/edit.html.erb +17 -7
  144. data/app/views/decidim/proposals/admin/proposals/index.html.erb +50 -63
  145. data/app/views/decidim/proposals/admin/proposals/new.html.erb +16 -6
  146. data/app/views/decidim/proposals/admin/proposals/publish_answers.js.erb +2 -2
  147. data/app/views/decidim/proposals/admin/proposals/show.html.erb +204 -162
  148. data/app/views/decidim/proposals/admin/proposals/update_attribute.js.erb +5 -6
  149. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +48 -34
  150. data/app/views/decidim/proposals/collaborative_drafts/_accept_request_access_form.html.erb +1 -1
  151. data/app/views/decidim/proposals/collaborative_drafts/_actions.html.erb +7 -0
  152. data/app/views/decidim/proposals/collaborative_drafts/_collaborative_draft_aside.html.erb +53 -0
  153. data/app/views/decidim/proposals/collaborative_drafts/_collaborative_drafts.html.erb +12 -13
  154. data/app/views/decidim/proposals/collaborative_drafts/_collaborator_requests.html.erb +8 -12
  155. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +26 -54
  156. data/app/views/decidim/proposals/collaborative_drafts/_reject_request_access_form.html.erb +1 -3
  157. data/app/views/decidim/proposals/collaborative_drafts/_request_access_form.html.erb +1 -1
  158. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +23 -25
  159. data/app/views/decidim/proposals/collaborative_drafts/index.html.erb +30 -22
  160. data/app/views/decidim/proposals/collaborative_drafts/index.js.erb +0 -5
  161. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +22 -18
  162. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +39 -109
  163. data/app/views/decidim/proposals/proposal_votes/update_buttons_and_counters.js.erb +2 -2
  164. data/app/views/decidim/proposals/proposals/_actions.html.erb +13 -0
  165. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +31 -70
  166. data/app/views/decidim/proposals/proposals/_linked_proposals.html.erb +3 -35
  167. data/app/views/decidim/proposals/proposals/_proposal_aside.html.erb +40 -0
  168. data/app/views/decidim/proposals/proposals/_proposals.html.erb +18 -39
  169. data/app/views/decidim/proposals/proposals/_proposals_picker.html.erb +5 -0
  170. data/app/views/decidim/proposals/proposals/_remaining_votes_count.html.erb +3 -3
  171. data/app/views/decidim/proposals/proposals/_vote_button.html.erb +16 -17
  172. data/app/views/decidim/proposals/proposals/_votes_count.html.erb +3 -6
  173. data/app/views/decidim/proposals/proposals/_voting_rules.html.erb +28 -41
  174. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +19 -25
  175. data/app/views/decidim/proposals/proposals/compare.html.erb +17 -16
  176. data/app/views/decidim/proposals/proposals/complete.html.erb +26 -21
  177. data/app/views/decidim/proposals/proposals/edit.html.erb +32 -27
  178. data/app/views/decidim/proposals/proposals/edit_draft.html.erb +21 -19
  179. data/app/views/decidim/proposals/proposals/index.html.erb +56 -47
  180. data/app/views/decidim/proposals/proposals/index.js.erb +0 -5
  181. data/app/views/decidim/proposals/proposals/new.html.erb +30 -35
  182. data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_vote_button.html.erb +5 -5
  183. data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +15 -8
  184. data/app/views/decidim/proposals/proposals/participatory_texts/participatory_text.html.erb +32 -15
  185. data/app/views/decidim/proposals/proposals/preview.html.erb +37 -34
  186. data/app/views/decidim/proposals/proposals/show.html.erb +90 -108
  187. data/app/views/decidim/proposals/versions/show.html.erb +14 -6
  188. data/config/assets.rb +0 -1
  189. data/config/brakeman.ignore +31 -56
  190. data/config/locales/ar.yml +23 -158
  191. data/config/locales/bg.yml +1 -776
  192. data/config/locales/ca.yml +92 -150
  193. data/config/locales/cs.yml +75 -135
  194. data/config/locales/de.yml +83 -141
  195. data/config/locales/el.yml +58 -121
  196. data/config/locales/en.yml +76 -134
  197. data/config/locales/es-MX.yml +77 -135
  198. data/config/locales/es-PY.yml +76 -134
  199. data/config/locales/es.yml +84 -142
  200. data/config/locales/eu.yml +77 -135
  201. data/config/locales/fi-plain.yml +68 -126
  202. data/config/locales/fi.yml +76 -134
  203. data/config/locales/fr-CA.yml +73 -132
  204. data/config/locales/fr.yml +77 -136
  205. data/config/locales/ga-IE.yml +0 -45
  206. data/config/locales/gl.yml +12 -131
  207. data/config/locales/hu.yml +45 -149
  208. data/config/locales/id-ID.yml +9 -114
  209. data/config/locales/is-IS.yml +5 -60
  210. data/config/locales/it.yml +14 -146
  211. data/config/locales/ja.yml +78 -141
  212. data/config/locales/lb.yml +0 -5
  213. data/config/locales/lt.yml +65 -126
  214. data/config/locales/lv.yml +13 -144
  215. data/config/locales/nl.yml +16 -148
  216. data/config/locales/no.yml +11 -134
  217. data/config/locales/pl.yml +16 -239
  218. data/config/locales/pt-BR.yml +14 -199
  219. data/config/locales/pt.yml +11 -142
  220. data/config/locales/ro-RO.yml +12 -146
  221. data/config/locales/ru.yml +5 -70
  222. data/config/locales/sk.yml +19 -145
  223. data/config/locales/sr-CS.yml +0 -23
  224. data/config/locales/sv.yml +60 -195
  225. data/config/locales/tr-TR.yml +16 -150
  226. data/config/locales/uk.yml +5 -70
  227. data/config/locales/zh-CN.yml +9 -135
  228. data/config/locales/zh-TW.yml +35 -107
  229. data/db/migrate/20170307085300_migrate_proposal_reports_data_to_reports.rb +1 -1
  230. data/db/migrate/20230427105700_change_states_on_collaborative_drafts.rb +34 -0
  231. data/db/migrate/20230427105700_change_states_on_proposals.rb +34 -0
  232. data/lib/decidim/api/proposals_type.rb +2 -2
  233. data/lib/decidim/proposals/component.rb +11 -289
  234. data/lib/decidim/proposals/doc_to_markdown.rb +0 -4
  235. data/lib/decidim/proposals/engine.rb +43 -7
  236. data/lib/decidim/proposals/import/proposal_answer_creator.rb +1 -1
  237. data/lib/decidim/proposals/import/proposal_creator.rb +10 -10
  238. data/lib/decidim/proposals/markdown_to_proposals.rb +8 -2
  239. data/lib/decidim/proposals/proposal_serializer.rb +4 -56
  240. data/lib/decidim/proposals/seeds.rb +278 -0
  241. data/lib/decidim/proposals/test/factories.rb +106 -85
  242. data/lib/decidim/proposals/valuatable.rb +1 -2
  243. data/lib/decidim/proposals/version.rb +1 -1
  244. metadata +55 -66
  245. data/app/cells/decidim/proposals/collaborative_draft_m/footer.erb +0 -6
  246. data/app/cells/decidim/proposals/collaborative_draft_m/tags.erb +0 -1
  247. data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +0 -44
  248. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +0 -5
  249. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +0 -1
  250. data/app/cells/decidim/proposals/proposal_link_to_rejected_emendation/show.erb +0 -9
  251. data/app/cells/decidim/proposals/proposal_m/footer.erb +0 -26
  252. data/app/cells/decidim/proposals/proposal_m/tags.erb +0 -1
  253. data/app/cells/decidim/proposals/proposal_m_cell.rb +0 -151
  254. data/app/cells/decidim/proposals/proposal_tags/show.erb +0 -33
  255. data/app/cells/decidim/proposals/proposal_tags_cell.rb +0 -35
  256. data/app/cells/decidim/proposals/proposals_picker/proposals.erb +0 -12
  257. data/app/controllers/concerns/decidim/proposals/admin/picker.rb +0 -21
  258. data/app/controllers/decidim/proposals/widgets_controller.rb +0 -29
  259. data/app/helpers/decidim/proposals/admin/filterable_helper.rb +0 -17
  260. data/app/helpers/decidim/proposals/admin/proposals_picker_helper.rb +0 -30
  261. data/app/packs/src/decidim/proposals/admin/proposals_picker.js +0 -50
  262. data/app/packs/stylesheets/decidim/proposals/_proposals.scss +0 -1
  263. data/app/packs/stylesheets/decidim/proposals/proposals/_preview.scss +0 -3
  264. data/app/views/decidim/proposals/collaborative_drafts/_count.html.erb +0 -1
  265. data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +0 -32
  266. data/app/views/decidim/proposals/collaborative_drafts/_filters_small_view.html.erb +0 -18
  267. data/app/views/decidim/proposals/collaborative_drafts/_new_collaborative_draft_button.html.erb +0 -11
  268. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +0 -13
  269. data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +0 -14
  270. data/app/views/decidim/proposals/proposals/_count.html.erb +0 -1
  271. data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +0 -4
  272. data/app/views/decidim/proposals/proposals/_filters.html.erb +0 -48
  273. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +0 -18
  274. data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +0 -22
  275. data/app/views/decidim/proposals/proposals/_wizard_aside.html.erb +0 -20
  276. data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +0 -19
  277. data/app/views/decidim/proposals/versions/index.html.erb +0 -16
  278. data/config/locales/he-IL.yml +0 -1
  279. data/db/migrate/20240404202756_add_valuation_assignments_count_to_decidim_proposals_proposals.rb +0 -16
  280. data/decidim-proposals.gemspec +0 -40
  281. data/lib/decidim/proposals/test/capybara_proposals_picker.rb +0 -59
@@ -20,14 +20,14 @@ module Decidim
20
20
  # Executes the command. Broadcasts these events:
21
21
  #
22
22
  # - :ok when everything is valid, together with the collaborative_draft.
23
- # - :invalid if the form wasn't valid and we couldn't proceed.
23
+ # - :invalid if the form was not valid and we could not proceed.
24
24
  #
25
25
  # Returns nothing.
26
26
  def call
27
27
  return broadcast(:invalid) if form.invalid?
28
28
  return broadcast(:invalid) unless collaborative_draft.editable_by?(current_user)
29
29
 
30
- transaction do
30
+ with_events(with_transaction: true) do
31
31
  update_collaborative_draft
32
32
  end
33
33
 
@@ -38,6 +38,16 @@ module Decidim
38
38
 
39
39
  attr_reader :form, :collaborative_draft, :current_user
40
40
 
41
+ def event_arguments
42
+ {
43
+ resource: collaborative_draft,
44
+ extra: {
45
+ event_author: form.current_user,
46
+ locale:
47
+ }
48
+ }
49
+ end
50
+
41
51
  def update_collaborative_draft
42
52
  Decidim.traceability.update!(
43
53
  @collaborative_draft,
@@ -5,7 +5,6 @@ module Decidim
5
5
  # A command with all the business logic when a user updates a proposal.
6
6
  class UpdateProposal < Decidim::Command
7
7
  include ::Decidim::MultipleAttachmentsMethods
8
- include GalleryMethods
9
8
  include HashtagsMethods
10
9
 
11
10
  # Public: Initializes the command.
@@ -23,7 +22,7 @@ module Decidim
23
22
  # Executes the command. Broadcasts these events:
24
23
  #
25
24
  # - :ok when everything is valid, together with the proposal.
26
- # - :invalid if the form wasn't valid and we couldn't proceed.
25
+ # - :invalid if the form was not valid and we could not proceed.
27
26
  #
28
27
  # Returns nothing.
29
28
  def call
@@ -34,22 +33,15 @@ module Decidim
34
33
  return broadcast(:invalid) if attachments_invalid?
35
34
  end
36
35
 
37
- if process_gallery?
38
- build_gallery
39
- return broadcast(:invalid) if gallery_invalid?
40
- end
41
-
42
- transaction do
36
+ with_events(with_transaction: true) do
43
37
  if @proposal.draft?
44
38
  update_draft
45
39
  else
46
40
  update_proposal
47
41
  end
48
42
 
49
- photo_cleanup!
50
- document_cleanup!
43
+ document_cleanup!(include_all_attachments: true)
51
44
 
52
- create_gallery if process_gallery?
53
45
  create_attachments(first_weight: first_attachment_weight) if process_attachments?
54
46
  end
55
47
 
@@ -60,6 +52,16 @@ module Decidim
60
52
 
61
53
  attr_reader :form, :proposal, :current_user, :attachment
62
54
 
55
+ def event_arguments
56
+ {
57
+ resource: proposal,
58
+ extra: {
59
+ event_author: form.current_user,
60
+ locale:
61
+ }
62
+ }
63
+ end
64
+
63
65
  def invalid?
64
66
  form.invalid? || !proposal.editable_by?(current_user) || proposal_limit_reached?
65
67
  end
@@ -73,7 +75,7 @@ module Decidim
73
75
  PaperTrail.request(enabled: false) do
74
76
  @proposal.update(attributes)
75
77
  @proposal.coauthorships.clear
76
- @proposal.add_coauthor(current_user, user_group: user_group)
78
+ @proposal.add_coauthor(current_user, user_group:)
77
79
  end
78
80
  end
79
81
 
@@ -85,7 +87,7 @@ module Decidim
85
87
  visibility: "public-only"
86
88
  )
87
89
  @proposal.coauthorships.clear
88
- @proposal.add_coauthor(current_user, user_group: user_group)
90
+ @proposal.add_coauthor(current_user, user_group:)
89
91
  end
90
92
 
91
93
  def attributes
@@ -123,7 +125,7 @@ module Decidim
123
125
  end
124
126
 
125
127
  def user_group
126
- @user_group ||= Decidim::UserGroup.find_by(organization: organization, id: form.user_group_id)
128
+ @user_group ||= Decidim::UserGroup.find_by(organization:, id: form.user_group_id)
127
129
  end
128
130
 
129
131
  def organization
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid, together with the proposal vote.
19
- # - :invalid if the form wasn't valid and we couldn't proceed.
19
+ # - :invalid if the form was not valid and we could not proceed.
20
20
  #
21
21
  # Returns nothing.
22
22
  def call
@@ -62,7 +62,7 @@ module Decidim
62
62
  def user_votes
63
63
  @user_votes ||= ProposalVote.where(
64
64
  author: @current_user,
65
- proposal: Proposal.where(component: component)
65
+ proposal: Proposal.where(component:)
66
66
  )
67
67
  end
68
68
 
@@ -11,8 +11,6 @@ module Decidim
11
11
  included do
12
12
  include Decidim::Admin::Filterable
13
13
 
14
- helper Decidim::Proposals::Admin::FilterableHelper
15
-
16
14
  private
17
15
 
18
16
  # Comment about participatory_texts_enabled.
@@ -35,8 +33,8 @@ module Decidim
35
33
  def filters
36
34
  [
37
35
  :is_emendation_true,
36
+ :with_any_state,
38
37
  :state_eq,
39
- :state_null,
40
38
  :scope_id_eq,
41
39
  :category_id_eq,
42
40
  :valuator_role_ids_has
@@ -46,14 +44,15 @@ module Decidim
46
44
  def filters_with_values
47
45
  {
48
46
  is_emendation_true: %w(true false),
49
- state_eq: proposal_states,
47
+ state_eq: Proposal::STATES,
48
+ with_any_state: %w(state_published state_not_published),
50
49
  scope_id_eq: scope_ids_hash(scopes.top_level),
51
50
  category_id_eq: category_ids_hash(categories.first_class),
52
51
  valuator_role_ids_has: valuator_role_ids
53
52
  }
54
53
  end
55
54
 
56
- # Can't user `super` here, because it does not belong to a superclass
55
+ # Cannot user `super` here, because it does not belong to a superclass
57
56
  # but to a concern.
58
57
  def dynamically_translated_filters
59
58
  [:scope_id_eq, :category_id_eq, :valuator_role_ids_has]
@@ -67,14 +66,6 @@ module Decidim
67
66
  user_role = current_participatory_space.user_roles(:valuator).find_by(id: valuator_role_id)
68
67
  user_role&.user&.name
69
68
  end
70
-
71
- # An Array<Symbol> of possible values for `state_eq` filter.
72
- # Excludes the states that cannot be filtered with the ransack predicate.
73
- # A link to filter by "Not answered" will be added in:
74
- # Decidim::Proposals::Admin::FilterableHelper#extra_dropdown_submenu_options_items
75
- def proposal_states
76
- Proposal::POSSIBLE_STATES.without("not_answered")
77
- end
78
69
  end
79
70
  end
80
71
  end
@@ -13,12 +13,12 @@ module Decidim
13
13
  helper Decidim::Messaging::ConversationHelper
14
14
 
15
15
  def edit
16
- enforce_permission_to :create, :proposal_answer, proposal: proposal
16
+ enforce_permission_to(:create, :proposal_answer, proposal:)
17
17
  @form = form(Admin::ProposalAnswerForm).from_model(proposal)
18
18
  end
19
19
 
20
20
  def update
21
- enforce_permission_to :create, :proposal_answer, proposal: proposal
21
+ enforce_permission_to(:create, :proposal_answer, proposal:)
22
22
  @notes_form = form(ProposalNoteForm).instance
23
23
  @answer_form = form(Admin::ProposalAnswerForm).from_params(params)
24
24
 
@@ -8,7 +8,7 @@ module Decidim
8
8
  helper_method :proposal
9
9
 
10
10
  def create
11
- enforce_permission_to :create, :proposal_note, proposal: proposal
11
+ enforce_permission_to(:create, :proposal_note, proposal:)
12
12
  @form = form(ProposalNoteForm).from_params(params)
13
13
 
14
14
  CreateProposalNote.call(@form, proposal) do
@@ -122,12 +122,12 @@ module Decidim
122
122
  end
123
123
 
124
124
  def edit
125
- enforce_permission_to :edit, :proposal, proposal: proposal
125
+ enforce_permission_to(:edit, :proposal, proposal:)
126
126
  @form = form(Admin::ProposalForm).from_model(proposal)
127
127
  end
128
128
 
129
129
  def update
130
- enforce_permission_to :edit, :proposal, proposal: proposal
130
+ enforce_permission_to(:edit, :proposal, proposal:)
131
131
 
132
132
  @form = form(Admin::ProposalForm).from_params(params)
133
133
 
@@ -4,12 +4,12 @@ module Decidim
4
4
  module Proposals
5
5
  # Exposes Collaborative Drafts resource so users can view and create them.
6
6
  class CollaborativeDraftsController < Decidim::Proposals::ApplicationController
7
- helper Decidim::WidgetUrlsHelper
8
7
  helper ProposalWizardHelper
9
8
  helper TooltipHelper
10
9
  helper UserGroupHelper
11
10
 
12
11
  include Decidim::ApplicationHelper
12
+ include Decidim::IconHelper
13
13
  include FormFactory
14
14
  include Flaggable
15
15
  include FilterResource
@@ -144,18 +144,12 @@ module Decidim
144
144
  def default_filter_params
145
145
  {
146
146
  search_text_cont: "",
147
- with_any_category: default_filter_category_params,
147
+ with_any_category: nil,
148
148
  with_any_state: %w(open),
149
- with_any_scope: default_filter_scope_params,
149
+ with_any_scope: nil,
150
150
  related_to: ""
151
151
  }
152
152
  end
153
-
154
- def default_filter_category_params
155
- return unless current_component.participatory_space.categories.any?
156
-
157
- ["without"] + current_component.participatory_space.categories.map { |category| category.id.to_s }
158
- end
159
153
  end
160
154
  end
161
155
  end
@@ -12,7 +12,7 @@ module Decidim
12
12
  before_action :authenticate_user!
13
13
 
14
14
  def create
15
- enforce_permission_to :vote, :proposal, proposal: proposal
15
+ enforce_permission_to(:vote, :proposal, proposal:)
16
16
  @from_proposals_list = params[:from_proposals_list] == "true"
17
17
 
18
18
  VoteProposal.call(proposal, current_user) do
@@ -24,7 +24,7 @@ module Decidim
24
24
  proposal: Proposal.where(component: current_component)
25
25
  ).map(&:proposal)
26
26
 
27
- expose(proposals: proposals)
27
+ expose(proposals:)
28
28
  render :update_buttons_and_counters
29
29
  end
30
30
 
@@ -35,7 +35,7 @@ module Decidim
35
35
  end
36
36
 
37
37
  def destroy
38
- enforce_permission_to :unvote, :proposal, proposal: proposal
38
+ enforce_permission_to(:unvote, :proposal, proposal:)
39
39
  @from_proposals_list = params[:from_proposals_list] == "true"
40
40
 
41
41
  UnvoteProposal.call(proposal, current_user) do
@@ -4,7 +4,6 @@ module Decidim
4
4
  module Proposals
5
5
  # Exposes the proposal resource so users can view and create them.
6
6
  class ProposalsController < Decidim::Proposals::ApplicationController
7
- helper Decidim::WidgetUrlsHelper
8
7
  helper ProposalWizardHelper
9
8
  helper ParticipatoryTextsHelper
10
9
  helper UserGroupHelper
@@ -15,8 +14,9 @@ module Decidim
15
14
  include FilterResource
16
15
  include Decidim::Proposals::Orderable
17
16
  include Paginable
17
+ include Decidim::AttachmentsHelper
18
18
 
19
- helper_method :proposal_presenter, :form_presenter
19
+ helper_method :proposal_presenter, :form_presenter, :tab_panel_items
20
20
 
21
21
  before_action :authenticate_user!, only: [:new, :create, :complete]
22
22
  before_action :ensure_is_draft, only: [:compare, :complete, :preview, :publish, :edit_draft, :update_draft, :destroy_draft]
@@ -225,23 +225,16 @@ module Decidim
225
225
  def default_filter_params
226
226
  {
227
227
  search_text_cont: "",
228
- with_any_origin: default_filter_origin_params,
228
+ with_any_origin: nil,
229
229
  activity: "all",
230
- with_any_category: default_filter_category_params,
230
+ with_any_category: nil,
231
231
  with_any_state: %w(accepted evaluating state_not_published),
232
- with_any_scope: default_filter_scope_params,
232
+ with_any_scope: nil,
233
233
  related_to: "",
234
234
  type: "all"
235
235
  }
236
236
  end
237
237
 
238
- def default_filter_origin_params
239
- filter_origin_params = %w(participants meeting)
240
- filter_origin_params << "official" if component_settings.official_proposals_enabled
241
- filter_origin_params << "user_group" if current_organization.user_groups_enabled?
242
- filter_origin_params
243
- end
244
-
245
238
  def proposal_draft
246
239
  Proposal.from_all_author_identities(current_user).not_hidden.only_amendables
247
240
  .where(component: current_component).find_by(published_at: nil)
@@ -303,6 +296,43 @@ module Decidim
303
296
  def proposal_creation_params
304
297
  params[:proposal].merge(body_template: translated_proposal_body_template)
305
298
  end
299
+
300
+ def tab_panel_items
301
+ @tab_panel_items ||= [
302
+ {
303
+ enabled: @proposal.linked_resources(:projects, "included_proposals").present?,
304
+ id: "included_projects",
305
+ text: t("decidim/budgets/project", scope: "activerecord.models", count: 2),
306
+ icon: resource_type_icon_key("Decidim::Budgets::Project"),
307
+ method: :cell,
308
+ args: ["decidim/linked_resources_for", @proposal, { type: :projects, link_name: "included_proposals" }]
309
+ },
310
+ {
311
+ enabled: @proposal.linked_resources(:results, "included_proposals").present?,
312
+ id: "included_results",
313
+ text: t("decidim/accountability/result", scope: "activerecord.models", count: 2),
314
+ icon: resource_type_icon_key("Decidim::Accountability::Result"),
315
+ method: :cell,
316
+ args: ["decidim/linked_resources_for", @proposal, { type: :results, link_name: "included_proposals" }]
317
+ },
318
+ {
319
+ enabled: @proposal.linked_resources(:meetings, "proposals_from_meeting").present?,
320
+ id: "included_meetings",
321
+ text: t("decidim/meetings/meeting", scope: "activerecord.models", count: 2),
322
+ icon: resource_type_icon_key("Decidim::Meetings::Meeting"),
323
+ method: :cell,
324
+ args: ["decidim/linked_resources_for", @proposal, { type: :meetings, link_name: "proposals_from_meeting" }]
325
+ },
326
+ {
327
+ enabled: @proposal.linked_resources(:proposals, "copied_from_component").present?,
328
+ id: "included_proposals",
329
+ text: t("decidim/proposals/proposal", scope: "activerecord.models", count: 2),
330
+ icon: resource_type_icon_key("Decidim::Proposals::Proposal"),
331
+ method: :cell,
332
+ args: ["decidim/linked_resources_for", @proposal, { type: :proposals, link_name: "copied_from_component" }]
333
+ }
334
+ ] + attachments_tab_panel_items(@proposal)
335
+ end
306
336
  end
307
337
  end
308
338
  end
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -1,4 +1,4 @@
1
- # frozen-string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Decidim
4
4
  module Proposals
@@ -21,7 +21,7 @@ module Decidim
21
21
  validates :document, presence: true, if: :new_participatory_text?
22
22
  validate :document_type_must_be_valid, if: :document
23
23
 
24
- # Assume it's a NEW participatory_text if there are no proposals
24
+ # Assume it is a NEW participatory_text if there are no proposals
25
25
  # Validate document presence while CREATING proposals from document
26
26
  # Allow skipping document validation while UPDATING title/description
27
27
  def new_participatory_text?
@@ -101,7 +101,7 @@ module Decidim
101
101
  end
102
102
 
103
103
  def suggested_hashtags
104
- downcased_suggested_hashtags = super.map(&:downcase).to_set
104
+ downcased_suggested_hashtags = super.to_set(&:downcase)
105
105
  component_suggested_hashtags.select { |hashtag| downcased_suggested_hashtags.member?(hashtag.downcase) }
106
106
  end
107
107
 
@@ -119,7 +119,7 @@ module Decidim
119
119
 
120
120
  private
121
121
 
122
- # This method will add an error to the `attachment` field only if there's
122
+ # This method will add an error to the `attachment` field only if there is
123
123
  # any error in any other field. This is needed because when the form has
124
124
  # an error, the attachment is lost, so we need a way to inform the user of
125
125
  # this problem.
@@ -21,7 +21,7 @@ module Decidim
21
21
  presenter = ProposalPresenter.new(model)
22
22
 
23
23
  self.title = presenter.title(all_locales: title.is_a?(Hash))
24
- self.body = presenter.body(all_locales: body.is_a?(Hash))
24
+ self.body = presenter.editor_body(all_locales: body.is_a?(Hash))
25
25
  self.attachment = if model.documents.first.present?
26
26
  { file: model.documents.first.file, title: translated_attribute(model.documents.first.title) }
27
27
  else
@@ -53,7 +53,7 @@ module Decidim
53
53
 
54
54
  # Private: Returns the id of the target component.
55
55
  #
56
- # We receive this as ["id"] since it's from a select in a form.
56
+ # We receive this as ["id"] since it is from a select in a form.
57
57
  def clean_target_component_id
58
58
  target_component_id.first
59
59
  end
@@ -17,7 +17,7 @@ module Decidim
17
17
  end
18
18
 
19
19
  def valuator_role
20
- @valuator_role ||= current_component.participatory_space.user_roles(:valuator).find_by(id: id)
20
+ @valuator_role ||= current_component.participatory_space.user_roles(:valuator).find_by(id:)
21
21
  end
22
22
 
23
23
  def valuator_user
@@ -15,15 +15,12 @@ module Decidim
15
15
  attribute :longitude, Float
16
16
  attribute :category_id, Integer
17
17
  attribute :scope_id, Integer
18
- attribute :has_address, Boolean
19
18
  attribute :attachment, AttachmentForm
20
19
  attribute :suggested_hashtags, Array[String]
21
20
 
22
- attachments_attribute :photos
23
21
  attachments_attribute :documents
24
22
 
25
23
  validates :address, geocoding: true, if: ->(form) { form.has_address? && !form.geocoded? }
26
- validates :address, presence: true, if: ->(form) { form.has_address? }
27
24
  validates :category, presence: true, if: ->(form) { form.category_id.present? }
28
25
  validates :scope, presence: true, if: ->(form) { form.scope_id.present? }
29
26
  validates :scope_id, scope_belongs_to_component: true, if: ->(form) { form.scope_id.present? }
@@ -37,17 +34,14 @@ module Decidim
37
34
  body = translated_attribute(model.body)
38
35
  @suggested_hashtags = Decidim::ContentRenderers::HashtagRenderer.new(body).extra_hashtags.map(&:name).map(&:downcase)
39
36
 
37
+ presenter = ProposalPresenter.new(model)
38
+ self.body = presenter.editor_body(all_locales: body.is_a?(Hash))
39
+
40
40
  # The scope attribute is with different key (decidim_scope_id), so it
41
41
  # has to be manually mapped.
42
42
  self.scope_id = model.scope.id if model.scope
43
43
 
44
- self.has_address = true if model.address.present?
45
-
46
- # Proposals have the "photos" field reserved for the proposal card image
47
- # so we don't want to show all photos there. Instead, only show the
48
- # first photo.
49
- self.photos = [model.photo].compact.select { |p| p.weight.zero? }
50
- self.documents = model.attachments - photos
44
+ self.documents = model.attachments
51
45
  end
52
46
 
53
47
  # Finds the Category from the category_id.
@@ -75,15 +69,7 @@ module Decidim
75
69
  Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled?
76
70
  end
77
71
 
78
- def address
79
- return unless has_address
80
-
81
- super
82
- end
83
-
84
72
  def has_address?
85
- return unless has_address
86
-
87
73
  geocoding_enabled? && address.present?
88
74
  end
89
75
 
@@ -96,7 +82,7 @@ module Decidim
96
82
  end
97
83
 
98
84
  def suggested_hashtags
99
- downcased_suggested_hashtags = super.map(&:downcase).to_set
85
+ downcased_suggested_hashtags = super.to_set(&:downcase)
100
86
  component_suggested_hashtags.select { |hashtag| downcased_suggested_hashtags.member?(hashtag.downcase) }
101
87
  end
102
88
 
@@ -114,15 +100,11 @@ module Decidim
114
100
 
115
101
  private
116
102
 
117
- # This method will add an error to the `add_photos` and/or "add_documents" fields
118
- # only if there's any error in any other field. This is needed because when the
119
- # form has an error, the attachment is lost, so we need a way to inform the user of
120
- # this problem.
103
+ # This method will add an error to the "add_documents" field only if there is any error
104
+ # in any other field. This is needed because when the form has an error, the attachment
105
+ # is lost, so we need a way to inform the user of this problem.
121
106
  def notify_missing_attachment_if_errored
122
- if errors.any?
123
- errors.add(:add_photos, :needs_to_be_reattached) if add_photos.present?
124
- errors.add(:add_documents, :needs_to_be_reattached) if add_documents.present?
125
- end
107
+ errors.add(:add_documents, :needs_to_be_reattached) if errors.any? && add_documents.present?
126
108
  end
127
109
 
128
110
  def ordered_hashtag_list(string)
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Returns a String.
17
17
  def bulk_valuators_select(participatory_space, prompt)
18
18
  options_for_select = find_valuators_for_select(participatory_space)
19
- select(:valuator_role, :id, options_for_select, prompt: prompt)
19
+ select(:valuator_role, :id, options_for_select, prompt:)
20
20
  end
21
21
 
22
22
  # Internal: A method to cache to queries to find the valuators for the