Skip to content

Commit b66ac2b

Browse files
committed
Improve patient session page banner
Make the patient session banner sticky as the user scrolls and use the same design as for session pages. The banner should collapse showing minimal information as the user scrolls
1 parent a255af3 commit b66ac2b

11 files changed

Lines changed: 64 additions & 53 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
@forward "grid";
2+
@forward "main-wrapper";
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@use "../../vendor/nhsuk-frontend" as *;
2+
3+
.app-main-wrapper--xs {
4+
padding-top: nhsuk-spacing(3);
5+
padding-bottom: nhsuk-spacing(3);
6+
}

app/components/app_breadcrumb_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<nav class="nhsuk-breadcrumb" aria-label="Breadcrumb"
1+
<nav class="nhsuk-breadcrumb<%= " nhsuk-breadcrumb--reverse" if @reverse %>" aria-label="Breadcrumb"
22
<%= @attributes.map { |name, value| "#{name}=\"#{value}\"" }.join(" ") %>>
33
<ol class="nhsuk-breadcrumb__list">
44
<% @items.each do |item| %>

app/components/app_breadcrumb_component.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# frozen_string_literal: true
22

33
class AppBreadcrumbComponent < ViewComponent::Base
4-
def initialize(items:, attributes: {})
4+
def initialize(items:, reverse: false, attributes: {})
55
@items = items
6+
@reverse = reverse
67
@attributes = attributes
78
end
89

app/components/app_patient_summary_component.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
class AppPatientSummaryComponent < ViewComponent::Base
44
erb_template <<-ERB
5-
<h3 class="nhsuk-heading-s nhsuk-u-margin-top-1">
6-
<%= patient.full_name %>
7-
</h3>
8-
95
<%= govuk_summary_list(rows:, classes:) %>
10-
6+
117
<p>
128
<%= link_to "View full child record", patient_path(patient) %>
139
</p>
@@ -35,11 +31,7 @@ def rows
3531
end
3632

3733
def classes
38-
%w[
39-
nhsuk-summary-list--no-border
40-
app-summary-list--full-width
41-
nhsuk-u-margin-bottom-2
42-
]
34+
%w[app-summary-list--full-width nhsuk-u-margin-bottom-2]
4335
end
4436

4537
def nhs_number_row
@@ -68,7 +60,14 @@ def date_of_birth_row
6860
},
6961
value: {
7062
text: patient.date_of_birth.to_fs(:long)
71-
}
63+
},
64+
**(
65+
if patient.restricted?
66+
{ classes: %w[nhsuk-summary-list__row--no-border] }
67+
else
68+
{}
69+
end
70+
)
7271
}
7372
end
7473

@@ -79,7 +78,8 @@ def address_row
7978
},
8079
value: {
8180
text: format_address_multi_line(patient)
82-
}
81+
},
82+
classes: %w[nhsuk-summary-list__row--no-border]
8383
}
8484
end
8585
end

app/helpers/sessions_helper.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,17 @@ def session_status(session)
5656
end
5757
end
5858

59-
def session_title(session)
59+
def session_title(session, include_dates: true)
6060
programmes = session.programmes.map(&:name).to_sentence
61+
<<<<<<< HEAD
62+
=======
63+
dates =
64+
(
65+
if session.dates.present? && include_dates
66+
"on #{session_dates(session)}"
67+
end
68+
)
69+
>>>>>>> b88b5b4ac (Improve patient session page banner)
6170

6271
items =
6372
if session.generic_clinic?
Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<% content_for :page_title, @patient.initials %>
22

3-
<% content_for :navigation do %>
4-
<%= render AppBreadcrumbComponent.new(items: [
5-
{ text: "Home", href: dashboard_path },
6-
{ text: t("sessions.index.title"), href: sessions_path },
7-
{ text: @session.location.name, href: session_path(@session) },
8-
@breadcrumb_item,
9-
].compact) %>
10-
<% end %>
11-
123
<% if (outstanding_programmes = patient_outstanding_programmes(@patient, session: @session)).any? %>
134
<% programmes_can_record_vaccination = outstanding_programmes.filter do |programme|
145
policy(VaccinationRecord.new(patient: @patient, session: @session, programme:)).new?
@@ -19,29 +10,34 @@
1910
<% end %>
2011
<% end %>
2112

22-
<h1 class="nhsuk-heading-l nhsuk-u-margin-bottom-2">
23-
<%= @patient.full_name %>
24-
</h1>
13+
<% content_for :main_content do %>
14+
<div class="app-session-banner" data-module="app-sticky">
15+
<div class="nhsuk-width-container">
16+
<%= render AppBreadcrumbComponent.new(items: [
17+
{ text: session_title(@session, include_dates: false), href: session_path(@session) },
18+
@breadcrumb_item,
19+
].compact, reverse: true) %>
2520

26-
<p class="nhsuk-caption-l nhsuk-u-margin-bottom-4">
27-
<%= patient_year_group(@patient, academic_year: @academic_year) %>
28-
</p>
21+
<div class="nhsuk-main-wrapper app-main-wrapper--xs">
22+
<%= h1 @patient.full_name %>
23+
</div>
2924

30-
<%= render AppStickyNavigationComponent.new do %>
31-
<%= render AppSecondaryNavigationComponent.new do |nav|
32-
@session.programmes_for(patient: @patient).each do |programme|
33-
nav.with_item(
34-
href: session_patient_programme_path(@session, @patient, programme, return_to: params[:return_to]),
35-
text: programme.name,
36-
selected: @programme == programme,
37-
ticked: @patient.programme_status(programme, academic_year: @academic_year).vaccinated?,
38-
)
39-
end
40-
41-
nav.with_item(
42-
href: session_patient_activity_path(@session, @patient, return_to: params[:return_to]),
43-
text: "Session activity and notes",
44-
selected: request.path.ends_with?("/activity"),
45-
)
46-
end %>
25+
<%= render AppSecondaryNavigationComponent.new(reverse: true) do |nav|
26+
@session.programmes_for(patient: @patient).each do |programme|
27+
nav.with_item(
28+
href: session_patient_programme_path(@session, @patient, programme, return_to: params[:return_to]),
29+
text: programme.name,
30+
selected: @programme == programme,
31+
ticked: @patient.programme_status(programme, academic_year: @academic_year).vaccinated?,
32+
)
33+
end
34+
35+
nav.with_item(
36+
href: session_patient_activity_path(@session, @patient, return_to: params[:return_to]),
37+
text: "Session activity and notes",
38+
selected: request.path.ends_with?("/activity"),
39+
)
40+
end %>
41+
</div>
42+
</div>
4743
<% end %>

spec/components/app_patient_summary_component_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
let(:href) { "/patients/#{patient.id}" }
1919

20-
it { should have_content("SELDON, Hari") }
21-
2220
it { should have_content("NHS number") }
2321

2422
context "when patient has an NHS number" do

spec/features/e2e_journey_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def then_i_should_see_that_the_patient_is_ready_for_vaccination
248248
end
249249

250250
def when_i_click_on_the_register_attendance_section
251-
click_link "Pilot School"
251+
within(".nhsuk-breadcrumb__list") { click_link @school.name }
252252
within(".app-secondary-navigation") { click_link "Children" }
253253
end
254254

@@ -285,7 +285,7 @@ def and_i_record_the_successful_vaccination
285285
end
286286

287287
def then_i_see_that_the_child_is_vaccinated
288-
click_on "Pilot School"
288+
within(".nhsuk-breadcrumb__list") { click_link @school.name }
289289
within(".app-secondary-navigation") { click_on "Children" }
290290
expect(page).not_to have_content("Not eligible")
291291
choose "Vaccinated", match: :first

spec/features/manage_children_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def when_i_click_on_record_new_vaccination
658658
end
659659

660660
def then_i_see_the_community_clinic_session
661-
expect(page).to have_content("Community clinic")
661+
expect(page).to have_content("community clinic")
662662
end
663663

664664
def when_i_go_to_the_dashboard

0 commit comments

Comments
 (0)