app/helpers/decidim/proposals/application_helper.rb in decidim-proposals-0.28.4 vs app/helpers/decidim/proposals/application_helper.rb in decidim-proposals-0.29.0.rc1
- old
+ new
@@ -26,20 +26,26 @@
# Returns a String.
def humanize_proposal_state(state)
I18n.t(state, scope: "decidim.proposals.answers", default: :not_answered)
end
+ def proposal_state_css_style(proposal)
+ return "" if proposal.emendation?
+
+ proposal.proposal_state&.css_style
+ end
+
# Public: The css class applied based on the proposal state.
#
# proposal - The proposal to evaluate.
#
# Returns a String.
def proposal_state_css_class(proposal)
- state = proposal.state
- state = proposal.internal_state if proposal.answered? && !proposal.published_state?
+ return "alert" if proposal.withdrawn?
+ return if proposal.state.blank?
- case state
+ case proposal.state
when "accepted"
"success"
when "rejected", "withdrawn"
"alert"
when "evaluating"
@@ -142,11 +148,11 @@
return false if !votes_enabled? || current_settings.votes_blocked?
return true if vote_limit_enabled?
return true if threshold_per_proposal_enabled?
return true if proposal_limit_enabled?
- return true if can_accumulate_supports_beyond_threshold?
+ return true if can_accumulate_votes_beyond_threshold?
return true if minimum_votes_per_user_enabled?
end
def filter_type_values
[
@@ -164,11 +170,11 @@
]
base += [["voted", t("decidim.proposals.proposals.filters.voted")]] if current_settings.votes_enabled?
base
end
- # Explicitely commenting the used I18n keys so their are not flagged as unused
+ # Explicitly commenting the used I18n keys so their are not flagged as unused
# i18n-tasks-use t('decidim.proposals.application_helper.filter_origin_values.official')
# i18n-tasks-use t('decidim.proposals.application_helper.filter_origin_values.participants')
# i18n-tasks-use t('decidim.proposals.application_helper.filter_origin_values.user_groups')
# i18n-tasks-use t('decidim.proposals.application_helper.filter_origin_values.official')
# i18n-tasks-use t('decidim.proposals.application_helper.filter_origin_values.meetings')
@@ -189,14 +195,14 @@
def filter_proposals_state_values
Decidim::CheckBoxesTreeHelper::TreeNode.new(
Decidim::CheckBoxesTreeHelper::TreePoint.new("", t("decidim.proposals.application_helper.filter_state_values.all")),
[
- Decidim::CheckBoxesTreeHelper::TreePoint.new("accepted", t("decidim.proposals.application_helper.filter_state_values.accepted")),
- Decidim::CheckBoxesTreeHelper::TreePoint.new("evaluating", t("decidim.proposals.application_helper.filter_state_values.evaluating")),
- Decidim::CheckBoxesTreeHelper::TreePoint.new("state_not_published", t("decidim.proposals.application_helper.filter_state_values.not_answered")),
- Decidim::CheckBoxesTreeHelper::TreePoint.new("rejected", t("decidim.proposals.application_helper.filter_state_values.rejected"))
- ]
+ Decidim::CheckBoxesTreeHelper::TreePoint.new("state_not_published", t("decidim.proposals.application_helper.filter_state_values.not_answered"))
+ ] +
+ Decidim::Proposals::ProposalState.where(component: current_component).where.not(token: "not_answered").map do |state|
+ Decidim::CheckBoxesTreeHelper::TreePoint.new(state.token, translated_attribute(state.title))
+ end
)
end
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity