Skip to content

Commit 0da6fde

Browse files
authored
Add ticks to programme tabs (#3226)
When viewing a patient session, if that programme has an vaccinated outcome for this session, we should show a tick next to the programme so the nurses know that there's nothing further to be done for that programme. ## Screenshot <img width="463" alt="Screenshot 2025-03-12 at 17 31 40" src="https://github.com/user-attachments/assets/28757caa-5a79-4880-bd96-3d402304469c" />
2 parents 421fe2d + c0c810f commit 0da6fde

File tree

6 files changed

+40
-19
lines changed

6 files changed

+40
-19
lines changed

app/assets/stylesheets/_secondary-navigation.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@
5353
font-weight: inherit;
5454
}
5555

56+
.app-secondary-navigation__link,
57+
.app-secondary-navigation__current {
58+
align-items: center;
59+
display: flex;
60+
gap: nhsuk-spacing(1);
61+
62+
.nhsuk-icon {
63+
height: 1.5rem;
64+
width: 1.5rem;
65+
}
66+
}
67+
5668
.app-secondary-navigation__list {
5769
// The list uses box-shadow rather than a border to set a 1px grey line at the
5870
// bottom, so that the current item appears on top of the grey line.

app/components/app_secondary_navigation_component.html.erb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
<ul class="app-secondary-navigation__list">
33
<% items.each do |item| %>
44
<li class="app-secondary-navigation__list-item">
5-
<% if item.selected %>
6-
<%= link_to item.href,
7-
class: "app-secondary-navigation__link",
8-
aria: { current: true },
9-
data: { turbo: true, turbo_action: "replace" } do %>
5+
<%= link_to item.href,
6+
class: "app-secondary-navigation__link",
7+
aria: { current: item.selected || nil },
8+
data: { turbo: true, turbo_action: "replace" } do %>
9+
<% if item.selected %>
1010
<strong class="app-secondary-navigation__current">
1111
<%= item %>
1212
</strong>
13+
<% else %>
14+
<%= item %>
1315
<% end %>
14-
<% else %>
15-
<%= link_to item.href,
16-
class: "app-secondary-navigation__link",
17-
data: { turbo: true, turbo_action: "replace" } do %>
18-
<%= item %>
16+
17+
<% if item.ticked %>
18+
<svg class="nhsuk-icon nhsuk-icon__tick" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" focusable="false" aria-hidden="true" role="presentation">
19+
<path d="M18.4 7.8l-8.5 8.4L5.6 12" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round"></path>
20+
</svg>
1921
<% end %>
2022
<% end %>
2123
</li>

app/components/app_secondary_navigation_component.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ def initialize(classes: nil, attributes: {})
1313
end
1414

1515
class Item < ViewComponent::Base
16-
attr_reader :href, :selected
17-
18-
def call
19-
content || @text || raise(ArgumentError, "no text or content")
20-
end
21-
22-
def initialize(href:, text: nil, selected: false)
16+
def initialize(href:, text: nil, selected: false, ticked: false)
2317
super
2418

2519
@href = href
2620
@text = html_escape(text)
2721
@selected = selected
22+
@ticked = ticked
2823
end
24+
25+
def call
26+
content || @text || raise(ArgumentError, "no text or content")
27+
end
28+
29+
attr_reader :href, :selected, :ticked
2930
end
3031
end

app/models/patient_session/session_outcome.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def initialize(patient_session)
1818

1919
def vaccinated?(programme) = status[programme] == VACCINATED
2020

21+
def already_had?(programme) = status[programme] == ALREADY_HAD
22+
2123
def not_vaccinated?(programme) =
2224
status[programme] != VACCINATED && status[programme] != NONE
2325

app/views/patient_sessions/_header.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
href: session_patient_programme_path(@session, @patient, programme, return_to: params[:return_to]),
5656
text: programme.name,
5757
selected: @programme == programme,
58+
ticked: @patient_session.session_outcome.vaccinated?(programme) || @patient_session.session_outcome.already_had?(programme),
5859
)
5960
end
6061

spec/components/app_secondary_navigation_component_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
nav.with_item(
1010
selected: false,
1111
text: "Example 2",
12-
href: "https://example.com"
12+
href: "https://example.com",
13+
ticked: true
1314
)
1415
end
1516
end
@@ -18,7 +19,9 @@
1819

1920
it { should have_css("ul.app-secondary-navigation__list") }
2021
it { should have_css("li.app-secondary-navigation__list-item") }
21-
it { should have_css("strong.app-secondary-navigation__current") }
22+
23+
it { should have_css("strong.app-secondary-navigation__current").once }
24+
it { should have_css(".nhsuk-icon").once }
2225

2326
it { should have_link("Example 1", href: "https://example.com") }
2427
it { should have_link("Example 2", href: "https://example.com") }

0 commit comments

Comments
 (0)