Skip to content

Commit 4ca5202

Browse files
authored
Merge pull request #4821 from nhsuk/fix-still-to-vaccinate-filter
Fix pagination for "Still to vaccinate" filter on patients tab
2 parents ec9f644 + 845b29b commit 4ca5202

6 files changed

Lines changed: 33 additions & 6 deletions

File tree

app/components/app_patient_search_form_component.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AppPatientSearchFormComponent < ViewComponent::Base
3232
<% end %>
3333
<% end %>
3434
35-
<% if tallying_enabled? %>
35+
<% if tallying_enabled? && show_still_to_vaccinate %>
3636
<%= f.govuk_check_boxes_fieldset :show_only, multiple: false, legend: { text: "Show only", size: "s" } do %>
3737
<%= f.govuk_check_box :still_to_vaccinate,
3838
1, 0,
@@ -211,7 +211,8 @@ def initialize(
211211
vaccine_methods: [],
212212
year_groups: [],
213213
heading_level: 3,
214-
show_aged_out_of_programmes: false
214+
show_aged_out_of_programmes: false,
215+
show_still_to_vaccinate: false
215216
)
216217
@form = form
217218
@url = url
@@ -226,6 +227,7 @@ def initialize(
226227
@year_groups = year_groups
227228
@heading_level = heading_level
228229
@show_aged_out_of_programmes = show_aged_out_of_programmes
230+
@show_still_to_vaccinate = show_still_to_vaccinate
229231
end
230232

231233
private
@@ -241,7 +243,8 @@ def initialize(
241243
:vaccine_methods,
242244
:year_groups,
243245
:heading_level,
244-
:show_aged_out_of_programmes
246+
:show_aged_out_of_programmes,
247+
:show_still_to_vaccinate
245248

246249
delegate :format_year_group,
247250
:govuk_button_link_to,

app/components/app_session_overview_tallies_component.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<%= render AppCardComponent.new do |card| %>
3131
<% if session.today? %>
3232
<%= govuk_inset_text classes: "nhsuk-u-margin-top-4 nhsuk-u-margin-bottom-4" do %>
33-
<%= link_to "#{still_to_vaccinate_count} children with consent have not been vaccinated yet",
33+
<%= link_to t(".still_to_vaccinate_message", count: still_to_vaccinate_count),
3434
session_patients_path(session, still_to_vaccinate: 1) %>
3535
<% end %>
3636
<% end %>

app/controllers/sessions/patients_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def show
1515
@session.patients.includes(:vaccination_statuses, notes: :created_by)
1616

1717
patients = @form.apply(scope)
18-
@pagy, @patients = pagy(patients)
18+
19+
@pagy, @patients =
20+
patients.is_a?(Array) ? pagy_array(patients) : pagy(patients)
1921
end
2022

2123
private

app/views/sessions/patients/show.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
programmes: @session.programmes,
1717
vaccination_statuses: @statuses,
1818
year_groups: @session.year_groups,
19+
show_still_to_vaccinate: true,
1920
) %>
2021
</div>
2122

config/locales/components.en.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ en:
44
one: >-
55
1 child is due a vaccination this year and has not been vaccinated at another location
66
other: >-
7-
%{count} children are due a vaccination this year and have not been vaccinated at another location
7+
%{count} children are due a vaccination this year and have not been vaccinated at another location
8+
still_to_vaccinate_message:
9+
one: >-
10+
1 child with consent has not been vaccinated yet
11+
other: >-
12+
%{count} children with consent have not been vaccinated yet

spec/features/tallying_session_overview_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
and_i_visit_the_session_record_tab
1414

1515
when_i_click_on_each_tally_the_filters_match_the_same_count
16+
17+
when_i_visit_the_session_record_tab
18+
and_i_click_on_the_link_to_view_patients_still_to_vaccinate
19+
then_i_should_see_the_patient_that_needs_to_be_vaccinated
1620
end
1721

1822
def given_a_session_for_flu_is_running_today
@@ -29,6 +33,8 @@ def given_a_session_for_flu_is_running_today
2933
def and_i_visit_the_session_record_tab
3034
visit session_path(@session, tallying: true)
3135
end
36+
alias_method :when_i_visit_the_session_record_tab,
37+
:and_i_visit_the_session_record_tab
3238

3339
def and_the_tallying_feature_flag_is_enabled
3440
Flipper.enable(:tallying)
@@ -133,4 +139,14 @@ def when_i_click_on_each_tally_the_filters_match_the_same_count
133139
expect(page).to have_content("Showing 1 to 1 of 1 children")
134140
expect(page).to have_content(@patients.fifth.given_name)
135141
end
142+
143+
def and_i_click_on_the_link_to_view_patients_still_to_vaccinate
144+
click_link "2 children with consent have not been vaccinated yet"
145+
end
146+
147+
def then_i_should_see_the_patient_that_needs_to_be_vaccinated
148+
expect(page).to have_content("Showing 1 to 2 of 2 children")
149+
expect(page).to have_content(@patients.second.given_name)
150+
expect(page).to have_content(@patients.third.given_name)
151+
end
136152
end

0 commit comments

Comments
 (0)