Skip to content

Commit 1cd3007

Browse files
committed
Improve vaccination record summary list change links
This adds change links to this component when the values don't yet exist, but the state of the vaccination record implies that they should (via the administered at date), allowing these to be changed.
1 parent 263269f commit 1cd3007

File tree

2 files changed

+76
-48
lines changed

2 files changed

+76
-48
lines changed

app/components/app_vaccination_record_summary_component.rb

Lines changed: 72 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,82 +42,106 @@ def call
4242
end
4343
end
4444

45-
if @vaccine.present?
45+
if @vaccination_record.administered?
4646
summary_list.with_row do |row|
4747
row.with_key { "Vaccine" }
48-
row.with_value { vaccine_value }
49-
50-
if (href = @change_links[:vaccine])
51-
row.with_action(
52-
text: "Change",
53-
visually_hidden_text: "vaccine",
54-
href:
55-
)
48+
49+
if @vaccine
50+
row.with_value { vaccine_value }
51+
52+
if (href = @change_links[:vaccine])
53+
row.with_action(
54+
text: "Change",
55+
visually_hidden_text: "vaccine",
56+
href:
57+
)
58+
end
59+
elsif (href = @change_links[:vaccine])
60+
row.with_value { link_to "Add vaccine", href }
61+
else
62+
row.with_value { "Not provided" }
5663
end
5764
end
58-
end
5965

60-
if @batch.present?
6166
summary_list.with_row do |row|
6267
row.with_key { "Batch ID" }
63-
row.with_value(classes: ["app-u-monospace"]) { batch_id_value }
64-
65-
if (href = @change_links[:batch])
66-
row.with_action(
67-
text: "Change",
68-
href:,
69-
visually_hidden_text: "batch"
70-
)
68+
69+
if @batch
70+
row.with_value(classes: ["app-u-monospace"]) { batch_id_value }
71+
72+
if (href = @change_links[:batch])
73+
row.with_action(
74+
text: "Change",
75+
href:,
76+
visually_hidden_text: "batch"
77+
)
78+
end
79+
elsif (href = @change_links[:batch])
80+
row.with_value { link_to "Add batch", href }
81+
else
82+
row.with_value { "Not provided" }
7183
end
7284
end
7385

74-
summary_list.with_row do |row|
75-
row.with_key { "Batch expiry date" }
76-
row.with_value { batch_expiry_value }
86+
if @batch
87+
summary_list.with_row do |row|
88+
row.with_key { "Batch expiry date" }
89+
row.with_value { batch_expiry_value }
90+
end
7791
end
78-
end
7992

80-
if @vaccination_record.delivery_method.present?
8193
summary_list.with_row do |row|
8294
row.with_key { "Method" }
83-
row.with_value { delivery_method_value }
84-
85-
if (href = @change_links[:delivery_method])
86-
row.with_action(
87-
text: "Change",
88-
href:,
89-
visually_hidden_text: "method"
90-
)
95+
96+
if @vaccination_record.delivery_method.present?
97+
row.with_value { delivery_method_value }
98+
99+
if (href = @change_links[:delivery_method])
100+
row.with_action(
101+
text: "Change",
102+
href:,
103+
visually_hidden_text: "method"
104+
)
105+
end
106+
elsif (href = @change_links[:delivery_method])
107+
row.with_value { link_to "Add method", href }
108+
else
109+
row.with_value { "Not provided" }
91110
end
92111
end
93-
end
94112

95-
if @vaccination_record.delivery_site.present?
96113
summary_list.with_row do |row|
97114
row.with_key { "Site" }
98-
row.with_value { delivery_site_value }
99-
100-
if (href = @change_links[:delivery_site])
101-
row.with_action(
102-
text: "Change",
103-
href:,
104-
visually_hidden_text: "method"
105-
)
115+
116+
if @vaccination_record.delivery_site.present?
117+
row.with_value { delivery_site_value }
118+
119+
if (href = @change_links[:delivery_site])
120+
row.with_action(
121+
text: "Change",
122+
href:,
123+
visually_hidden_text: "method"
124+
)
125+
end
126+
elsif (href = @change_links[:delivery_site])
127+
row.with_value { link_to "Add site", href }
128+
else
129+
row.with_value { "Not provided" }
106130
end
107131
end
108132
end
109133

110-
if @vaccine.present?
134+
if @vaccination_record.administered?
111135
summary_list.with_row do |row|
112136
row.with_key { "Dose volume" }
113137
row.with_value { dose_volume_value }
114138
end
115-
end
116139

117-
if dose_number.present?
118-
summary_list.with_row do |row|
119-
row.with_key { "Dose number" }
120-
row.with_value { dose_number_value }
140+
if dose_number.present?
141+
summary_list.with_row do |row|
142+
row.with_key { "Dose number" }
143+
row.with_value { dose_number_value }
144+
end
121145
end
122146
end
123147

spec/components/app_vaccination_record_summary_component_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
end
7676

7777
context "without a vaccine" do
78+
let(:administered_at) { nil }
7879
let(:vaccine) { nil }
7980
let(:batch) { nil }
8081
let(:other_batch) { nil }
@@ -110,6 +111,7 @@
110111
end
111112

112113
context "without a vaccine" do
114+
let(:administered_at) { nil }
113115
let(:vaccine) { nil }
114116
let(:batch) { nil }
115117
let(:other_batch) { nil }
@@ -151,6 +153,7 @@
151153
it { should have_css(".nhsuk-summary-list__row", text: "Batch ID\nABC") }
152154

153155
context "without a vaccine" do
156+
let(:administered_at) { nil }
154157
let(:vaccine) { nil }
155158
let(:batch) { nil }
156159
let(:other_batch) { nil }
@@ -168,6 +171,7 @@
168171
end
169172

170173
context "without a vaccine" do
174+
let(:administered_at) { nil }
171175
let(:vaccine) { nil }
172176
let(:batch) { nil }
173177
let(:other_batch) { nil }

0 commit comments

Comments
 (0)