From e724fe347a791856fdd637951627fd1f0f123cbf Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Mon, 11 Oct 2021 18:16:52 +0100 Subject: [PATCH] Navigate straight to check answers page if a section has been started already --- app/helpers/tasklist_helper.rb | 13 +++++++ app/views/case_logs/_tasklist.html.erb | 7 ++-- spec/features/case_log_spec.rb | 2 +- spec/helpers/tasklist_helper_spec.rb | 51 ++++++++++++++------------ 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index 4c831029c..1b4d5b329 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -36,6 +36,14 @@ module TasklistHelper subsections.count { |subsection| get_subsection_status(subsection, case_log, form.questions_for_subsection(subsection).keys) == status } end + def get_first_page_or_check_answers(subsection, case_log, form, questions) + if is_started?(subsection, case_log, questions) + send("case_log_#{subsection}_check_answers_path", case_log) + else + send("case_log_#{form.first_page_for_subsection(subsection)}_path", case_log) + end + end + private def all_questions_completed(case_log) @@ -46,4 +54,9 @@ private status = get_subsection_status(subsection, case_log, questions) %i[not_started in_progress].include?(status) end + + def is_started?(subsection, case_log, questions) + status = get_subsection_status(subsection, case_log, questions) + %i[in_progress completed].include?(status) + end end diff --git a/app/views/case_logs/_tasklist.html.erb b/app/views/case_logs/_tasklist.html.erb index dbbeb6321..fdf4c5aa9 100644 --- a/app/views/case_logs/_tasklist.html.erb +++ b/app/views/case_logs/_tasklist.html.erb @@ -9,9 +9,10 @@