Skip to content

Commit 128d744

Browse files
committed
Update session vaccinations given card
This updates the card showing the vaccinations that were given at the session to match the latest designs in the prototype. Jira-Issue: MAV-2645
1 parent a888bd2 commit 128d744

13 files changed

Lines changed: 55 additions & 133 deletions

app/components/app_session_buttons_component.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class AppSessionButtonsComponent < ViewComponent::Base
44
erb_template <<-ERB
55
<div class="nhsuk-button-group">
66
<% if policy(session).edit? %>
7-
<%= govuk_button_link_to edit_button_text, edit_session_path(session), secondary: true %>
7+
<%= govuk_button_link_to "Edit session", edit_session_path(session), secondary: true %>
88
99
<%= link_to "Record offline", session_path(session, format: :xlsx) %>
1010
@@ -26,8 +26,4 @@ def initialize(session)
2626
attr_reader :session
2727

2828
delegate :policy, :govuk_button_link_to, to: :helpers
29-
30-
def edit_button_text
31-
session.dates.empty? ? "Schedule sessions" : "Edit session"
32-
end
3329
end

app/components/app_session_dates_component.rb

Lines changed: 0 additions & 57 deletions
This file was deleted.

app/components/app_session_dates_table_component.html.erb

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/components/app_session_details_component.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class AppSessionDetailsComponent < ViewComponent::Base
99
session,
1010
patient_count: session.patients.count,
1111
show_consent_forms: true,
12+
show_dates: true,
1213
show_location: true,
1314
show_status: true,
1415
) %>

app/components/app_session_overview_component.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class AppSessionOverviewComponent < ViewComponent::Base
55
<%= render AppSessionStatsComponent.new(session) %>
66
77
<section>
8-
<%= render AppSessionDatesComponent.new(session) %>
8+
<%= render AppSessionVaccinationsComponent.new(session) %>
99
</section>
1010
1111
<section>
@@ -17,9 +17,7 @@ class AppSessionOverviewComponent < ViewComponent::Base
1717
</section>
1818
1919
<section>
20-
<% if Flipper.enabled?(:schools_and_sessions) %>
21-
<%= render AppSessionButtonsComponent.new(session) %>
22-
<% end %>
20+
<%= render AppSessionButtonsComponent.new(session) %>
2321
</section>
2422
ERB
2523

app/components/app_session_dates_table_component.rb renamed to app/components/app_session_vaccinations_component.rb

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,62 @@
11
# frozen_string_literal: true
22

3-
class AppSessionDatesTableComponent < ViewComponent::Base
3+
class AppSessionVaccinationsComponent < ViewComponent::Base
4+
erb_template <<-ERB
5+
<%= render AppCardComponent.new do |card| %>
6+
<% card.with_heading(level: 3) { "Vaccinations given in this session" } %>
7+
8+
<%= govuk_table(html_attributes: { class: "nhsuk-table-responsive" }) do |table| %>
9+
<% table.with_head do |head| %>
10+
<% head.with_row do |row| %>
11+
<% row.with_cell(text: "Session date") %>
12+
<% session_column_names.each do |column| %>
13+
<% row.with_cell(text: column, numeric: true) %>
14+
<% end %>
15+
<% end %>
16+
<% end %>
17+
18+
<% table.with_body do |body| %>
19+
<% rows.each_with_index do |row_data| %>
20+
<% body.with_row do |row| %>
21+
<% row.with_cell(text: row_data[:label]) %>
22+
<% row_data[:tallies].each do |tally| %>
23+
<% row.with_cell(text: tally.to_s, numeric: true) %>
24+
<% end %>
25+
<% end %>
26+
<% end %>
27+
<% end %>
28+
<% end %>
29+
<% end %>
30+
ERB
31+
432
def initialize(session)
533
@session = session
634
end
735

8-
def session_column_names
9-
@session_column_names ||= build_column_names
10-
end
11-
12-
def rows = session_dates_rows + [total_row]
36+
def render? = session.started?
1337

1438
private
1539

1640
attr_reader :session
1741

18-
delegate :govuk_table, to: :helpers
1942
delegate :programmes, to: :session
2043

21-
def build_column_names
22-
programmes.flat_map do |programme|
23-
if programme.has_multiple_vaccine_methods?
24-
base_name = programme.name_in_sentence.titlecase
25-
["#{base_name} (nasal spray)", "#{base_name} (injection)"]
26-
else
27-
programme.name_in_sentence
44+
delegate :govuk_table, to: :helpers
45+
46+
def session_column_names
47+
@session_column_names ||=
48+
programmes.flat_map do |programme|
49+
if programme.has_multiple_vaccine_methods?
50+
base_name = programme.name_in_sentence.titlecase
51+
["#{base_name} (nasal spray)", "#{base_name} (injection)"]
52+
else
53+
programme.name_in_sentence
54+
end
2855
end
29-
end
3056
end
3157

58+
def rows = session_dates_rows + [total_row]
59+
3260
def session_dates_rows
3361
@session_dates_rows ||=
3462
session.dates.map do |date|

spec/components/app_session_overview_component_spec.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -363,19 +363,5 @@
363363
end
364364
end
365365
end
366-
367-
context "when session has not started" do
368-
let(:dates) { [Date.new(2025, 1, 20)] }
369-
370-
it "renders the scheduled dates list instead of the table" do
371-
expect(rendered).to have_content("Monday, 20 January 2025")
372-
expect(rendered).not_to have_content("Vaccinations given")
373-
expect(rendered).not_to have_content("Session date")
374-
end
375-
376-
it "displays the consent period information" do
377-
expect(rendered).to have_content("Consent period")
378-
end
379-
end
380366
end
381367
end

spec/components/app_session_dates_table_component_spec.rb renamed to spec/components/app_session_vaccinations_component_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
describe AppSessionDatesTableComponent do
3+
describe AppSessionVaccinationsComponent do
44
subject(:rendered) { render_inline(component) }
55

66
let(:hpv_programme) { Programme.hpv }

spec/features/e2e_journey_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def when_i_start_creating_a_new_session_by_choosing_school_and_time
149149
choose "Unscheduled"
150150
click_on "Update results"
151151
click_on "Pilot School"
152-
click_on "Schedule sessions"
152+
click_on "Edit session"
153153

154154
click_on "Add session dates"
155155
expect(page).to have_content("When will sessions be held?")

spec/features/edit_session_dates_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def when_i_visit_the_session_overview_page
5353
end
5454

5555
def and_i_click_on_schedule_sessions
56-
click_on "Schedule sessions"
56+
click_on "Edit session"
5757
end
5858

5959
def and_i_click_on_add_session_dates

0 commit comments

Comments
 (0)