Module: Decidim::Proposals::ProposalsHelper

Defined in:
decidim-proposals/app/helpers/decidim/proposals/proposals_helper.rb

Overview

Simple helpers to handle markup variations for proposals

Instance Method Summary collapse

Instance Method Details

#filter_proposals_state_valuesObject


38
39
40
41
42
43
44
45
46
47
48
# File 'decidim-proposals/app/helpers/decidim/proposals/proposals_helper.rb', line 38

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"))
    ]
  )
end

#proposal_has_costs?Boolean

Returns:

  • (Boolean)

50
51
52
53
54
# File 'decidim-proposals/app/helpers/decidim/proposals/proposals_helper.rb', line 50

def proposal_has_costs?
  @proposal.cost.present? &&
    translated_attribute(@proposal.cost_report).present? &&
    translated_attribute(@proposal.execution_period).present?
end

#proposal_reason_callout_announcementObject


7
8
9
10
11
12
# File 'decidim-proposals/app/helpers/decidim/proposals/proposals_helper.rb', line 7

def proposal_reason_callout_announcement
  {
    title: proposal_reason_callout_title,
    body: decidim_sanitize(translated_attribute(@proposal.answer))
  }
end

#proposal_reason_callout_classObject


14
15
16
17
18
19
20
21
22
23
24
25
# File 'decidim-proposals/app/helpers/decidim/proposals/proposals_helper.rb', line 14

def proposal_reason_callout_class
  case @proposal.state
  when "accepted"
    "success"
  when "evaluating"
    "warning"
  when "rejected"
    "alert"
  else
    ""
  end
end

#proposal_reason_callout_titleObject


27
28
29
30
31
32
33
34
35
36
# File 'decidim-proposals/app/helpers/decidim/proposals/proposals_helper.rb', line 27

def proposal_reason_callout_title
  i18n_key = case @proposal.state
             when "evaluating"
               "proposal_in_evaluation_reason"
             else
               "proposal_#{@proposal.state}_reason"
             end

  t(i18n_key, scope: "decidim.proposals.proposals.show")
end

#resource_version(resource, options = {}) ⇒ Object


56
57
58
59
60
# File 'decidim-proposals/app/helpers/decidim/proposals/proposals_helper.rb', line 56

def resource_version(resource, options = {})
  return unless resource.respond_to?(:amendable?) && resource.amendable?

  super
end