Browse Source

WIP duplicate page example

duplicate-spike
Kat 2 years ago
parent
commit
778fb7ba32
  1. 10
      app/models/form/lettings/pages/duplicate_page.rb
  2. 10
      app/models/form/lettings/questions/duplicate.rb
  3. 1
      app/models/form/lettings/subsections/property_information.rb
  4. 3
      app/models/form/page.rb
  5. 5
      app/views/form/_duplicate_page.html.erb
  6. 4
      app/views/form/page.html.erb

10
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

10
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

1
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),

3
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

5
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),
) %>

4
app/views/form/page.html.erb

@ -5,6 +5,9 @@
<% end %>
<div data-controller="govukfrontend"></div>
<% 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| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
@ -78,3 +81,4 @@
</div>
</div>
<% end %>
<% end %>

Loading…
Cancel
Save