Module: Decidim::Consultations::QuestionsHelper
- Defined in:
- app/helpers/decidim/consultations/questions_helper.rb
Overview
Helper for questions controller
Instance Method Summary collapse
- #authorized_vote_modal_button(question, html_options, &block) ⇒ Object
-
#display_next_previous_button(direction, optional_classes = "") ⇒ Object
Returns a link to the next/previous question if found.
Instance Method Details
#authorized_vote_modal_button(question, html_options, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/decidim/consultations/questions_helper.rb', line 31 def (question, , &block) return if current_user && (:vote, resource: nil, permissions_holder: question).ok? tag = "button" ||= {} if current_user ["data-open"] = "authorizationModal" ["data-open-url"] = decidim_consultations.(question) else ["data-open"] = "loginModal" end ["onclick"] = "event.preventDefault();" send("#{tag}_to", "", , &block) end |
#display_next_previous_button(direction, optional_classes = "") ⇒ Object
Returns a link to the next/previous question if found. Else, returns a disabled link to the current question.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/decidim/consultations/questions_helper.rb', line 9 def (direction, optional_classes = "") # rubocop: disable Style/StringConcatenation as we don't want the string to be frozen css = "card__button button hollow " + optional_classes # rubocop: enable Style/StringConcatenation # Do not show anything if is a lonely question return unless previous_published_question || next_published_question case direction when :previous i18n_text = t("previous_button", scope: "decidim.questions") question = previous_published_question || current_question css << " disabled" if previous_published_question.nil? when :next i18n_text = t("next_button", scope: "decidim.questions") question = next_published_question || current_question css << " disabled" if next_published_question.nil? end link_to(i18n_text, decidim_consultations.question_path(question), class: css) end |