diff --git a/app/helpers/question_view_helper.rb b/app/helpers/question_view_helper.rb index fc308b835..1b9ffbb20 100644 --- a/app/helpers/question_view_helper.rb +++ b/app/helpers/question_view_helper.rb @@ -7,7 +7,7 @@ module QuestionViewHelper def legend(question, page_header, conditional) { - text: question.header.html_safe, + text: question.header_partial.present? ? question.header_partial.html_safe : question.header.html_safe, size: label_size(page_header, conditional), tag: label_tag(page_header, conditional), } diff --git a/app/models/form/page.rb b/app/models/form/page.rb index 3ee1932cc..5bf1e1618 100644 --- a/app/models/form/page.rb +++ b/app/models/form/page.rb @@ -1,5 +1,5 @@ class Form::Page - attr_accessor :id, :header, :description, :questions, :depends_on, :title_text, + attr_accessor :id, :header, :header_partial, :description, :questions, :depends_on, :title_text, :informative_text, :subsection, :hide_subsection_label def initialize(id, hsh, subsection) @@ -7,6 +7,7 @@ class Form::Page @subsection = subsection if hsh @header = hsh["header"] + @header_partial = hsh["header_partial"] @description = hsh["description"] @questions = hsh["questions"].map { |q_id, q| Form::Question.new(q_id, q, self) } @depends_on = hsh["depends_on"] diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 227e6079e..ff75dead8 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -1,5 +1,5 @@ class Form::Question - attr_accessor :id, :header, :hint_text, :description, :questions, + attr_accessor :id, :header, :header_partial, :hint_text, :description, :questions, :type, :min, :max, :step, :width, :fields_to_add, :result_field, :conditional_for, :readonly, :answer_options, :page, :check_answer_label, :inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value, @@ -16,6 +16,7 @@ class Form::Question if hsh @check_answer_label = hsh["check_answer_label"] @header = hsh["header"] + @header_partial = hsh["header_partial"] @guidance_partial = hsh["guidance_partial"] @guidance_position = GuidancePosition::TOP @hint_text = hsh["hint_text"] diff --git a/app/models/form/sales/pages/person2_known.rb b/app/models/form/sales/pages/person2_known.rb new file mode 100644 index 000000000..a94625694 --- /dev/null +++ b/app/models/form/sales/pages/person2_known.rb @@ -0,0 +1,21 @@ +class Form::Sales::Pages::Person2Known < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "person_2_known" + @header_partial = "personx_known_page" + @header = "" + @description = "" + @subsection = subsection + @depends_on = [ + { "hholdcount" => 2 }, + { "hholdcount" => 3 }, + { "hholdcount" => 4 }, + ] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Person2Known.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/person2_known.rb b/app/models/form/sales/questions/person2_known.rb new file mode 100644 index 000000000..40306c64b --- /dev/null +++ b/app/models/form/sales/questions/person2_known.rb @@ -0,0 +1,25 @@ +class Form::Sales::Questions::Person2Known < ::Form::Question + def initialize(id, hsh, page) + super + @id = "details_known_2" + @check_answer_label = "Details known for person 2" + @header = "Do you know the details for person 2? +" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @page = page + @hint_text = "" + @hidden_in_check_answers = { + "depends_on" => [ + { + "details_known_2" => 1, + }, + ], + } + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + }.freeze +end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index c8d4ae8d6..b9d941a38 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -29,6 +29,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self), Form::Sales::Pages::Person1Age.new(nil, nil, self), + Form::Sales::Pages::Person2Known.new(nil, nil, self), ] end end diff --git a/app/views/form/headers/_personx_known_page.erb b/app/views/form/headers/_personx_known_page.erb new file mode 100644 index 000000000..197750515 --- /dev/null +++ b/app/views/form/headers/_personx_known_page.erb @@ -0,0 +1 @@ +You have given us the details for 1 of the <%= hholdcount %> other people in the household diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index 8d90f12b9..686e2d947 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -11,11 +11,14 @@ <% remove_other_page_errors(@log, @page) %> <%= f.govuk_error_summary %> - <% if @page.header.present? %> + <% if @page.header.present? || @page.header_partial.present? %>