From 778fb7ba32f7a6a217bcf9746137647d110f5897 Mon Sep 17 00:00:00 2001 From: Kat Date: Fri, 7 Jul 2023 13:26:26 +0100 Subject: [PATCH] WIP duplicate page example --- app/models/form/lettings/pages/duplicate_page.rb | 10 ++++++++++ app/models/form/lettings/questions/duplicate.rb | 10 ++++++++++ .../form/lettings/subsections/property_information.rb | 1 + app/models/form/page.rb | 3 ++- app/views/form/_duplicate_page.html.erb | 5 +++++ app/views/form/page.html.erb | 4 ++++ 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/models/form/lettings/pages/duplicate_page.rb create mode 100644 app/models/form/lettings/questions/duplicate.rb create mode 100644 app/views/form/_duplicate_page.html.erb diff --git a/app/models/form/lettings/pages/duplicate_page.rb b/app/models/form/lettings/pages/duplicate_page.rb new file mode 100644 index 000000000..2c7d65966 --- /dev/null +++ b/app/models/form/lettings/pages/duplicate_page.rb @@ -0,0 +1,10 @@ +class Form::Lettings::Pages::DuplicatePage < ::Form::Page + def initialize(id, hsh, section) + super + @page_type = "duplicate" + end + + def questions + @questions ||= [Form::Lettings::Questions::Duplicate.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/questions/duplicate.rb b/app/models/form/lettings/questions/duplicate.rb new file mode 100644 index 000000000..36aa37e87 --- /dev/null +++ b/app/models/form/lettings/questions/duplicate.rb @@ -0,0 +1,10 @@ +class Form::Lettings::Questions::Duplicate < ::Form::Question + def initialize(id, hsh, page) + super + @id = "duplicate" + @check_answer_label = "Look at all these duplicates" + @header = "Look at all these duplicates" + @type = "duplicate" + @hint_text = "" + end +end diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index 860d4ea88..cd317760c 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -10,6 +10,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection @pages ||= [ uprn_questions, Form::Lettings::Pages::PropertyLocalAuthority.new(nil, nil, self), + Form::Lettings::Pages::DuplicatePage.new("duplicates", nil, self), Form::Lettings::Pages::MinRentValueCheck.new("local_authority_min_rent_value_check", nil, self, check_answers_card_number: nil), Form::Lettings::Pages::MaxRentValueCheck.new("local_authority_max_rent_value_check", nil, self, check_answers_card_number: nil), Form::Lettings::Pages::FirstTimePropertyLetAsSocialHousing.new(nil, nil, self), diff --git a/app/models/form/page.rb b/app/models/form/page.rb index 498c69d7b..0925fbb8a 100644 --- a/app/models/form/page.rb +++ b/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, :interruption_screen_question_ids + :skip_text, :interruption_screen_question_ids, :page_type def initialize(id, hsh, subsection) @id = id @@ -18,6 +18,7 @@ class Form::Page @next_unresolved_page_id = hsh["next_unresolved_page_id"] @skip_text = hsh["skip_text"] @interruption_screen_question_ids = hsh["interruption_screen_question_ids"] || [] + @page_type = hsh["page_type"] end end diff --git a/app/views/form/_duplicate_page.html.erb b/app/views/form/_duplicate_page.html.erb new file mode 100644 index 000000000..3824ecd14 --- /dev/null +++ b/app/views/form/_duplicate_page.html.erb @@ -0,0 +1,5 @@ +Display duplicates here +<%= govuk_button_link_to( + "Continue", + send(@log.form.next_page_redirect_path(@page, @log, current_user), @log), + ) %> \ No newline at end of file diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index b5ce2ead7..ee162ff1b 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -5,6 +5,9 @@ <% end %>
+<% if @page.page_type == "duplicate" %> + <%= render partial: "form/duplicate_page", locals: { log: @log } %> +<% else %> <%= form_with model: @log, url: request.original_url, method: "post", local: true do |f| %>
@@ -78,3 +81,4 @@
<% end %> +<% end %>