From 79e6fd42c4d1a0144feedbe19179c524eb0b9ec2 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Tue, 22 Mar 2022 18:35:44 +0000 Subject: [PATCH] Log status on log (#410) * Fix link to next incomplete section * Update status of log on log page * Remove TasklistController as no longer required * Add missing quotes around HTML attribute * Add additional spec for tasklist page * Capybara does not enjoy setting focus Co-authored-by: Paul Robert Lloyd --- app/frontend/controllers/index.js | 3 -- .../controllers/tasklist_controller.js | 8 ----- app/views/case_logs/_tasklist.html.erb | 2 +- app/views/case_logs/edit.html.erb | 33 +++++++++---------- spec/features/form/tasklist_page_spec.rb | 13 ++++---- 5 files changed, 23 insertions(+), 36 deletions(-) delete mode 100644 app/frontend/controllers/tasklist_controller.js diff --git a/app/frontend/controllers/index.js b/app/frontend/controllers/index.js index 743adba1c..ee3be6037 100644 --- a/app/frontend/controllers/index.js +++ b/app/frontend/controllers/index.js @@ -14,6 +14,3 @@ application.register("govukfrontend", GovukfrontendController) import NumericQuestionController from "./numeric_question_controller.js" application.register("numeric-question", NumericQuestionController) - -import TasklistController from "./tasklist_controller.js" -application.register("tasklist", TasklistController) diff --git a/app/frontend/controllers/tasklist_controller.js b/app/frontend/controllers/tasklist_controller.js deleted file mode 100644 index be94797f8..000000000 --- a/app/frontend/controllers/tasklist_controller.js +++ /dev/null @@ -1,8 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - addHighlight() { - let section_to_highlight = this.element.dataset.info; - document.getElementById(section_to_highlight).classList.add('tasklist_item_highlight'); - } -} diff --git a/app/views/case_logs/_tasklist.html.erb b/app/views/case_logs/_tasklist.html.erb index 6c240d616..42adcd340 100644 --- a/app/views/case_logs/_tasklist.html.erb +++ b/app/views/case_logs/_tasklist.html.erb @@ -15,7 +15,7 @@ <%= subsection_link(subsection, @case_log) %> > + id="<%= subsection.id.dasherize %>"> <%= TasklistHelper::STATUSES[subsection_status] %> diff --git a/app/views/case_logs/edit.html.erb b/app/views/case_logs/edit.html.erb index 5cd0de9a4..fe7e2d661 100644 --- a/app/views/case_logs/edit.html.erb +++ b/app/views/case_logs/edit.html.erb @@ -11,25 +11,22 @@ <%= content_for(:title) %> -

- This log is - <%= @case_log.status.to_s.humanize.downcase %> -

+ <% if @case_log.status == "in_progress" %> +

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

+

+ <% next_incomplete_section = get_next_incomplete_section(@case_log) %> +

+

+ <% if next_incomplete_section.present? %> + + Skip to next incomplete section: <%= next_incomplete_section.label %> + + <% end %> +

+ <% elsif @case_log.status == "not_started" %> +

This log has not been started.

+ <% end %> -

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

-

- <% next_incomplete_section = get_next_incomplete_section(@case_log) %> -

-

- <% if next_incomplete_section.present? %> - > - Skip to next incomplete section: <%= next_incomplete_section.label %> - - <% end %> -

<%= render "tasklist" %> diff --git a/spec/features/form/tasklist_page_spec.rb b/spec/features/form/tasklist_page_spec.rb index ba731e05e..7f869ded4 100644 --- a/spec/features/form/tasklist_page_spec.rb +++ b/spec/features/form/tasklist_page_spec.rb @@ -26,19 +26,20 @@ RSpec.describe "Task List" do sign_in user end - it "skips to the first section if no answers are completed" do + it "shows if the section has not been started" do visit("/logs/#{empty_case_log.id}") - expect(page).to have_link("Skip to next incomplete section", href: /#household_characteristics/) + expect(page).to have_content("This log has not been started.") end - it "shows the number of completed sections if no sections are completed" do + it "shows number of completed sections if one section is completed" do + answer_all_questions_in_income_subsection(empty_case_log) visit("/logs/#{empty_case_log.id}") - expect(page).to have_content("You have completed 0 of 9 sections.") + expect(page).to have_content("1 of 9 sections completed.") end - it "shows the number of completed sections if one section is completed" do + it "show skip link for next incomplete section" do answer_all_questions_in_income_subsection(empty_case_log) visit("/logs/#{empty_case_log.id}") - expect(page).to have_content("You have completed 1 of 9 sections.") + expect(page).to have_link("Skip to next incomplete section", href: /#household-characteristics/) end end