Browse Source

Leave JS hooks until text conditionals are updated as well

pull/235/head
baarkerlounger 3 years ago
parent
commit
406c5c8ee3
  1. 14
      app/helpers/question_attribute_helper.rb

14
app/helpers/question_attribute_helper.rb

@ -1,7 +1,8 @@
module QuestionAttributeHelper module QuestionAttributeHelper
def stimulus_html_attributes(question) def stimulus_html_attributes(question)
attribs = [ attribs = [
numeric_question_html_attributes(question) numeric_question_html_attributes(question),
conditional_html_attributes(question),
] ]
merge_controller_attributes(*attribs) merge_controller_attributes(*attribs)
end end
@ -19,6 +20,17 @@ private
"data-calculated": question.fields_to_add.to_json, "data-calculated": question.fields_to_add.to_json,
} }
end end
# TODO: remove this once all conditional questions no longer need JS
def conditional_html_attributes(question)
return {} if question.conditional_for.blank? || question.type == "radio"
{
"data-controller": "conditional-question",
"data-action": "conditional-question#displayConditional",
"data-info": question.conditional_for.to_json,
}
end
end end
def merge_controller_attributes(*args) def merge_controller_attributes(*args)

Loading…
Cancel
Save