diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 5c5b31483..31ee94287 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -7,7 +7,7 @@ class FormController < ApplicationController if @case_log @page = @case_log.form.get_page(params[:case_log][:page]) responses_for_page = responses_for_page(@page) - if @case_log.update(responses_for_page) && @case_log.has_no_unresolved_soft_errors? + if @case_log.update(responses_for_page) if @case_log.form.is_last_question?(@page, @case_log.form.subsection_for_page(@page), @case_log) redirect_to(case_logs_path) else diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 2b1ffe6cd..2b8e40e91 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -16,7 +16,20 @@ class CaseLogValidator < ActiveModel::Validator end class CaseLog < ApplicationRecord - include Validations::SoftValidations + # include Validations::SoftValidations + ALLOWED_INCOME_RANGES = { + 1 => OpenStruct.new(soft_min: 143, soft_max: 730, hard_min: 90, hard_max: 1230), + 0 => OpenStruct.new(soft_min: 67, soft_max: 620, hard_min: 50, hard_max: 950), + 2 => OpenStruct.new(soft_min: 80, soft_max: 480, hard_min: 40, hard_max: 990), + 3 => OpenStruct.new(soft_min: 50, soft_max: 370, hard_min: 10, hard_max: 450), + 4 => OpenStruct.new(soft_min: 50, soft_max: 380, hard_min: 10, hard_max: 690), + 5 => OpenStruct.new(soft_min: 53, soft_max: 540, hard_min: 10, hard_max: 890), + 6 => OpenStruct.new(soft_min: 47, soft_max: 460, hard_min: 10, hard_max: 1300), + 7 => OpenStruct.new(soft_min: 54, soft_max: 460, hard_min: 10, hard_max: 820), + 8 => OpenStruct.new(soft_min: 50, soft_max: 450, hard_min: 10, hard_max: 750), + 9 => OpenStruct.new(soft_min: 50, soft_max: 580, hard_min: 10, hard_max: 1040), + 10 => OpenStruct.new(soft_min: 47, soft_max: 730, hard_min: 10, hard_max: 1300), + }.freeze has_paper_trail @@ -111,6 +124,10 @@ class CaseLog < ApplicationRecord incfreq == 2 end + def net_income_soft_validation_triggered? + true + end + def given_reasonable_preference? reasonpref == 1 end diff --git a/app/models/form/page.rb b/app/models/form/page.rb index ad8a4a8af..c917d71ff 100644 --- a/app/models/form/page.rb +++ b/app/models/form/page.rb @@ -1,6 +1,6 @@ class Form::Page attr_accessor :id, :header, :description, :questions, :soft_validations, - :depends_on, :subsection, :hide_subsection_label + :depends_on, :title_text, :subsection, :hide_subsection_label def initialize(id, hsh, subsection) @id = id @@ -8,6 +8,7 @@ class Form::Page @description = hsh["description"] @questions = hsh["questions"].map { |q_id, q| Form::Question.new(q_id, q, self) } @depends_on = hsh["depends_on"] + @title_text = hsh["title_text"] @hide_subsection_label = hsh["hide_subsection_label"] @soft_validations = hsh["soft_validations"]&.map { |sv_id, s| Form::Question.new(sv_id, s, self) } @subsection = subsection diff --git a/app/views/form/_interruption_screen_question.html.erb b/app/views/form/_interruption_screen_question.html.erb new file mode 100644 index 000000000..0ed405034 --- /dev/null +++ b/app/views/form/_interruption_screen_question.html.erb @@ -0,0 +1,40 @@ +<%= govuk_panel( + title_text: title_text, + classes: 'app-panel--interruption', +) do %> + <%= f.govuk_radio_buttons_fieldset question.id.to_sym, + caption: caption(caption_text, page_header, conditional), + legend: legend(question, page_header, conditional), + 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 %> + <% conditional_question = find_conditional_question(@page, question, key) %> + <% if conditional_question.nil? %> + <%= f.govuk_radio_button question.id, + key, + label: { text: options['value'] }, + hint: { text: options['hint'] }, + **stimulus_html_attributes(question) + %> + <% else %> + <%= f.govuk_radio_button question.id, + key, + label: { text: options['value'] }, + hint: { text: options['hint'] }, + **stimulus_html_attributes(question) do %> + <%= render partial: "#{conditional_question.type}_question", locals: { + question: conditional_question, + caption_text: caption_text, + page_header: page_header, + f: f, + conditional: true + } %> + <% end %> + <% end %> + <% end %> + <% end %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index b3a11b5fb..9c7ab4b4f 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -38,7 +38,11 @@ <% if question.read_only? %>