Class: Decidim::Forms::Admin::DisplayConditionForm
- Inherits:
-
Decidim::Form
- Object
- Decidim::Form
- Decidim::Forms::Admin::DisplayConditionForm
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/forms/admin/display_condition_form.rb
Overview
This class holds a Form to update questionnaire questions from Decidim’s admin panel.
Instance Method Summary collapse
-
#answer_option ⇒ Object
Finds the Answer Option from the given decidim_answer_option_id.
- #answer_options ⇒ Object
-
#condition_question ⇒ Object
Finds the Condition Question from the given decidim_condition_question_id.
-
#question ⇒ Object
Finds the Question from the given decidim_question_id.
- #questions_for_select(questionnaire, id) ⇒ Object
- #to_param ⇒ Object
Instance Method Details
#answer_option ⇒ Object
Finds the Answer Option from the given decidim_answer_option_id
Returns a Decidim::Forms::AnswerOption
71 72 73 |
# File 'app/forms/decidim/forms/admin/display_condition_form.rb', line 71 def answer_option @answer_option ||= AnswerOption.find_by(id: decidim_answer_option_id) end |
#answer_options ⇒ Object
35 36 37 38 39 |
# File 'app/forms/decidim/forms/admin/display_condition_form.rb', line 35 def return [] if condition_question.blank? condition_question. end |
#condition_question ⇒ Object
Finds the Condition Question from the given decidim_condition_question_id
Returns a Decidim::Forms::Question
64 65 66 |
# File 'app/forms/decidim/forms/admin/display_condition_form.rb', line 64 def condition_question @condition_question ||= Question.find_by(id: decidim_condition_question_id) end |
#question ⇒ Object
Finds the Question from the given decidim_question_id
Returns a Decidim::Forms::Question
57 58 59 |
# File 'app/forms/decidim/forms/admin/display_condition_form.rb', line 57 def question @question ||= Question.find_by(id: decidim_question_id) end |
#questions_for_select(questionnaire, id) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/forms/decidim/forms/admin/display_condition_form.rb', line 41 def questions_for_select(questionnaire, id) questionnaire.questions.map do |question| [ question.translated_body, question.id, { "disabled" => (question.question_type == "sorting" || question.id == id), "data-type" => question.question_type } ] end end |
#to_param ⇒ Object
29 30 31 32 33 |
# File 'app/forms/decidim/forms/admin/display_condition_form.rb', line 29 def to_param return id if id.present? "questionnaire-display-condition-id" end |