Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
module ConditionalQuestionsHelper
|
|
|
|
def conditional_questions_for_page(page)
|
|
|
|
page.questions.map(&:conditional_for).compact.map(&:keys).flatten
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_conditional_question(page, question, answer_value)
|
|
|
|
return if question.conditional_for.nil?
|
|
|
|
|
|
|
|
conditional_key = question.conditional_for.find { |_, conditional_value|
|
|
|
|
conditional_value.map(&:to_s).include? answer_value.to_s
|
|
|
|
}&.first
|
|
|
|
page.questions.find { |q| q.id == conditional_key }
|
|
|
|
end
|
|
|
|
|
|
|
|
def display_question_key_div(page, question)
|
|
|
|
"style='display:none;'".html_safe if conditional_questions_for_page(page).include?(question.id) || question.requires_js
|
|
|
|
end
|
|
|
|
end
|