Module: Decidim::Consultations::ConsultationsHelper

Defined in:
decidim-consultations/app/helpers/decidim/consultations/consultations_helper.rb

Instance Method Summary collapse

Instance Method Details

#display_take_part_button_for(question) ⇒ Object

Returns a link to the given question with different text/appearence depending on whether the user has voted it or not.


18
19
20
21
22
23
24
25
26
27
28
# File 'decidim-consultations/app/helpers/decidim/consultations/consultations_helper.rb', line 18

def display_take_part_button_for(question)
  if current_user && question.voted_by?(current_user)
    i18n_text = t("already_voted", scope: "decidim.questions.vote_button")
    css = "button expanded button--sc success"
  else
    i18n_text = t("take_part", scope: "decidim.consultations.question")
    css = "button expanded button--sc"
  end

  link_to(i18n_text, decidim_consultations.question_path(question), class: css)
end

#options_for_state_filterObject

Returns options for state filter selector.


7
8
9
10
11
12
13
14
# File 'decidim-consultations/app/helpers/decidim/consultations/consultations_helper.rb', line 7

def options_for_state_filter
  [
    ["all", t("consultations.filters.all", scope: "decidim")],
    ["active", t("consultations.filters.active", scope: "decidim")],
    ["upcoming", t("consultations.filters.upcoming", scope: "decidim")],
    ["finished", t("consultations.filters.finished", scope: "decidim")]
  ]
end