|
|
@ -19,7 +19,6 @@ class Form::Question |
|
|
|
@fields_to_add = hsh["fields-to-add"] |
|
|
|
@fields_to_add = hsh["fields-to-add"] |
|
|
|
@result_field = hsh["result-field"] |
|
|
|
@result_field = hsh["result-field"] |
|
|
|
@readonly = hsh["readonly"] |
|
|
|
@readonly = hsh["readonly"] |
|
|
|
@answer_options = hsh["answer_options"] |
|
|
|
|
|
|
|
@conditional_for = hsh["conditional_for"] |
|
|
|
@conditional_for = hsh["conditional_for"] |
|
|
|
@inferred_answers = hsh["inferred_answers"] |
|
|
|
@inferred_answers = hsh["inferred_answers"] |
|
|
|
@inferred_check_answers_value = hsh["inferred_check_answers_value"] |
|
|
|
@inferred_check_answers_value = hsh["inferred_check_answers_value"] |
|
|
@ -29,6 +28,7 @@ class Form::Question |
|
|
|
@requires_js = hsh["requires_js"] |
|
|
|
@requires_js = hsh["requires_js"] |
|
|
|
@fields_added = hsh["fields_added"] |
|
|
|
@fields_added = hsh["fields_added"] |
|
|
|
@page = page |
|
|
|
@page = page |
|
|
|
|
|
|
|
@answer_options = hsh["answer_options_lookup"] ? answer_options_from_lookup(hsh["answer_options_lookup"]) : hsh["answer_options"] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
delegate :subsection, to: :page |
|
|
|
delegate :subsection, to: :page |
|
|
@ -164,6 +164,14 @@ class Form::Question |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def answer_options_from_lookup(lookup) |
|
|
|
|
|
|
|
values = {} |
|
|
|
|
|
|
|
values[""] = "Select an option" |
|
|
|
|
|
|
|
records = Object.const_get((lookup["class"]).to_s).send((lookup["scope"]).to_s) |
|
|
|
|
|
|
|
records.each { |record| values[record.send((lookup["id"]).to_s)] = record.send((lookup["label"]).to_s) } |
|
|
|
|
|
|
|
values |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def selected_answer_option_is_derived?(case_log) |
|
|
|
def selected_answer_option_is_derived?(case_log) |
|
|
|
selected_option = answer_options&.dig(case_log[id].to_s.presence) |
|
|
|
selected_option = answer_options&.dig(case_log[id].to_s.presence) |
|
|
|
selected_option.is_a?(Hash) && selected_option["depends_on"] && form.depends_on_met(selected_option["depends_on"], case_log) |
|
|
|
selected_option.is_a?(Hash) && selected_option["depends_on"] && form.depends_on_met(selected_option["depends_on"], case_log) |
|
|
|