Browse Source

CLDC-836: Don't make subsection labels links if they're not enabled (#215)

* Don't make subsection labels links if they're not enabled

* PR accessibility comments
pull/218/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
873d738513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/helpers/tasklist_helper.rb
  2. 11
      app/views/case_logs/_tasklist.html.erb
  3. 4
      spec/helpers/tasklist_helper_spec.rb

12
app/helpers/tasklist_helper.rb

@ -35,11 +35,11 @@ module TasklistHelper
end
def subsection_link(subsection, case_log)
next_page_path = if subsection.status(case_log) != :cannot_start_yet
first_page_or_check_answers(subsection, case_log)
else
"#"
end
govuk_link_to(subsection.label, next_page_path.to_s.dasherize, class: "task-name")
if subsection.status(case_log) != :cannot_start_yet
next_page_path = first_page_or_check_answers(subsection, case_log).to_s
govuk_link_to(subsection.label, next_page_path.dasherize, aria: { describedby: subsection.id.dasherize })
else
subsection.label
end
end
end

11
app/views/case_logs/_tasklist.html.erb

@ -8,10 +8,13 @@
</h2>
<ul class="app-task-list__items">
<% section.subsections.map do |subsection| %>
<li class="app-task-list__item" id=<%= subsection.id %>>
<% subsection_status = subsection.status(@case_log) %>
<%= subsection_link(subsection, @case_log) %>
<strong class="govuk-tag app-task-list__tag <%= TasklistHelper::STYLES[subsection_status] %>">
<% subsection_status = subsection.status(@case_log) %>
<li class="app-task-list__item">
<span class="app-task-list__task-name">
<%= subsection_link(subsection, @case_log) %>
</span>
<strong class="govuk-tag app-task-list__tag <%= TasklistHelper::STYLES[subsection_status] %>"
id=<%= subsection.id.dasherize %>>
<%= TasklistHelper::STATUSES[subsection_status] %>
</strong>
</li>

4
spec/helpers/tasklist_helper_spec.rb

@ -67,8 +67,8 @@ RSpec.describe TasklistHelper do
allow(subsection).to receive(:status).with(case_log).and_return(:cannot_start_yet)
end
it "returns a # link" do
expect(subsection_link(subsection, case_log)).to match(/#/)
it "returns the label instead of a link" do
expect(subsection_link(subsection, case_log)).to match(subsection.label)
end
end
end

Loading…
Cancel
Save