decidim-proposals 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/admin/decidim_proposals_manifest.js +1 -0
  3. data/app/assets/images/decidim/gamification/badges/accepted_proposals.svg +1 -234
  4. data/app/assets/images/decidim/gamification/badges/proposal_votes.svg +1 -95
  5. data/app/assets/images/decidim/gamification/badges/proposals.svg +1 -229
  6. data/app/assets/images/decidim/proposals/icon.svg +1 -3
  7. data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +0 -5
  8. data/app/assets/javascripts/decidim/proposals/admin/proposals_picker.js.es6 +35 -0
  9. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +1 -1
  10. data/app/cells/decidim/proposals/collaborative_draft_m/footer.erb +1 -1
  11. data/app/cells/decidim/proposals/collaborative_draft_m_cell.rb +1 -1
  12. data/app/cells/decidim/proposals/highlighted_proposals_for_component/show.erb +3 -3
  13. data/app/cells/decidim/proposals/highlighted_proposals_for_component_cell.rb +1 -1
  14. data/app/cells/decidim/proposals/irreversible_action_modal/show.erb +2 -2
  15. data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
  16. data/app/cells/decidim/proposals/participatory_text_proposal/buttons.erb +1 -1
  17. data/app/cells/decidim/proposals/participatory_text_proposal_cell.rb +1 -1
  18. data/app/cells/decidim/proposals/proposal_m/footer.erb +4 -1
  19. data/app/cells/decidim/proposals/proposal_m_cell.rb +28 -8
  20. data/app/cells/decidim/proposals/proposal_tags/show.erb +8 -2
  21. data/app/cells/decidim/proposals/proposals_picker/proposals.erb +12 -0
  22. data/app/cells/decidim/proposals/proposals_picker/show.erb +14 -0
  23. data/app/cells/decidim/proposals/proposals_picker_cell.rb +72 -0
  24. data/app/commands/decidim/proposals/admin/create_proposal.rb +1 -1
  25. data/app/commands/decidim/proposals/admin/create_proposal_note.rb +15 -0
  26. data/app/commands/decidim/proposals/admin/update_proposal.rb +1 -1
  27. data/app/commands/decidim/proposals/create_collaborative_draft.rb +1 -1
  28. data/app/commands/decidim/proposals/create_proposal.rb +1 -1
  29. data/app/commands/decidim/proposals/gallery_methods.rb +2 -51
  30. data/app/commands/decidim/proposals/update_proposal.rb +1 -1
  31. data/app/controllers/concerns/decidim/proposals/admin/picker.rb +21 -0
  32. data/app/controllers/concerns/decidim/proposals/orderable.rb +1 -1
  33. data/app/controllers/decidim/proposals/proposals_controller.rb +4 -5
  34. data/app/controllers/decidim/proposals/versions_controller.rb +8 -18
  35. data/app/events/decidim/proposals/admin/proposal_note_created_event.rb +27 -0
  36. data/app/forms/decidim/proposals/admin/participatory_text_proposal_form.rb +13 -0
  37. data/app/forms/decidim/proposals/admin/preview_participatory_text_form.rb +2 -2
  38. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +129 -0
  39. data/app/forms/decidim/proposals/admin/proposal_form.rb +2 -120
  40. data/app/forms/decidim/proposals/proposal_form.rb +4 -0
  41. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +5 -1
  42. data/app/helpers/decidim/proposals/admin/filterable_helper.rb +2 -2
  43. data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +2 -2
  44. data/app/helpers/decidim/proposals/admin/proposals_picker_helper.rb +30 -0
  45. data/app/helpers/decidim/proposals/application_helper.rb +6 -6
  46. data/app/helpers/decidim/proposals/control_version_helper.rb +1 -37
  47. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -145
  48. data/app/helpers/decidim/proposals/proposal_votes_helper.rb +2 -2
  49. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +24 -7
  50. data/app/helpers/decidim/proposals/proposals_helper.rb +6 -0
  51. data/app/models/decidim/proposals/proposal.rb +4 -14
  52. data/app/permissions/decidim/proposals/permissions.rb +1 -22
  53. data/app/presenters/decidim/proposals/proposal_presenter.rb +14 -2
  54. data/app/queries/decidim/proposals/metrics/accepted_proposals_metric_manage.rb +1 -2
  55. data/app/queries/decidim/proposals/metrics/endorsements_metric_manage.rb +15 -12
  56. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +5 -4
  57. data/app/queries/decidim/proposals/metrics/proposals_metric_manage.rb +2 -8
  58. data/app/queries/decidim/proposals/metrics/votes_metric_manage.rb +3 -9
  59. data/app/services/decidim/proposals/diff_renderer.rb +2 -0
  60. data/app/services/decidim/proposals/proposal_builder.rb +1 -1
  61. data/app/services/decidim/proposals/proposal_search.rb +2 -2
  62. data/app/types/decidim/proposals/proposal_input_sort.rb +1 -7
  63. data/app/types/decidim/proposals/proposal_type.rb +1 -11
  64. data/app/types/decidim/proposals/proposals_type.rb +10 -0
  65. data/app/validators/proposal_length_validator.rb +38 -0
  66. data/app/views/decidim/proposals/admin/participatory_texts/index.html.erb +9 -1
  67. data/app/views/decidim/proposals/admin/proposal_notes/_proposal_notes.html.erb +2 -2
  68. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +3 -23
  69. data/app/views/decidim/proposals/admin/proposals/index.html.erb +1 -1
  70. data/app/views/decidim/proposals/admin/proposals/show.html.erb +1 -1
  71. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +6 -4
  72. data/app/views/decidim/proposals/collaborative_drafts/_filters.html.erb +9 -7
  73. data/app/views/decidim/proposals/collaborative_drafts/_new_collaborative_draft_button.html.erb +4 -4
  74. data/app/views/decidim/proposals/collaborative_drafts/_reject_request_access_form.html.erb +1 -1
  75. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +4 -2
  76. data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +2 -0
  77. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +2 -0
  78. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +3 -1
  79. data/app/views/decidim/proposals/collaborative_drafts/index.html.erb +4 -2
  80. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +4 -0
  81. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +29 -30
  82. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +5 -3
  83. data/app/views/decidim/proposals/proposals/_endorsements_card_row.html.erb +0 -16
  84. data/app/views/decidim/proposals/proposals/_filters.html.erb +12 -10
  85. data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +1 -11
  86. data/app/views/decidim/proposals/proposals/_proposal_similar.html.erb +2 -2
  87. data/app/views/decidim/proposals/proposals/_proposals.html.erb +14 -0
  88. data/app/views/decidim/proposals/proposals/_vote_button.html.erb +13 -6
  89. data/app/views/decidim/proposals/proposals/_wizard_aside.html.erb +4 -2
  90. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +4 -3
  91. data/app/views/decidim/proposals/proposals/compare.html.erb +2 -0
  92. data/app/views/decidim/proposals/proposals/complete.html.erb +2 -0
  93. data/app/views/decidim/proposals/proposals/edit.html.erb +3 -1
  94. data/app/views/decidim/proposals/proposals/edit_draft.html.erb +2 -0
  95. data/app/views/decidim/proposals/proposals/index.html.erb +5 -10
  96. data/app/views/decidim/proposals/proposals/new.html.erb +5 -1
  97. data/app/views/decidim/proposals/proposals/participatory_texts/_index.html.erb +1 -1
  98. data/app/views/decidim/proposals/proposals/participatory_texts/_proposal_vote_button.html.erb +10 -3
  99. data/app/views/decidim/proposals/proposals/participatory_texts/_view_index.html.erb +1 -1
  100. data/app/views/decidim/proposals/proposals/preview.html.erb +7 -8
  101. data/app/views/decidim/proposals/proposals/show.html.erb +52 -34
  102. data/app/views/decidim/proposals/versions/index.html.erb +14 -32
  103. data/app/views/decidim/proposals/versions/show.html.erb +16 -34
  104. data/config/locales/ar.yml +8 -64
  105. data/config/locales/bg-BG.yml +237 -0
  106. data/config/locales/ca.yml +68 -61
  107. data/config/locales/cs.yml +78 -68
  108. data/config/locales/da-DK.yml +1 -0
  109. data/config/locales/de.yml +142 -58
  110. data/config/locales/el.yml +875 -0
  111. data/config/locales/en.yml +74 -67
  112. data/config/locales/es-MX.yml +68 -61
  113. data/config/locales/es-PY.yml +68 -61
  114. data/config/locales/es.yml +68 -61
  115. data/config/locales/et-EE.yml +1 -0
  116. data/config/locales/eu.yml +5 -43
  117. data/config/locales/fi-plain.yml +68 -61
  118. data/config/locales/fi.yml +109 -102
  119. data/config/locales/fr-CA.yml +876 -0
  120. data/config/locales/fr.yml +128 -60
  121. data/config/locales/ga-IE.yml +1 -0
  122. data/config/locales/gl.yml +5 -43
  123. data/config/locales/hr-HR.yml +1 -0
  124. data/config/locales/hu.yml +38 -61
  125. data/config/locales/id-ID.yml +5 -42
  126. data/config/locales/is-IS.yml +1 -27
  127. data/config/locales/it.yml +136 -76
  128. data/config/locales/ja-JP.yml +886 -0
  129. data/config/locales/lt-LT.yml +1 -0
  130. data/config/locales/lv-LV.yml +858 -0
  131. data/config/locales/mt-MT.yml +1 -0
  132. data/config/locales/nl.yml +114 -59
  133. data/config/locales/no.yml +11 -64
  134. data/config/locales/pl.yml +170 -60
  135. data/config/locales/pt-BR.yml +6 -47
  136. data/config/locales/pt.yml +419 -331
  137. data/config/locales/ro-RO.yml +840 -0
  138. data/config/locales/ru.yml +1 -40
  139. data/config/locales/sk-SK.yml +896 -0
  140. data/config/locales/sk.yml +869 -0
  141. data/config/locales/sl.yml +26 -0
  142. data/config/locales/sr-CS.yml +126 -0
  143. data/config/locales/sv.yml +228 -156
  144. data/config/locales/tr-TR.yml +5 -43
  145. data/config/locales/uk.yml +1 -40
  146. data/db/migrate/20181003074440_fix_user_groups_ids_in_proposals_endorsements.rb +4 -0
  147. data/db/migrate/20191206154128_add_endorsements_counter_cache_to_proposals.rb +7 -0
  148. data/db/migrate/20200120215928_move_proposal_endorsements_to_core_endorsements.rb +52 -0
  149. data/db/migrate/20200730131631_move_proposal_endorsed_event_notifications_to_resource_endorsed_event.rb +20 -0
  150. data/lib/decidim/proposals/component.rb +8 -4
  151. data/lib/decidim/proposals/engine.rb +1 -5
  152. data/lib/decidim/proposals/test/capybara_proposals_picker.rb +49 -0
  153. data/lib/decidim/proposals/test/factories.rb +3 -12
  154. data/lib/decidim/proposals/version.rb +1 -1
  155. metadata +55 -34
  156. data/app/assets/javascripts/decidim/proposals/identity_selector_dialog.js.es6 +0 -56
  157. data/app/cells/decidim/proposals/endorsers_list/show.erb +0 -17
  158. data/app/cells/decidim/proposals/endorsers_list_cell.rb +0 -31
  159. data/app/commands/decidim/proposals/attachment_methods.rb +0 -43
  160. data/app/commands/decidim/proposals/endorse_proposal.rb +0 -59
  161. data/app/commands/decidim/proposals/unendorse_proposal.rb +0 -40
  162. data/app/controllers/decidim/proposals/proposal_endorsements_controller.rb +0 -60
  163. data/app/models/decidim/proposals/proposal_endorsement.rb +0 -37
  164. data/app/views/decidim/proposals/proposal_endorsements/_identity.html.erb +0 -9
  165. data/app/views/decidim/proposals/proposal_endorsements/identities.html.erb +0 -12
  166. data/app/views/decidim/proposals/proposal_endorsements/update_buttons_and_counters.js.erb +0 -20
  167. data/app/views/decidim/proposals/proposals/_endorsement_button.html.erb +0 -11
  168. data/app/views/decidim/proposals/proposals/_endorsement_identities_cabin.html.erb +0 -13
  169. data/app/views/decidim/proposals/versions/_version.html.erb +0 -20
@@ -4,10 +4,10 @@ module Decidim
4
4
  module Proposals
5
5
  module Admin
6
6
  module FilterableHelper
7
- def extra_dropdown_submenu_options_items(filter)
7
+ def extra_dropdown_submenu_options_items(filter, i18n_scope)
8
8
  options = case filter
9
9
  when :state_eq
10
- content_tag(:li, filter_link_value(:state_null, true))
10
+ content_tag(:li, filter_link_value(:state_null, true, i18n_scope))
11
11
  end
12
12
  [options].compact
13
13
  end
@@ -17,7 +17,7 @@ module Decidim
17
17
  #
18
18
  # Examples:
19
19
  # ranking_for(proposal, proposal_votes_count: :desc)
20
- # ranking_for(proposal, proposal_endorsements_count: :desc)
20
+ # ranking_for(proposal, endorsements_count: :desc)
21
21
  def ranking_for(proposal, order = {})
22
22
  siblings = Decidim::Proposals::Proposal.where(component: proposal.component)
23
23
  ranked = siblings.order([order, id: :asc])
@@ -28,7 +28,7 @@ module Decidim
28
28
 
29
29
  # Public: Gets the ranking for a given proposal, ordered by endorsements.
30
30
  def endorsements_ranking_for(proposal)
31
- ranking_for(proposal, proposal_endorsements_count: :desc)
31
+ ranking_for(proposal, endorsements_count: :desc)
32
32
  end
33
33
 
34
34
  # Public: Gets the ranking for a given proposal, ordered by votes.
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Proposals
5
+ module Admin
6
+ # This class contains helpers needed to show the Proposals picker.
7
+ #
8
+ module ProposalsPickerHelper
9
+ def proposals_picker(form, field, url)
10
+ picker_options = {
11
+ id: sanitize_to_id(field),
12
+ class: "picker-multiple",
13
+ name: "#{form.object_name}[#{field.to_s.sub(/s$/, "_ids")}]",
14
+ multiple: true,
15
+ autosort: true
16
+ }
17
+
18
+ prompt_params = {
19
+ url: url,
20
+ text: t("proposals_picker.choose_proposals", scope: "decidim.proposals")
21
+ }
22
+
23
+ form.data_picker(field, picker_options, prompt_params) do |item|
24
+ { url: url, text: present(item).id_and_title }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -8,7 +8,8 @@ module Decidim
8
8
  include Decidim::Comments::CommentsHelper
9
9
  include PaginateHelper
10
10
  include ProposalVotesHelper
11
- include ProposalEndorsementsHelper
11
+ include ::Decidim::EndorsableHelper
12
+ include ::Decidim::FollowableHelper
12
13
  include Decidim::MapHelper
13
14
  include Decidim::Proposals::MapHelper
14
15
  include CollaborativeDraftHelper
@@ -99,8 +100,11 @@ module Decidim
99
100
  # If the content is safe, HTML tags are sanitized, otherwise, they are stripped.
100
101
  def render_proposal_body(proposal)
101
102
  body = present(proposal).body(links: true, strip_tags: !safe_content?)
103
+ body = simple_format(body, {}, sanitize: false)
102
104
 
103
- safe_content? ? decidim_sanitize(body) : simple_format(body, {}, sanitize: false)
105
+ return body unless safe_content?
106
+
107
+ decidim_sanitize(body)
104
108
  end
105
109
 
106
110
  # Returns :text_area or :editor based on the organization' settings.
@@ -127,10 +131,6 @@ module Decidim
127
131
  ).count
128
132
  end
129
133
 
130
- def follow_button_for(model, large = nil)
131
- render partial: "decidim/shared/follow_button.html", locals: { followable: model, large: large }
132
- end
133
-
134
134
  def votes_count_for(model, from_proposals_list)
135
135
  render partial: "decidim/proposals/proposals/participatory_texts/proposal_votes_count.html", locals: { proposal: model, from_proposals_list: from_proposals_list }
136
136
  end
@@ -5,43 +5,7 @@ module Decidim
5
5
  # Custom helpers, scoped to the proposals engine.
6
6
  module ControlVersionHelper
7
7
  def item_name
8
- item.model_name.singular_route_key.to_sym
9
- end
10
-
11
- def back_to_resource_path_text
12
- case item_name
13
- when :proposal
14
- t("back_to_proposal", scope: "decidim.proposals.versions.stats")
15
- when :collaborative_draft
16
- t("back_to_collaborative_draft", scope: "decidim.proposals.versions.stats")
17
- end
18
- end
19
-
20
- def back_to_resource_path
21
- case item_name
22
- when :proposal
23
- proposal_path(item)
24
- when :collaborative_draft
25
- collaborative_draft_path(item)
26
- end
27
- end
28
-
29
- def resource_version_path(index)
30
- case item_name
31
- when :proposal
32
- proposal_version_path(item, index + 1)
33
- when :collaborative_draft
34
- collaborative_draft_version_path(item, index + 1)
35
- end
36
- end
37
-
38
- def resource_all_versions_path
39
- case item_name
40
- when :proposal
41
- proposal_versions_path(item)
42
- when :collaborative_draft
43
- collaborative_draft_versions_path(item)
44
- end
8
+ versioned_resource.model_name.singular_route_key.to_sym
45
9
  end
46
10
  end
47
11
  end
@@ -1,145 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Proposals
5
- # Simple helper to handle markup variations for proposal endorsements partials
6
- module ProposalEndorsementsHelper
7
- # Returns the css classes used for proposal endorsement button in both proposals list and show pages
8
- #
9
- # from_proposals_list - A boolean to indicate if the template is rendered from the proposals list page
10
- #
11
- # Returns a string with the value of the css classes.
12
- def endorsement_button_classes(from_proposals_list)
13
- return "small" if from_proposals_list
14
-
15
- "small compact light button--sc expanded"
16
- end
17
-
18
- # Public: Checks if endorsement are enabled in this step.
19
- #
20
- # Returns true if enabled, false otherwise.
21
- def endorsements_enabled?
22
- current_settings.endorsements_enabled
23
- end
24
-
25
- # Public: Checks if endorsements are blocked in this step.
26
- #
27
- # Returns true if blocked, false otherwise.
28
- def endorsements_blocked?
29
- current_settings.endorsements_blocked
30
- end
31
-
32
- # Public: Checks if the current user is allowed to endorse in this step.
33
- #
34
- # Returns true if the current user can endorse, false otherwise.
35
- def current_user_can_endorse?
36
- current_user && endorsements_enabled? && !endorsements_blocked?
37
- end
38
-
39
- # Public: Checks if the card for endorsements should be rendered.
40
- #
41
- # Returns true if the endorsements card should be rendered, false otherwise.
42
- def show_endorsements_card?
43
- endorsements_enabled?
44
- end
45
-
46
- def endorsement_identity_presenter(endorsement)
47
- if endorsement.user_group
48
- Decidim::UserGroupPresenter.new(endorsement.user_group)
49
- else
50
- Decidim::UserPresenter.new(endorsement.author)
51
- end
52
- end
53
-
54
- # Public: Renders a button to endorse the given proposal.
55
- # To override the translation for both buttons: endorse and unendorse (use to be the name of the user/user_group).
56
- #
57
- # @params (mandatory): proposal, from_proposals_list
58
- # @params (optional) : user_group, btn_label
59
- def endorsement_button(proposal, from_proposals_list, btn_label = nil, user_group = nil)
60
- current_endorsement_url = proposal_proposal_endorsement_path(
61
- proposal_id: proposal,
62
- from_proposals_list: from_proposals_list,
63
- user_group_id: user_group&.id
64
- )
65
- endorse_label = btn_label || t("decidim.proposals.proposal_endorsements_helper.endorsement_button.endorse")
66
- unendorse_label = btn_label || t("decidim.proposals.proposal_endorsements_helper.endorsement_button.already_endorsed")
67
-
68
- render partial: "decidim/proposals/proposals/endorsement_button", locals: { proposal: proposal,
69
- from_proposals_list: from_proposals_list, user_group: user_group,
70
- current_endorsement_url: current_endorsement_url,
71
- endorse_label: endorse_label, unendorse_label: unendorse_label }
72
- end
73
-
74
- #
75
- # Public: Checks if the given Proposal has been endorsed by all identities of the user.
76
- #
77
- # @param proposal: The Proposal from which endorsements will be checked against.
78
- # @param user: The user whose identities and endorsements will be checked against.
79
- #
80
- def fully_endorsed?(proposal, user)
81
- return false unless user
82
-
83
- user_group_endorsements = Decidim::UserGroups::ManageableUserGroups.for(user).verified.all? { |user_group| proposal.endorsed_by?(user, user_group) }
84
-
85
- user_group_endorsements && proposal.endorsed_by?(user)
86
- end
87
-
88
- # Public: Renders an identity for endorsement.
89
- #
90
- # @params (mandatory): proposal, from_proposals_list
91
- # @params (mandatory): user, the user that is endorsing at the end.
92
- # @params (optional) : user_group, the user_group on behalf of which the endorsement is being done
93
- def render_endorsement_identity(proposal, user, user_group = nil)
94
- current_endorsement_url = proposal_proposal_endorsement_path(
95
- proposal_id: proposal,
96
- from_proposals_list: false,
97
- user_group_id: user_group&.id,
98
- authenticity_token: form_authenticity_token
99
- )
100
- presenter = if user_group
101
- Decidim::UserGroupPresenter.new(user_group)
102
- else
103
- Decidim::UserPresenter.new(user)
104
- end
105
- selected = proposal.endorsed_by?(user, user_group)
106
- http_method = selected ? :delete : :post
107
- render partial: "decidim/proposals/proposal_endorsements/identity", locals:
108
- { identity: presenter, selected: selected, current_endorsement_url: current_endorsement_url, http_method: http_method }
109
- end
110
-
111
- # Renders the counter of endorsements that appears in card at show Propoal.
112
- def render_endorsements_count_card_part(proposal, fully_endorsed, html_class = nil)
113
- content = icon("bullhorn", class: "icon--small", aria_label: "Endorsements", role: "img")
114
- content += proposal.proposal_endorsements_count.to_s
115
- html_class = "button small compact light button--sc button--shadow" if html_class.blank?
116
- tag_params = { id: "proposal-#{proposal.id}-endorsements-count", class: "#{html_class} #{fully_endorsed ? "success" : "secondary"}" }
117
- if proposal.proposal_endorsements_count.positive?
118
- link_to "#list-of-endorsements", tag_params do
119
- content
120
- end
121
- else
122
- content_tag("div", tag_params) do
123
- content
124
- end
125
- end
126
- end
127
-
128
- def render_endorsements_button_card_part(proposal, fully_endorsed, html_class = nil)
129
- endorse_translated = t("decidim.proposals.proposal_endorsements_helper.render_endorsements_button_card_part.endorse")
130
- html_class = "card__button button" if html_class.blank?
131
- if current_settings.endorsements_blocked? || !current_component.participatory_space.can_participate?(current_user)
132
- content_tag :span, endorse_translated, class: "#{html_class} #{endorsement_button_classes(false)} disabled", disabled: true, title: endorse_translated
133
- elsif current_user && allowed_to?(:endorse, :proposal, proposal: proposal)
134
- render partial: "endorsement_identities_cabin", locals: { proposal: proposal, fully_endorsed: fully_endorsed }
135
- elsif current_user
136
- button_to(endorse_translated, proposal_path(proposal),
137
- data: { open: "authorizationModal", "open-url": modal_path(:endorse, proposal) },
138
- class: "#{html_class} #{endorsement_button_classes(false)} secondary")
139
- else
140
- action_authorized_button_to :endorse, endorse_translated, "", resource: proposal, class: "#{html_class} #{endorsement_button_classes(false)} secondary"
141
- end
142
- end
143
- end
144
- end
145
- end
@@ -21,9 +21,9 @@ module Decidim
21
21
  #
22
22
  # Returns a string with the value of the css classes.
23
23
  def vote_button_classes(from_proposals_list)
24
- return "card__button button--sc" if from_proposals_list
24
+ return "card__button" if from_proposals_list
25
25
 
26
- "expanded button--sc"
26
+ "expanded"
27
27
  end
28
28
 
29
29
  # Public: Gets the vote limit for each user, if set.
@@ -58,7 +58,15 @@ module Decidim
58
58
  def proposal_wizard_stepper_step(step, current_step)
59
59
  return if step == :step_4 && type_of == :collaborative_drafts
60
60
 
61
- content_tag(:li, proposal_wizard_step_name(step), class: proposal_wizard_step_classes(step, current_step).to_s)
61
+ attributes = { class: proposal_wizard_step_classes(step, current_step).to_s }
62
+ step_title = proposal_wizard_step_name(step)
63
+ if step.to_s.split("_").last.to_i == proposal_wizard_step_number(current_step)
64
+ current_step_title = proposal_wizard_step_name("current_step")
65
+ step_title = content_tag(:span, "#{current_step_title}: ", class: "show-for-sr") + step_title
66
+ attributes["aria-current"] = "step"
67
+ end
68
+
69
+ content_tag(:li, step_title, attributes)
62
70
  end
63
71
 
64
72
  # Returns the list with all the steps, in html
@@ -77,15 +85,21 @@ module Decidim
77
85
 
78
86
  # Returns a string with the current step number and the total steps number
79
87
  #
80
- # step - A symbol of the target step
81
88
  def proposal_wizard_current_step_of(step)
82
89
  current_step_num = proposal_wizard_step_number(step)
83
- content_tag :span, class: "text-small" do
84
- concat t(:"decidim.proposals.proposals.wizard_steps.step_of", current_step_num: current_step_num, total_steps: total_steps)
90
+ see_steps = content_tag(:span, class: "hide-for-large") do
85
91
  concat " ("
86
92
  concat content_tag :a, t(:"decidim.proposals.proposals.wizard_steps.see_steps"), "data-toggle": "steps"
87
93
  concat ")"
88
94
  end
95
+ content_tag :span, class: "text-small" do
96
+ concat t(:"decidim.proposals.proposals.wizard_steps.step_of", current_step_num: current_step_num, total_steps: total_steps)
97
+ concat see_steps
98
+ end
99
+ end
100
+
101
+ def proposal_wizard_steps_title
102
+ t("title", scope: "decidim.proposals.#{type_of}.wizard_steps")
89
103
  end
90
104
 
91
105
  # Returns a boolean if the step has a help text defined
@@ -146,12 +160,15 @@ module Decidim
146
160
  url
147
161
  end
148
162
 
149
- def wizard_aside_back_text
163
+ def wizard_aside_back_text(from = nil)
164
+ key = "back"
165
+ key = "back_from_#{from}" if from
166
+
150
167
  case type_of
151
168
  when :collaborative_drafts
152
- t("back", scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe
169
+ t(key, scope: "decidim.proposals.collaborative_drafts.wizard_aside").html_safe
153
170
  else
154
- t("back", scope: "decidim.proposals.proposals.wizard_aside").html_safe
171
+ t(key, scope: "decidim.proposals.proposals.wizard_aside").html_safe
155
172
  end
156
173
  end
157
174
 
@@ -55,6 +55,12 @@ module Decidim
55
55
  translated_attribute(@proposal.cost_report).present? &&
56
56
  translated_attribute(@proposal.execution_period).present?
57
57
  end
58
+
59
+ def resource_version(resource, options = {})
60
+ return unless resource.respond_to?(:amendable?) && resource.amendable?
61
+
62
+ super
63
+ end
58
64
  end
59
65
  end
60
66
  end
@@ -24,6 +24,7 @@ module Decidim
24
24
  include Decidim::Amendable
25
25
  include Decidim::NewsletterParticipant
26
26
  include Decidim::Randomable
27
+ include Decidim::Endorsable
27
28
  include Decidim::Proposals::Valuatable
28
29
 
29
30
  POSSIBLE_STATES = %w(not_answered evaluating accepted rejected withdrawn).freeze
@@ -37,8 +38,6 @@ module Decidim
37
38
 
38
39
  component_manifest_name "proposals"
39
40
 
40
- has_many :endorsements, foreign_key: "decidim_proposal_id", class_name: "ProposalEndorsement", dependent: :destroy, counter_cache: "proposal_endorsements_count"
41
-
42
41
  has_many :votes,
43
42
  -> { final },
44
43
  foreign_key: "decidim_proposal_id",
@@ -145,10 +144,9 @@ module Decidim
145
144
 
146
145
  participants_has_voted_ids = Decidim::Proposals::ProposalVote.joins(:proposal).where(proposal: proposals).joins(:author).map(&:decidim_author_id).flatten.compact.uniq
147
146
 
148
- endorsements_participants_ids = Decidim::Proposals::ProposalEndorsement.joins(:proposal)
149
- .where(proposal: proposals)
150
- .where(decidim_author_type: "Decidim::UserBaseEntity")
151
- .map(&:decidim_author_id).flatten.compact.uniq
147
+ endorsements_participants_ids = Decidim::Endorsement.where(resource: proposals)
148
+ .where(decidim_author_type: "Decidim::UserBaseEntity")
149
+ .map(&:decidim_author_id).flatten.compact.uniq
152
150
 
153
151
  (endorsements_participants_ids + participants_has_voted_ids + coauthors_recipients_ids).flatten.compact.uniq
154
152
  end
@@ -169,14 +167,6 @@ module Decidim
169
167
  ProposalVote.where(proposal: self, author: user).any?
170
168
  end
171
169
 
172
- # Public: Check if the user has endorsed the proposal.
173
- # - user_group: may be nil if user is not representing any user_group.
174
- #
175
- # Returns Boolean.
176
- def endorsed_by?(user, user_group = nil)
177
- endorsements.where(author: user, user_group: user_group).any?
178
- end
179
-
180
170
  # Public: Checks if the proposal has been published or not.
181
171
  #
182
172
  # Returns Boolean.
@@ -31,10 +31,6 @@ module Decidim
31
31
  can_edit_proposal?
32
32
  when :withdraw
33
33
  can_withdraw_proposal?
34
- when :endorse
35
- can_endorse_proposal?
36
- when :unendorse
37
- can_unendorse_proposal?
38
34
  when :amend
39
35
  can_create_amendment?
40
36
  when :vote
@@ -47,7 +43,7 @@ module Decidim
47
43
  end
48
44
 
49
45
  def proposal
50
- @proposal ||= context.fetch(:proposal, nil)
46
+ @proposal ||= context.fetch(:proposal, nil) || context.fetch(:resource, nil)
51
47
  end
52
48
 
53
49
  def voting_enabled?
@@ -82,23 +78,6 @@ module Decidim
82
78
  toggle_allow(proposal && proposal.authored_by?(user))
83
79
  end
84
80
 
85
- def can_endorse_proposal?
86
- is_allowed = proposal &&
87
- authorized?(:endorse, resource: proposal) &&
88
- current_settings&.endorsements_enabled? &&
89
- !current_settings&.endorsements_blocked?
90
-
91
- toggle_allow(is_allowed)
92
- end
93
-
94
- def can_unendorse_proposal?
95
- is_allowed = proposal &&
96
- authorized?(:endorse, resource: proposal) &&
97
- current_settings&.endorsements_enabled?
98
-
99
- toggle_allow(is_allowed)
100
- end
101
-
102
81
  def can_create_amendment?
103
82
  is_allowed = proposal &&
104
83
  authorized?(:amend, resource: proposal) &&