Skip to content

Commit a6b9278

Browse files
committed
Show immunisation import warning callout
If there are duplicate records or not administered records, we want to include this information in a warning callout at the top of the page. The warning callout component is part of the NHS design system, but not part of GOV.UK's so we don't have a component in govuk-components for it. As this is the first time we're using it, I decided against creating a component for it, but we might want to do add one in the future.
1 parent 21d5a2a commit a6b9278

File tree

4 files changed

+27
-29
lines changed

4 files changed

+27
-29
lines changed

app/controllers/immunisation_imports_controller.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,6 @@ def create
4444
return
4545
end
4646

47-
flash[
48-
:success
49-
] = "#{@immunisation_import.new_record_count} vaccinations uploaded"
50-
51-
# TODO: Move to "Check and confirm" page
52-
if (duplicate_count = @immunisation_import.exact_duplicate_record_count) > 1
53-
flash[
54-
:info
55-
] = "#{duplicate_count} previously uploaded records were omitted"
56-
end
57-
58-
if (ignored_count = @immunisation_import.not_administered_record_count) > 1
59-
flash[
60-
:info
61-
] = "#{ignored_count} records for children who were not vaccinated were omitted"
62-
end
63-
6447
redirect_to edit_campaign_immunisation_import_path(
6548
@campaign,
6649
@immunisation_import

app/views/immunisation_imports/edit.html.erb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@
1010
<span class="nhsuk-caption-l"><%= @campaign.name %></span>
1111
<%= h1 title, page_title: "#{@campaign.name}#{title}" %>
1212

13+
<% if @immunisation_import.exact_duplicate_record_count > 1 || @immunisation_import.not_administered_record_count > 1 %>
14+
<div class="nhsuk-warning-callout">
15+
<h3 class="nhsuk-warning-callout__label">
16+
<span class="nhsuk-u-visually-hidden">Important: </span>
17+
Uploaded records will differ from the file
18+
</h3>
19+
20+
<ul class="nhsuk-list nhsuk-list--bullet">
21+
<% if @immunisation_import.exact_duplicate_record_count > 1 %>
22+
<li><%= @immunisation_import.exact_duplicate_record_count %> previously uploaded records were omitted</li>
23+
<% end %>
24+
25+
<% if @immunisation_import.not_administered_record_count > 1 %>
26+
<li><%= @immunisation_import.not_administered_record_count %> records for children who were not vaccinated were omitted</li>
27+
<% end %>
28+
</ul>
29+
</div>
30+
<% end %>
31+
1332
<%= govuk_button_to "Upload records", campaign_immunisation_import_path(
1433
@campaign,
1534
@immunisation_import

spec/features/immunisation_imports_upload_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
and_i_go_back_to_the_upload_page
2323

2424
when_i_upload_a_valid_file
25-
then_i_should_see_the_success_banner
25+
then_i_should_see_the_success_heading
2626
and_i_should_see_the_vaccination_records
2727

2828
when_i_click_on_upload_records
@@ -114,8 +114,8 @@ def when_i_upload_a_valid_file
114114
click_on "Continue"
115115
end
116116

117-
def then_i_should_see_the_success_banner
118-
expect(page).to have_content("7 vaccinations uploaded")
117+
def then_i_should_see_the_success_heading
118+
expect(page).to have_content("7 new vaccination records")
119119
end
120120

121121
def and_i_should_see_the_vaccination_records

spec/models/immunisation_import_spec.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,11 @@
191191
end
192192

193193
it "stores statistics on the import" do
194-
expect { process! }.to change(
195-
immunisation_import,
196-
:exact_duplicate_record_count
197-
).to(0).and change(immunisation_import, :new_record_count).to(
198-
7
199-
).and change(
200-
immunisation_import,
201-
:not_administered_record_count
202-
).to(0)
194+
# stree-ignore
195+
expect { process! }
196+
.to change(immunisation_import, :exact_duplicate_record_count).to(0)
197+
.and change(immunisation_import, :new_record_count).to(7)
198+
.and change(immunisation_import, :not_administered_record_count).to(0)
203199
end
204200

205201
it "ignores and counts duplicate records" do

0 commit comments

Comments
 (0)