diff --git a/app/helpers/interruption_screen_helper.rb b/app/helpers/interruption_screen_helper.rb
index 939f70bb2..43d6b1da0 100644
--- a/app/helpers/interruption_screen_helper.rb
+++ b/app/helpers/interruption_screen_helper.rb
@@ -29,6 +29,10 @@ module InterruptionScreenHelper
I18n.t(title_text["translation"], **translation_params).to_s
end
+ def soft_validation_affected_questions(question, log)
+ question.affected_question_ids.map { |question_id| log.form.get_question(question_id, log) }
+ end
+
private
def get_value_from_argument(log, argument)
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index d4b7c9d76..7b04b48f8 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -4,7 +4,8 @@ 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
+ :check_answers_card_number, :unresolved_hint_text, :question_number, :plain_label,
+ :affected_question_ids
module GuidancePosition
TOP = 1
@@ -43,6 +44,7 @@ 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
@@ -124,6 +126,10 @@ class Form::Question
"/#{log.model_name.param_key.dasherize}s/#{log.id}/#{page_id.to_s.dasherize}?referrer=check_answers"
end
+ def interruption_action_href(log, page_id)
+ "/#{log.model_name.param_key.dasherize}s/#{log.id}/#{page_id.to_s.dasherize}"
+ end
+
def unanswered?(log)
return answer_options.keys.none? { |key| value_is_yes?(log[key]) } if type == "checkbox"
diff --git a/app/views/form/_interruption_screen_question.html.erb b/app/views/form/_interruption_screen_question.html.erb
index c5da48a92..07081c005 100644
--- a/app/views/form/_interruption_screen_question.html.erb
+++ b/app/views/form/_interruption_screen_question.html.erb
@@ -1,22 +1,48 @@
<%= govuk_panel(
- title_text: display_title_text(title_text, lettings_log),
classes: "app-panel--interruption",
) do %>
-
<%= display_informative_text(informative_text, lettings_log) %>
- <%= f.govuk_radio_buttons_fieldset question.id.to_sym,
- legend: { text: question.header },
- hint: { text: question.hint_text&.html_safe } do %>
- <% question.answer_options.map do |key, options| %>
- <% if key.starts_with?("divider") %>
- <%= f.govuk_radio_divider %>
- <% else %>
- <%= f.govuk_radio_button question.id,
- key,
- label: { text: options["value"] },
- hint: { text: options["hint"] },
- **stimulus_html_attributes(question) %>
+ <%= display_title_text(title_text, lettings_log) %>
+ <%= display_informative_text(informative_text, lettings_log) %>
+ <%= question.header %>
+ <%= question.hint_text&.html_safe %>
+
+<% end %>
+
+
+ Make sure these answers are all correct
+
+<%= govuk_summary_list do |summary_list| %>
+ <% soft_validation_affected_questions(question, @log).each do |affected_question| %>
+ <% summary_list.row do |row| %>
+ <% row.key { get_question_label(affected_question) } %>
+ <% row.value do %>
+ <%= simple_format(
+ get_answer_label(affected_question, @log),
+ wrapper_tag: "span",
+ class: "govuk-!-margin-right-4",
+ ) %>
+ <% extra_value = affected_question.get_extra_check_answer_value(@log) %>
+ <% if extra_value && affected_question.answer_label(@log, current_user).present? %>
+ <%= simple_format(
+ extra_value,
+ wrapper_tag: "span",
+ class: "govuk-!-font-weight-regular app-!-colour-muted",
+ ) %>
+ <% end %>
+ <% affected_question.get_inferred_answers(@log).each do |inferred_answer| %>
+ <%= inferred_answer %>
+ <% end %>
+ <% end %>
+ <% if @log.collection_period_open? %>
+ <% row.action(
+ text: affected_question.action_text(@log),
+ href: affected_question.interruption_action_href(@log, affected_question.page.id),
+ visually_hidden_text: affected_question.check_answer_label.to_s.downcase,
+ ) %>
<% end %>
<% end %>
<% end %>
- <%= f.govuk_submit "Save and continue", accesskey: "s", class: "app-button--inverse govuk-!-margin-bottom-0" %>
<% end %>
+
+<%= f.hidden_field question.id, value: "0" %>
+<%= f.govuk_submit "Save and continue" %>
diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb
index 9b4d14d9d..7a28c4eaf 100644
--- a/app/views/form/page.html.erb
+++ b/app/views/form/page.html.erb
@@ -7,7 +7,7 @@
<%= form_with model: @log, url: request.original_url, method: "post", local: true do |f| %>
-
">
+
<% remove_other_page_errors(@log, @page) %>
<%= f.govuk_error_summary %>
diff --git a/spec/features/form/validations_spec.rb b/spec/features/form/validations_spec.rb
index 12e5bb657..6c02855a2 100644
--- a/spec/features/form/validations_spec.rb
+++ b/spec/features/form/validations_spec.rb
@@ -138,28 +138,33 @@ RSpec.describe "validations" do
let(:income_over_soft_limit) { 750 }
let(:income_under_soft_limit) { 700 }
- it "prompts the user to confirm the value is correct with an interruption screen" do
+ before do
visit("/lettings-logs/#{lettings_log.id}/net-income")
fill_in("lettings-log-earnings-field", with: income_over_soft_limit)
choose("lettings-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
+ end
+
+ it "prompts the user to confirm the value is correct with an interruption screen" do
expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income-value-check")
expect(page).to have_content("Net income is outside the expected range based on the lead tenant’s working situation")
expect(page).to have_content("You told us the lead tenant’s working situation is: full-time – 30 hours or more")
expect(page).to have_content("The household income you have entered is £750.00 every week")
- choose("lettings-log-net-income-value-check-0-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income-uc-proportion")
end
- it "returns the user to the previous question if they do not confirm the value as correct on the interruption screen" do
- visit("/lettings-logs/#{lettings_log.id}/net-income")
- fill_in("lettings-log-earnings-field", with: income_over_soft_limit)
+ it "allows to fix the questions that trigger the soft validation" do
+ expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income-value-check")
+ expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/net-income").twice
+ expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/person-1-working-situation")
+ expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income-value-check")
+ click_link("Change", href: "/lettings-logs/#{lettings_log.id}/net-income", match: :first)
+ expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income")
+ fill_in("lettings-log-earnings-field", with: income_under_soft_limit)
choose("lettings-log-incfreq-1-field", allow_label_click: true)
click_button("Save and continue")
- choose("lettings-log-net-income-value-check-1-field", allow_label_click: true)
- click_button("Save and continue")
- expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income")
+ expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/net-income-uc-proportion") # will need change to the interruption screen
end
end
end
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 139ac8399..f483627f5 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -770,7 +770,8 @@
"1": {
"value": "No"
}
- }
+ },
+ "affected_question_ids": ["ecstat1", "incfreq", "earnings"]
}
}
},