Browse Source

Update status of log on log page

pull/404/head
Paul Robert Lloyd 3 years ago
parent
commit
5ab96154da
  1. 36
      app/views/case_logs/edit.html.erb
  2. 13
      spec/features/form/tasklist_page_spec.rb

36
app/views/case_logs/edit.html.erb

@ -11,25 +11,25 @@
<%= content_for(:title) %> <%= content_for(:title) %>
</h1> </h1>
<h2 class="govuk-heading-s govuk-!-margin-bottom-2"> <% if @case_log.status == "in_progress" %>
This log is <p class="govuk-body govuk-!-margin-bottom-7"><%= get_subsections_count(@case_log, :completed) %> of <%= get_subsections_count(@case_log, :all) %> sections completed.</p>
<%= @case_log.status.to_s.humanize.downcase %> <p class="govuk-body govuk-!-margin-bottom-2">
</h2> <% next_incomplete_section = get_next_incomplete_section(@case_log) %>
</p>
<p>
<% if next_incomplete_section.present? %>
<a class="app-section-skip-link" href="#<%= next_incomplete_section.id.dasherize %>"
data-controller="tasklist"
data-action="tasklist#addHighlight"
data-info=<%= next_incomplete_section.id %>>
Skip to next incomplete section: <%= next_incomplete_section.label %>
</a>
<% end %>
</p>
<% elsif @case_log.status == "not_started" %>
<p class="govuk-body">This log has not been started.</p>
<% end %>
<p class="govuk-body govuk-!-margin-bottom-7">You have completed <%= get_subsections_count(@case_log, :completed) %> of <%= get_subsections_count(@case_log, :all) %> sections.</p>
<p class="govuk-body govuk-!-margin-bottom-2">
<% next_incomplete_section = get_next_incomplete_section(@case_log) %>
</p>
<p>
<% if next_incomplete_section.present? %>
<a class="app-section-skip-link" href="#<%= next_incomplete_section.id.dasherize %>"
data-controller="tasklist"
data-action="tasklist#addHighlight"
data-info=<%= next_incomplete_section.id %>>
Skip to next incomplete section: <%= next_incomplete_section.label %>
</a>
<% end %>
</p>
<%= render "tasklist" %> <%= render "tasklist" %>
</div> </div>
</div> </div>

13
spec/features/form/tasklist_page_spec.rb

@ -26,19 +26,20 @@ RSpec.describe "Task List" do
sign_in user sign_in user
end 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}") 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 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}") 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 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) answer_all_questions_in_income_subsection(empty_case_log)
visit("/logs/#{empty_case_log.id}") 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
end end

Loading…
Cancel
Save