Sha256: c1b7f3c133a39cf620883c90c7932406bde4465a538e1126d383ee9a9006397f

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Decidim
  module Consultations
    module ConsultationsHelper
      # Returns  options for state filter selector.
      def options_for_date_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

      # Returns a link to the given question with different text/appearence
      # depending on whether the user has voted it or not.
      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
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-consultations-0.27.9 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.8 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.7 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.6 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.5 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.4 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.3 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.2 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.1 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.0 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.0.rc2 app/helpers/decidim/consultations/consultations_helper.rb
decidim-consultations-0.27.0.rc1 app/helpers/decidim/consultations/consultations_helper.rb