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
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ # This cell renders metadata for an instance of a Proposal
6
+ class ProposalMetadataCell < Decidim::CardMetadataCell
7
+ include Decidim::Proposals::ApplicationHelper
8
+
9
+ delegate :state, to: :model
10
+
11
+ def initialize(*)
12
+ super
13
+
14
+ @items.prepend(*proposal_items)
15
+ end
16
+
17
+ def state_item
18
+ return if state.blank?
19
+
20
+ { text: content_tag(:span, humanize_proposal_state(state), class: "label #{state_class}") }
21
+ end
22
+
23
+ private
24
+
25
+ def proposal_items
26
+ [coauthors_item, comments_count_item, endorsements_count_item, state_item, emendation_item]
27
+ end
28
+
29
+ def proposal_items_for_map
30
+ [coauthors_item_for_map, comments_count_item, endorsements_count_item, state_item, emendation_item].compact_blank.map do |item|
31
+ {
32
+ text: item[:text].to_s.html_safe,
33
+ icon: item[:icon].present? ? icon(item[:icon]).html_safe : nil
34
+ }
35
+ end
36
+ end
37
+
38
+ def coauthors_item_for_map
39
+ presented_author = official? ? Decidim::Proposals::OfficialAuthorPresenter.new : present(resource.identities.first)
40
+
41
+ {
42
+ text: presented_author.name,
43
+ icon: "account-circle-line"
44
+ }
45
+ end
46
+
47
+ def state_class
48
+ case state
49
+ when "accepted"
50
+ "success"
51
+ when "rejected", "withdrawn"
52
+ "alert"
53
+ when "evaluating"
54
+ "warning"
55
+ else
56
+ "muted"
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Proposals
7
+ # This cell renders the Search (:s) proposal card
8
+ # for an instance of a Proposal
9
+ class ProposalSCell < Decidim::CardSCell
10
+ private
11
+
12
+ def title
13
+ present(model).title(html_escape: true)
14
+ end
15
+
16
+ def metadata_cell
17
+ "decidim/proposals/proposal_metadata"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,14 +1,14 @@
1
- <div class="picker-header">
2
- <h1><%= t("proposals_picker.choose_proposals", scope: "decidim.proposals") %></h1>
3
- <input type="text" name="proposals-filter" id="proposals_filter" placeholder="<%= t("decidim.admin.filters.search_placeholder.id_string_or_title_cont", collection: proposals_collection_name) %>">
4
- </div>
5
- <div class="picker-content picker-list" data-picker-path="<%= picker_path %>" data-picker-more="<%= more_proposals? %>">
6
- <%= render :proposals %>
7
- </div>
8
- <div class="picker-footer">
9
- <div class="buttons button--double">
10
- <a class="button" data-close=""><%= t("proposals_picker.close", scope: "decidim.proposals") %></a>
11
- </div>
12
- </div>
1
+ <label for="proposals_list">
2
+ <%= t("name", scope: "decidim.components.proposals") %>
13
3
 
14
- <%= javascript_pack_tag "decidim_proposals_admin" %>
4
+ <select id="proposals_list"
5
+ placeholder="<%= t("proposals_picker.choose_proposals", scope: "decidim.proposals") %>"
6
+ data-tm-name="<%= form_name %>"
7
+ data-tm-items="<%= selected_ids.to_json %>"
8
+ data-tm-no-results="<%= t("proposals_picker.no_proposals", scope: "decidim.proposals") %>"
9
+ class="mt-4" multiple>
10
+ <% decorated_proposals do |proposal| %>
11
+ <option value="<%= proposal.id %>"><%= proposal.id_and_title(html_escape: true) %> (<%= proposal.reference %>)</option>
12
+ <% end %>
13
+ </select>
14
+ </label>
@@ -9,54 +9,29 @@ module Decidim
9
9
  MAX_PROPOSALS = 1000
10
10
 
11
11
  def show
12
- if filtered?
13
- render :proposals
14
- else
15
- render
16
- end
12
+ render
17
13
  end
18
14
 
19
15
  alias component model
20
16
 
21
- def filtered?
22
- !search_text.nil?
23
- end
24
-
25
- def picker_path
26
- request.path
17
+ def form
18
+ options[:form]
27
19
  end
28
20
 
29
- def search_text
30
- params[:q]
21
+ def field
22
+ options[:field]
31
23
  end
32
24
 
33
- def more_proposals?
34
- @more_proposals ||= more_proposals_count.positive?
25
+ def form_name
26
+ "#{form.object_name}[#{method_name}]"
35
27
  end
36
28
 
37
- def more_proposals_count
38
- @more_proposals_count ||= proposals_count - MAX_PROPOSALS
29
+ def method_name
30
+ field.to_s.sub(/s$/, "_ids")
39
31
  end
40
32
 
41
- def proposals_count
42
- @proposals_count ||= filtered_proposals.count
43
- end
44
-
45
- def decorated_proposals
46
- filtered_proposals.limit(MAX_PROPOSALS).each do |proposal|
47
- yield Decidim::Proposals::ProposalPresenter.new(proposal)
48
- end
49
- end
50
-
51
- def filtered_proposals
52
- @filtered_proposals ||= if filtered?
53
- table_name = Decidim::Proposals::Proposal.table_name
54
- proposals.where(%("#{table_name}"."title"::text ILIKE ?), "%#{search_text}%")
55
- .or(proposals.where(%("#{table_name}"."reference" ILIKE ?), "%#{search_text}%"))
56
- .or(proposals.where(%("#{table_name}"."id"::text ILIKE ?), "%#{search_text}%"))
57
- else
58
- proposals
59
- end
33
+ def selected_ids
34
+ form.object.send(method_name)
60
35
  end
61
36
 
62
37
  def proposals
@@ -67,8 +42,10 @@ module Decidim
67
42
  &.order(id: :asc)
68
43
  end
69
44
 
70
- def proposals_collection_name
71
- Decidim::Proposals::Proposal.model_name.human(count: 2)
45
+ def decorated_proposals
46
+ proposals.limit(MAX_PROPOSALS).each do |proposal|
47
+ yield Decidim::Proposals::ProposalPresenter.new(proposal)
48
+ end
72
49
  end
73
50
  end
74
51
  end
@@ -21,7 +21,7 @@ module Decidim
21
21
  # Executes the command. Broadcasts these events:
22
22
  #
23
23
  # - :ok when everything is valid.
24
- # - :invalid if it wasn't valid and we couldn't proceed.
24
+ # - :invalid if it was not valid and we could not proceed.
25
25
  #
26
26
  # Returns nothing.
27
27
  def call
@@ -17,7 +17,7 @@ module Decidim
17
17
  # Executes the command. Broadcasts these events:
18
18
  #
19
19
  # - :ok when everything is valid.
20
- # - :invalid if the form wasn't valid and we couldn't proceed.
20
+ # - :invalid if the form was not valid and we could not proceed.
21
21
  #
22
22
  # Returns nothing.
23
23
  def call
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
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
@@ -42,7 +42,7 @@ module Decidim
42
42
 
43
43
  def find_assignment(proposal)
44
44
  Decidim::Proposals::ValuationAssignment.find_by(
45
- proposal: proposal,
45
+ proposal:,
46
46
  valuator_role: form.valuator_role
47
47
  )
48
48
  end
@@ -51,7 +51,7 @@ module Decidim
51
51
  Decidim.traceability.create!(
52
52
  Decidim::Proposals::ValuationAssignment,
53
53
  form.current_user,
54
- proposal: proposal,
54
+ proposal:,
55
55
  valuator_role: form.valuator_role
56
56
  )
57
57
  end
@@ -19,7 +19,7 @@ module Decidim
19
19
  # Executes the command. Broadcasts these events:
20
20
  #
21
21
  # - :ok when everything is valid, together with the proposal.
22
- # - :invalid if the form wasn't valid and we couldn't proceed.
22
+ # - :invalid if the form was not valid and we could not proceed.
23
23
  #
24
24
  # Returns nothing.
25
25
  def call
@@ -53,7 +53,7 @@ module Decidim
53
53
 
54
54
  def create_proposal
55
55
  @proposal = Decidim::Proposals::ProposalBuilder.create(
56
- attributes: attributes,
56
+ attributes:,
57
57
  author: form.author,
58
58
  action_user: form.current_user
59
59
  )
@@ -17,7 +17,7 @@ module Decidim
17
17
  # Executes the command. Broadcasts these events:
18
18
  #
19
19
  # - :ok when everything is valid, together with the note proposal.
20
- # - :invalid if the form wasn't valid and we couldn't proceed.
20
+ # - :invalid if the form was not valid and we could not proceed.
21
21
  #
22
22
  # Returns nothing.
23
23
  def call
@@ -39,7 +39,7 @@ module Decidim
39
39
  form.current_user,
40
40
  {
41
41
  body: form.body,
42
- proposal: proposal,
42
+ proposal:,
43
43
  author: form.current_user
44
44
  },
45
45
  resource: {
@@ -50,13 +50,13 @@ module Decidim
50
50
 
51
51
  def notify_admins_and_valuators
52
52
  affected_users = Decidim::User.org_admins_except_me(form.current_user).all
53
- affected_users += Decidim::Proposals::ValuationAssignment.includes(valuator_role: :user).where.not(id: form.current_user.id).where(proposal: proposal).map(&:valuator)
53
+ affected_users += Decidim::Proposals::ValuationAssignment.includes(valuator_role: :user).where.not(id: form.current_user.id).where(proposal:).map(&:valuator)
54
54
 
55
55
  data = {
56
56
  event: "decidim.events.proposals.admin.proposal_note_created",
57
57
  event_class: Decidim::Proposals::Admin::ProposalNoteCreatedEvent,
58
58
  resource: proposal,
59
- affected_users: affected_users
59
+ affected_users:
60
60
  }
61
61
 
62
62
  Decidim::EventsManager.publish(**data)
@@ -15,7 +15,7 @@ module Decidim
15
15
  # Executes the command. Broadcasts these events:
16
16
  #
17
17
  # - :ok when everything is valid.
18
- # - :invalid if the form wasn't valid and we couldn't proceed.
18
+ # - :invalid if the form was not valid and we could not proceed.
19
19
  #
20
20
  # Returns nothing.
21
21
  def call
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
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
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
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
@@ -47,22 +47,11 @@ module Decidim
47
47
  def proposals
48
48
  @proposals = Decidim::Proposals::Proposal
49
49
  .where(component: origin_component)
50
- .where(state: proposal_states)
50
+ .where(state: @form.states)
51
51
  @proposals = @proposals.where(scope: proposal_scopes) unless proposal_scopes.empty?
52
52
  @proposals
53
53
  end
54
54
 
55
- def proposal_states
56
- @proposal_states = @form.states
57
-
58
- if @form.states.include?("not_answered")
59
- @proposal_states.delete("not_answered")
60
- @proposal_states.push(nil)
61
- end
62
-
63
- @proposal_states
64
- end
65
-
66
55
  def proposal_scopes
67
56
  @form.scopes
68
57
  end
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
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
@@ -16,7 +16,7 @@ module Decidim
16
16
 
17
17
  # Executes the command. Broadcasts these events:
18
18
  #
19
- # - :noop when the answer is not published or the state didn't changed.
19
+ # - :noop when the answer is not published or the state did not changed.
20
20
  # - :ok when everything is valid.
21
21
  #
22
22
  # Returns nothing.
@@ -62,8 +62,8 @@ module Decidim
62
62
 
63
63
  def publish_event(event, event_class)
64
64
  Decidim::EventsManager.publish(
65
- event: event,
66
- event_class: event_class,
65
+ event:,
66
+ event_class:,
67
67
  resource: proposal,
68
68
  affected_users: proposal.notifiable_identities,
69
69
  followers: proposal.followers - proposal.notifiable_identities
@@ -44,7 +44,7 @@ module Decidim
44
44
  .published
45
45
  .answered
46
46
  .state_not_published
47
- .where(component: component)
47
+ .where(component:)
48
48
  .where(id: proposal_ids)
49
49
  end
50
50
 
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
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
@@ -55,7 +55,7 @@ module Decidim
55
55
  title, body = reset_proposal_title_and_body(proposal)
56
56
 
57
57
  Decidim.traceability.perform_action!(:create, proposal, form.current_user, visibility: "all") do
58
- proposal.update(title: title, body: body, published_at: Time.current)
58
+ proposal.update(title:, body:, published_at: Time.current)
59
59
  end
60
60
  end
61
61
 
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
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
@@ -16,7 +16,7 @@ module Decidim
16
16
  # Executes the command. Broadcasts these events:
17
17
  #
18
18
  # - :ok when everything is valid.
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
@@ -41,7 +41,7 @@ module Decidim
41
41
 
42
42
  def find_assignment(proposal)
43
43
  Decidim::Proposals::ValuationAssignment.find_by(
44
- proposal: proposal,
44
+ proposal:,
45
45
  valuator_role: form.valuator_role
46
46
  )
47
47
  end
@@ -17,7 +17,7 @@ module Decidim
17
17
  # Executes the command. Broadcasts these events:
18
18
  #
19
19
  # - :ok when everything is valid.
20
- # - :invalid if the form wasn't valid and we couldn't proceed.
20
+ # - :invalid if the form was not valid and we could not proceed.
21
21
  #
22
22
  # Returns nothing.
23
23
  def call
@@ -22,7 +22,7 @@ module Decidim
22
22
  # Executes the command. Broadcasts these events:
23
23
  #
24
24
  # - :ok when everything is valid, together with the proposal.
25
- # - :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.
26
26
  #
27
27
  # Returns nothing.
28
28
  def call
@@ -57,6 +57,10 @@ module Decidim
57
57
 
58
58
  attr_reader :form, :proposal, :attachment, :gallery
59
59
 
60
+ def delete_attachment(attachment)
61
+ Attachment.find(attachment.id).delete if attachment.id.to_i == proposal.documents.first.id
62
+ end
63
+
60
64
  def update_proposal
61
65
  parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
62
66
  parsed_body = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite
@@ -57,7 +57,7 @@ module Decidim
57
57
 
58
58
  def update_proposal_scope(proposal)
59
59
  proposal.update!(
60
- scope: scope
60
+ scope:
61
61
  )
62
62
  end
63
63
 
@@ -20,7 +20,7 @@ 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
@@ -31,7 +31,7 @@ module Decidim
31
31
  return broadcast(:invalid) if attachments_invalid?
32
32
  end
33
33
 
34
- transaction do
34
+ with_events(with_transaction: true) do
35
35
  create_collaborative_draft
36
36
  create_attachments if process_attachments?
37
37
  end
@@ -43,6 +43,16 @@ module Decidim
43
43
 
44
44
  attr_reader :form, :collaborative_draft, :attachment
45
45
 
46
+ def event_arguments
47
+ {
48
+ resource: collaborative_draft,
49
+ extra: {
50
+ event_author: form.current_user,
51
+ locale:
52
+ }
53
+ }
54
+ end
55
+
46
56
  def create_collaborative_draft
47
57
  @collaborative_draft = Decidim.traceability.perform_action!(
48
58
  :create,
@@ -70,7 +80,7 @@ module Decidim
70
80
  end
71
81
 
72
82
  def user_group
73
- @user_group ||= Decidim::UserGroup.find_by(organization: organization, id: form.user_group_id)
83
+ @user_group ||= Decidim::UserGroup.find_by(organization:, id: form.user_group_id)
74
84
  end
75
85
 
76
86
  def organization
@@ -4,7 +4,6 @@ module Decidim
4
4
  module Proposals
5
5
  # A command with all the business logic when a user creates a new proposal.
6
6
  class CreateProposal < Decidim::Command
7
- include ::Decidim::AttachmentMethods
8
7
  include HashtagsMethods
9
8
 
10
9
  # Public: Initializes the command.
@@ -21,7 +20,7 @@ module Decidim
21
20
  # Executes the command. Broadcasts these events:
22
21
  #
23
22
  # - :ok when everything is valid, together with the proposal.
24
- # - :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.
25
24
  #
26
25
  # Returns nothing.
27
26
  def call
@@ -32,7 +31,7 @@ module Decidim
32
31
  return broadcast(:invalid)
33
32
  end
34
33
 
35
- transaction do
34
+ with_events(with_transaction: true) do
36
35
  create_proposal
37
36
  end
38
37
 
@@ -43,6 +42,16 @@ module Decidim
43
42
 
44
43
  attr_reader :form, :proposal, :attachment
45
44
 
45
+ def event_arguments
46
+ {
47
+ resource: proposal,
48
+ extra: {
49
+ event_author: form.current_user,
50
+ locale:
51
+ }
52
+ }
53
+ end
54
+
46
55
  # Prevent PaperTrail from creating an additional version
47
56
  # in the proposal multi-step creation process (step 1: create)
48
57
  #
@@ -65,7 +74,7 @@ module Decidim
65
74
  },
66
75
  component: form.component
67
76
  )
68
- proposal.add_coauthor(@current_user, user_group: user_group)
77
+ proposal.add_coauthor(@current_user, user_group:)
69
78
  proposal.save!
70
79
  proposal
71
80
  end
@@ -87,7 +96,7 @@ module Decidim
87
96
  end
88
97
 
89
98
  def user_group
90
- @user_group ||= Decidim::UserGroup.find_by(organization: organization, id: form.user_group_id)
99
+ @user_group ||= Decidim::UserGroup.find_by(organization:, id: form.user_group_id)
91
100
  end
92
101
 
93
102
  def organization
@@ -14,7 +14,7 @@ module Decidim
14
14
  def body_with_hashtags
15
15
  @body_with_hashtags ||= begin
16
16
  ret = Decidim::ContentProcessor.parse(form.body, current_organization: form.current_organization).rewrite.strip
17
- ret += "\n#{body_extra_hashtags.strip}" unless body_extra_hashtags.empty?
17
+ ret += "\n\n#{body_extra_hashtags.strip}" unless body_extra_hashtags.empty?
18
18
  ret
19
19
  end
20
20
  end
@@ -49,7 +49,7 @@ module Decidim
49
49
  @current_user,
50
50
  visibility: "public-only"
51
51
  ) do
52
- @proposal.update title: title, body: body, published_at: Time.current
52
+ @proposal.update title:, body:, published_at: Time.current
53
53
  end
54
54
  end
55
55
 
@@ -21,7 +21,7 @@ module Decidim
21
21
  # Executes the command. Broadcasts these events:
22
22
  #
23
23
  # - :ok when everything is valid.
24
- # - :invalid if it wasn't valid and we couldn't proceed.
24
+ # - :invalid if it was not valid and we could not proceed.
25
25
  #
26
26
  # Returns nothing.
27
27
  def call
@@ -19,7 +19,7 @@ module Decidim
19
19
  # Executes the command. Broadcasts these events:
20
20
  #
21
21
  # - :ok when everything is valid.
22
- # - :invalid if it wasn't valid and we couldn't proceed.
22
+ # - :invalid if it was not valid and we could not proceed.
23
23
  #
24
24
  # Returns nothing.
25
25
  def call
@@ -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.
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
@@ -57,7 +57,7 @@ module Decidim
57
57
  def user_votes
58
58
  @user_votes ||= ProposalVote.where(
59
59
  author: @current_user,
60
- proposal: Proposal.where(component: component)
60
+ proposal: Proposal.where(component:)
61
61
  )
62
62
  end
63
63
  end