Sha256: a560d318c5411c8fdc0e735ad06c0a80093648523ebe1ea9304f5691a04d70bd

Contents?: true

Size: 1.64 KB

Versions: 13

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

# i18n-tasks-use t('decidim.templates.admin.questionnaire_templates.form.title')

module Decidim
  module Forms
    module Admin
      # Custom helpers, scoped to the forms engine.
      #
      module ApplicationHelper
        def tabs_id_for_question(question)
          "questionnaire_question_#{question.to_param}"
        end

        def tabs_id_for_question_answer_option(question, answer_option)
          "questionnaire_question_#{question.to_param}_answer_option_#{answer_option.to_param}"
        end

        def tabs_id_for_question_display_condition(question, display_condition)
          "questionnaire_question_#{question.to_param}_display_condition_#{display_condition.to_param}"
        end

        def tabs_id_for_question_matrix_row(question, matrix_row)
          "questionnaire_question_#{question.to_param}_matrix_row_#{matrix_row.to_param}"
        end

        def dynamic_title(title, **options)
          data = {
            "max-length" => options[:max_length],
            "omission" => options[:omission],
            "placeholder" => options[:placeholder],
            "locale" => I18n.locale
          }
          tag.span(class: options[:class], data:) do
            truncate translated_attribute(title), length: options[:max_length], omission: options[:omission]
          end
        end

        def template?(questionnaire_for)
          return unless defined? Decidim::Templates::Template

          questionnaire_for.is_a? Decidim::Templates::Template
        end

        def templates_defined?
          defined? Decidim::Templates::Admin::Concerns::Templatable
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-forms-0.29.1 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.28.4 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.29.0 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.28.3 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.29.0.rc4 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.29.0.rc3 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.29.0.rc2 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.29.0.rc1 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.28.2 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.28.1 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.28.0 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.28.0.rc5 app/helpers/decidim/forms/admin/application_helper.rb
decidim-forms-0.28.0.rc4 app/helpers/decidim/forms/admin/application_helper.rb