Module: Decidim::Forms::Admin::ApplicationHelper

Defined in:
decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb

Overview

Custom helpers, scoped to the forms engine.

Instance Method Summary collapse

Instance Method Details

#dynamic_title(title, **options) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
# File 'decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb', line 27

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: data) do
    truncate translated_attribute(title), length: options[:max_length], omission: options[:omission]
  end
end

#tabs_id_for_question(question) ⇒ Object


11
12
13
# File 'decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb', line 11

def tabs_id_for_question(question)
  "questionnaire_question_#{question.to_param}"
end

#tabs_id_for_question_answer_option(question, answer_option) ⇒ Object


15
16
17
# File 'decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb', line 15

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

#tabs_id_for_question_display_condition(question, display_condition) ⇒ Object


19
20
21
# File 'decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb', line 19

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

#tabs_id_for_question_matrix_row(question, matrix_row) ⇒ Object


23
24
25
# File 'decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb', line 23

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

#template?(questionnaire_for) ⇒ Boolean

Returns:

  • (Boolean)

39
40
41
42
43
# File 'decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb', line 39

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

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

#templates_defined?Boolean

Returns:

  • (Boolean)

45
46
47
# File 'decidim-forms/app/helpers/decidim/forms/admin/application_helper.rb', line 45

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