Browse Source

get previous page that was routed to and display the same error for both soft validations

pull/434/head
Kat 3 years ago
parent
commit
d6fae05cb6
  1. 4
      app/models/case_log.rb
  2. 9
      app/models/form.rb
  3. 30
      config/forms/2021_2022.json
  4. 2
      db/migrate/20220328133331_add_rent_value_check.rb
  5. 2
      db/schema.rb

4
app/models/case_log.rb

@ -124,6 +124,10 @@ class CaseLog < ApplicationRecord
net_income_in_soft_min_range? || net_income_in_soft_max_range?
end
def rent_in_soft_validation_range?
rent_in_soft_min_range? || rent_in_soft_max_range?
end
def given_reasonable_preference?
reasonpref == 1
end

9
app/models/form.rb

@ -37,7 +37,7 @@ class Form
def next_page(page, case_log)
page_ids = subsection_for_page(page).pages.map(&:id)
page_index = page_ids.index(page.id)
page_id = page.id.include?("value_check") && case_log[page.id] == 1 ? page_ids[page_index - 1] : page_ids[page_index + 1]
page_id = page.id.include?("value_check") && case_log[page.questions[0].id] == 1 ? previous_page(page_ids, page_index, case_log) : page_ids[page_index + 1]
nxt_page = get_page(page_id)
return :check_answers if nxt_page.nil?
@ -144,4 +144,11 @@ class Form
subsection_ids = subsections.map(&:id)
subsection.id == subsection_ids[subsection_ids.length - 1] && next_page(page, case_log) == :check_answers
end
def previous_page(page_ids, page_index, case_log)
prev_page = get_page(page_ids[page_index - 1])
return prev_page.id if prev_page.routed_to?(case_log)
previous_page(page_ids, page_index - 1, case_log)
end
end

30
config/forms/2021_2022.json

@ -4573,7 +4573,7 @@
}
}
},
"check_income_amount": {
"net_income_value_check": {
"depends_on": [{ "net_income_soft_validation_triggered?": true }],
"title_text": "Net income is outside the expected range based on the main tenant’s working situation",
"informative_text": {
@ -5568,33 +5568,9 @@
}
]
},
"check_min_rent_amount": {
"depends_on": [{ "rent_in_soft_min_range?": true }],
"title_text": "Rent value is under the expected range",
"informative_text": {
"translation": "soft_validations.rent.min_max.hint_text",
"argument": ["brent"]
},
"questions": {
"rent_value_check": {
"check_answer_label": "Rent soft validation",
"hidden_in_check_answers": true,
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value":"Yes"
},
"1": {
"value":"No"
}
}
}
}
},
"check_max_rent_amount": {
"depends_on": [{ "rent_in_soft_max_range?": true }],
"title_text": "Rent value is over the expected range",
"depends_on": [{ "rent_in_soft_validation_range?": true }],
"title_text": "Rent value is outside of the expected range",
"informative_text": {
"translation": "soft_validations.rent.min_max.hint_text",
"argument": ["brent"]

2
db/migrate/20220328133331_add_rent_value_check.rb

@ -1,5 +1,5 @@
class AddRentValueCheck < ActiveRecord::Migration[7.0]
def change
add_column :case_logs, :rent_value_check, :boolean
add_column :case_logs, :rent_value_check, :integer
end
end

2
db/schema.rb

@ -231,7 +231,7 @@ ActiveRecord::Schema[7.0].define(version: 202202071123100) do
t.string "relat6"
t.string "relat7"
t.string "relat8"
t.boolean "rent_value_check"
t.integer "rent_value_check"
t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_case_logs_on_owning_organisation_id"
end

Loading…
Cancel
Save