From 4c479d4fd3f799a5941005f1bc63c1f11cf47085 Mon Sep 17 00:00:00 2001 From: Daniel Baark <5101747+baarkerlounger@users.noreply.github.com> Date: Mon, 15 Nov 2021 12:25:00 +0000 Subject: [PATCH] Bug fixes (#89) * Check answers to tasklist * Fix status display * Fix case log status * Update footer * Update spec * Fix spec * Make form pages 2/3 width * Make spec failures less likely --- .../soft_validations_controller.js | 2 +- app/views/case_logs/edit.html.erb | 2 +- app/views/form/check_answers.html.erb | 2 +- app/views/form/page.html.erb | 41 ++++++++-------- app/views/layouts/_footer.html.erb | 48 +++++++++++++++++++ app/views/layouts/application.html.erb | 29 +---------- spec/features/case_log_spec.rb | 2 +- 7 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 app/views/layouts/_footer.html.erb diff --git a/app/javascript/controllers/soft_validations_controller.js b/app/javascript/controllers/soft_validations_controller.js index a408e4460..2c223ce1c 100644 --- a/app/javascript/controllers/soft_validations_controller.js +++ b/app/javascript/controllers/soft_validations_controller.js @@ -5,7 +5,7 @@ export default class extends Controller { initialize() { let url = window.location.href + "/soft_validations" - this.fetch_retry(url, { headers: { accept: "application/json" } }, 2) + this.fetch_retry(url, { headers: { accept: "application/json" } }, 5) } fetch_retry(url, options, n) { diff --git a/app/views/case_logs/edit.html.erb b/app/views/case_logs/edit.html.erb index 551ce0cb5..83d442cb9 100644 --- a/app/views/case_logs/edit.html.erb +++ b/app/views/case_logs/edit.html.erb @@ -5,7 +5,7 @@ <%= @case_log.id %>

This submission is - <%= @case_log.status %>

+ <%= @case_log.status.to_s.humanize %>

You've completed <%= get_subsections_count(@form, @case_log, :completed) %> of <%= get_subsections_count(@form, @case_log, :all) %> sections.

<% next_incomplete_section=get_next_incomplete_section(@form, @case_log) %> diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb index 49ebeda0f..26b153f8f 100644 --- a/app/views/form/check_answers.html.erb +++ b/app/views/form/check_answers.html.erb @@ -10,7 +10,7 @@ <%end %> <%end %> <% end %> - <%= form_with action: '/case_logs', method: "next_page", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= form_with model: @case_log, method: "get", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= f.govuk_submit "Save and continue" %> <% end %> diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index 188b16cda..d47e89e7b 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -3,25 +3,28 @@ <% end %> <%= turbo_frame_tag "case_log_form", target: "_top" do %> +

+
+ <% if page_info["header"].present? %> +

+ <%= page_info["header"] %> +

+ <% end %> + <%= form_with model: @case_log, method: "submit_form", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_error_summary %> + <% page_info["questions"].map do |question_key, question| %> +
<%= display_question_key_div(page_info, question_key) %> > + <%= render partial: "form/#{question["type"]}_question", locals: { question_key: question_key.to_sym, question: question, f: f } %> +
+ <% end %> - <% if page_info["header"].present? %> -

- <%= page_info["header"] %> -

- <% end %> - <%= form_with model: @case_log, method: "submit_form", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> - <%= f.govuk_error_summary %> - <% page_info["questions"].map do |question_key, question| %> -
<%= display_question_key_div(page_info, question_key) %> > - <%= render partial: "form/#{question["type"]}_question", locals: { question_key: question_key.to_sym, question: question, f: f } %> -
- <% end %> + <% if page_info["soft_validations"]&.keys&.first %> + <%= render partial: "form/validation_override_question", locals: { f: f, page_key: page_key, page_info: page_info } %> + <% end %> - <% if page_info["soft_validations"]&.keys&.first %> - <%= render partial: "form/validation_override_question", locals: { f: f, page_key: page_key, page_info: page_info } %> - <% end %> - - <%= f.hidden_field :page, value: page_key %> - <%= f.govuk_submit "Save and continue" %> - <% end %> + <%= f.hidden_field :page, value: page_key %> + <%= f.govuk_submit "Save and continue" %> + <% end %> +
+
<% end %> diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb new file mode 100644 index 000000000..ffba80da2 --- /dev/null +++ b/app/views/layouts/_footer.html.erb @@ -0,0 +1,48 @@ +
+ + +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 343307b55..7ea45b6e4 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -72,34 +72,7 @@ diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index b48572d62..5552b0c85 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -43,7 +43,7 @@ RSpec.describe "Test Features" do it "displays a tasklist header" do visit("/case_logs/#{id}") expect(page).to have_content("Tasklist for log #{id}") - expect(page).to have_content("This submission is #{status}") + expect(page).to have_content("This submission is #{status.humanize}") end it "displays a section status" do