Sha256: e8217ed9a046c49fe17f2383db365ef0e89c629a149221a3a9f12cd58db9b4e6

Contents?: true

Size: 1.17 KB

Versions: 20

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Decidim
  module Surveys
    module Admin
      # Custom helpers, scoped to the surveys engine.
      #
      module ApplicationHelper
        def tabs_id_for_question(question)
          return "survey-question-#{question.id}" if question.persisted?
          "${tabsId}"
        end

        def tabs_id_for_question_answer_option(question, idx)
          return "survey-question-answer-option-#{question.id}-#{idx}" if question.present?
          "${tabsId}"
        end

        def label_for_question(survey, _question)
          survey.questions_editable? ? "#{icon("move")} #{t(".question")}".html_safe : t(".question")
        end

        def mandatory_id_for_question(question)
          return "survey_questions_#{question.id}_mandatory" if question.persisted?
          "${tabsId}_mandatory"
        end

        def question_type_id_for_question(question)
          return "survey_questions_#{question.id}_question_type" if question.persisted?
          "${tabsId}_question_type"
        end

        def disabled_for_question(survey, question)
          !question.persisted? || !survey.questions_editable?
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
decidim-surveys-0.5.1 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.5.1 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.5.0 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.5.0 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.4.4 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.4.4 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.4.3 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.4.2 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.4.1 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.4.3 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.4.2 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.4.1 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.4.0 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.4.0 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.3.2 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.3.2 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.3.1 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.3.1 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb
decidim-surveys-0.3.0 app/helpers/decidim/surveys/admin/application_helper.rb
decidim-0.3.0 decidim-surveys/app/helpers/decidim/surveys/admin/application_helper.rb