Browse Source

Move affected_question_ids to page, because we reuse questions so they might have different affected_question_ids

pull/1584/head
Kat 3 years ago
parent
commit
86139e051d
  1. 2
      app/helpers/interruption_screen_helper.rb
  2. 4
      app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb
  3. 4
      app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb
  4. 4
      app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb
  5. 4
      app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb
  6. 4
      app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb
  7. 4
      app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb
  8. 4
      app/models/form/lettings/questions/pregnancy_value_check.rb
  9. 3
      app/models/form/page.rb
  10. 4
      app/models/form/question.rb
  11. 6
      spec/fixtures/forms/2021_2022.json

2
app/helpers/interruption_screen_helper.rb

@ -30,7 +30,7 @@ module InterruptionScreenHelper
end
def soft_validation_affected_questions(question, log)
question.affected_question_ids.map { |question_id| log.form.get_question(question_id, log) }
question.page.affected_question_ids.map { |question_id| log.form.get_question(question_id, log) }
end
private

4
app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb

@ -16,4 +16,8 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadAgeValueCheck < ::For
def questions
@questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)]
end
def affected_question_ids
%w[preg_occ sex1 sex2 sex3 sex4 sex5 sex6 sex7 sex8]
end
end

4
app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb

@ -16,4 +16,8 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck < ::
def questions
@questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)]
end
def affected_question_ids
%w[preg_occ sex1 sex2 sex3 sex4 sex5 sex6 sex7 sex8]
end
end

4
app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb

@ -16,4 +16,8 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadValueCheck < ::Form::
def questions
@questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)]
end
def affected_question_ids
%w[preg_occ sex1 sex2 sex3 sex4 sex5 sex6 sex7 sex8]
end
end

4
app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb

@ -16,4 +16,8 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck < ::F
def questions
@questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)]
end
def affected_question_ids
%w[preg_occ sex1 sex2 sex3 sex4 sex5 sex6 sex7 sex8]
end
end

4
app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb

@ -16,4 +16,8 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck < ::Form
def questions
@questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)]
end
def affected_question_ids
%w[preg_occ sex1 sex2 sex3 sex4 sex5 sex6 sex7 sex8]
end
end

4
app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb

@ -16,4 +16,8 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdValueCheck < ::Form::Page
def questions
@questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)]
end
def affected_question_ids
%w[preg_occ sex1 sex2 sex3 sex4 sex5 sex6 sex7 sex8]
end
end

4
app/models/form/lettings/questions/pregnancy_value_check.rb

@ -11,8 +11,4 @@ class Form::Lettings::Questions::PregnancyValueCheck < ::Form::Question
end
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze
def affected_question_ids
%w[preg_occ sex1 sex2 sex3 sex4 sex5 sex6 sex7 sex8]
end
end

3
app/models/form/page.rb

@ -1,7 +1,7 @@
class Form::Page
attr_accessor :id, :header, :header_partial, :description, :questions, :depends_on, :title_text,
:informative_text, :subsection, :hide_subsection_label, :next_unresolved_page_id,
:skip_text
:skip_text, :affected_question_ids
def initialize(id, hsh, subsection)
@id = id
@ -17,6 +17,7 @@ class Form::Page
@hide_subsection_label = hsh["hide_subsection_label"]
@next_unresolved_page_id = hsh["next_unresolved_page_id"]
@skip_text = hsh["skip_text"]
@affected_question_ids = hsh["affected_question_ids"] || []
end
end

4
app/models/form/question.rb

@ -4,8 +4,7 @@ class Form::Question
:conditional_for, :readonly, :answer_options, :page, :check_answer_label,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
:guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived,
:check_answers_card_number, :unresolved_hint_text, :question_number, :plain_label,
:affected_question_ids
:check_answers_card_number, :unresolved_hint_text, :question_number, :plain_label
module GuidancePosition
TOP = 1
@ -44,7 +43,6 @@ class Form::Question
@question_number = hsh["question_number"]
@plain_label = hsh["plain_label"]
@disable_clearing_if_not_routed_or_dynamic_answer_options = hsh["disable_clearing_if_not_routed_or_dynamic_answer_options"]
@affected_question_ids = hsh["affected_question_ids"] || []
end
end

6
spec/fixtures/forms/2021_2022.json vendored

@ -770,10 +770,10 @@
"1": {
"value": "No"
}
},
"affected_question_ids": ["ecstat1", "incfreq", "earnings"]
}
}
}
},
"affected_question_ids": ["ecstat1", "incfreq", "earnings"]
},
"net_income_uc_proportion": {
"questions": {

Loading…
Cancel
Save