Skip to content

Commit 632225e

Browse files
Simplify radios and checkboxes macro options (#448)
This removes the remaining use of the `checked` param on radio and checkbox items, instead setting either `value` or `values` at the top level in the macro, which is simpler and easier to maintain. This feature was added in NHS frontend 9.2.0: https://github.com/nhsuk/nhsuk-frontend/releases/tag/v9.2.0
1 parent 03e1d64 commit 632225e

32 files changed

+162
-276
lines changed

app/views/alerts/new.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,15 @@ <h1 class="nhsuk-heading-l">{{ pageName }}</h1>
6565
classes: "nhsuk-fieldset__legend--s"
6666
}
6767
},
68+
value: data.packType,
6869
"items": [
6970
{
7071
"value": "Single vial",
71-
"text": "Single vial",
72-
checked: (data.packType == "Single vial")
72+
"text": "Single vial"
7373
},
7474
{
7575
"value": "10 vials",
76-
"text": "10 vials",
77-
checked: (data.packType == "10 vials")
76+
"text": "10 vials"
7877
}
7978
]
8079
}) }}

app/views/lists/record/batch.html

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"isPageHeading": true
3838
}
3939
},
40+
value: data.vaccineBatch,
4041
errorMessage: {
4142
text: error.text
4243
} if error,
@@ -46,40 +47,35 @@
4647
"text": "AB2345",
4748
hint: {
4849
text: "Expires 14 August 2025"
49-
},
50-
checked: (data.vaccineBatch == "AB2345")
50+
}
5151
},
5252
{
5353
"value": "DE8342",
5454
"text": "DE8342",
5555
hint: {
5656
text: "Expires 19 August 2025"
57-
},
58-
checked: (data.vaccineBatch == "DE8342")
57+
}
5958
},
6059
{
6160
"value": "LF842",
6261
"text": "LF842",
6362
hint: {
6463
text: "Expires 28 August 2025"
65-
},
66-
checked: (data.vaccineBatch == "LF842")
64+
}
6765
},
6866
{
6967
"value": "JD8352",
7068
"text": "JD8352",
7169
hint: {
7270
text: "Expires 3 September 2025"
73-
},
74-
checked: (data.vaccineBatch == "JD8352")
71+
}
7572
},
7673
{
7774
divider: "or"
7875
},
7976
{
8077
"value": "add-new",
81-
"text": "Add a batch",
82-
checked: (data.vaccineBatch == "add-new")
78+
"text": "Add a batch"
8379
}
8480
]
8581
}) }}

app/views/lists/record/consent.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,51 +134,46 @@
134134
errorMessage: {
135135
text: consentError.text
136136
} if consentError,
137+
value: data.consent,
137138
items: [
138139
{
139140
value: 'patient',
140-
text: (data.patientName or "Michael James"),
141-
checked: (data.consent === 'patient')
141+
text: (data.patientName or "Michael James")
142142
},
143143
{
144144
divider: "or"
145145
},
146146
{
147147
value: "Clinician acting in the patient’s best interests",
148148
text: "Clinician acting in the patient’s best interests",
149-
checked: (data.consent === "Clinician acting in the patient’s best interests"),
150149
conditional: {
151150
html: consentClinicianHtml
152151
}
153152
},
154153
{
155154
value: "Person with lasting power of attorney for health and welfare",
156155
text: "Person with lasting power of attorney for health and welfare",
157-
checked: (data.consent === "Person with lasting power of attorney for health and welfare"),
158156
conditional: {
159157
html: consentAttorneyHtml
160158
}
161159
},
162160
{
163161
value: "Parent or guardian",
164162
text: "Parent or guardian",
165-
checked: (data.consent === "Parent or guardian"),
166163
conditional: {
167164
html: consentParentHtml
168165
}
169166
},
170167
{
171168
value: "Independent mental capacity advocate",
172169
text: "Independent mental capacity advocate",
173-
checked: (data.consent === "Independent mental capacity advocate"),
174170
conditional: {
175171
html: consentAdvocateHtml
176172
}
177173
},
178174
{
179175
value: "Court appointed deputy",
180176
text: "Court appointed deputy",
181-
checked: (data.consent === "Court appointed deputy"),
182177
conditional: {
183178
html: consentDeputyHtml
184179
}

app/views/lists/record/eligibility.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
{% for option in eligibilityOptions %}
6767
{% set items = (items.push({
6868
text: option,
69-
value: option,
70-
checked: (data.eligibility | arrayOrStringIncludes(option))
69+
value: option
7170
}), items) %}
7271
{% endfor %}
7372

@@ -82,6 +81,7 @@
8281
isPageHeading: true
8382
}
8483
},
84+
value: data.eligibility,
8585
items: items
8686
}) }}
8787
{% else %}
@@ -91,6 +91,7 @@
9191
errorMessage: {
9292
text: (errors | first).text
9393
} if (errors | length) > 0,
94+
values: data.eligibility,
9495
fieldset: {
9596
legend: {
9697
text: "Why are you giving them the vaccine?",

app/views/lists/record/injection-site.html

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,26 @@
3636
classes: "nhsuk-fieldset__legend--s"
3737
}
3838
},
39+
value: data.otherInjectionSite,
3940
errorMessage: {
4041
text: otherInjectionSiteError.text
4142
} if otherInjectionSiteError,
4243
items: [
4344
{
4445
value: "Left buttock",
45-
text: "Left buttock",
46-
checked: (data.otherInjectionSite == "Left buttock")
46+
text: "Left buttock"
4747
},
4848
{
4949
value: "Right buttock",
50-
text: "Right buttock",
51-
checked: (data.otherInjectionSite == "Right buttock")
50+
text: "Right buttock"
5251
},
5352
{
5453
value: "Left thigh",
55-
text: "Left thigh",
56-
checked: (data.otherInjectionSite == "Left thigh")
54+
text: "Left thigh"
5755
},
5856
{
5957
value: "Right thigh",
60-
text: "Right thigh",
61-
checked: (data.otherInjectionSite == "Right thigh")
58+
text: "Right thigh"
6259
}
6360
]
6461
}) }}
@@ -78,24 +75,22 @@
7875
errorMessage: {
7976
text: injectionSiteError.text
8077
} if injectionSiteError,
78+
value: data.injectionSite,
8179
items: [
8280
{
8381
value: "Left arm",
84-
text: "Left arm",
85-
checked: (data.injectionSite == 'Left arm')
82+
text: "Left arm"
8683
},
8784
{
8885
value: "Right arm",
89-
text: "Right arm",
90-
checked: (data.injectionSite == 'Right arm')
86+
text: "Right arm"
9187
},
9288
{
9389
divider: "or"
9490
},
9591
{
9692
value: "other",
9793
text: "Somewhere else",
98-
checked: (data.injectionSite == 'other'),
9994
conditional: {
10095
html: somewhereElseHtml
10196
}

app/views/lists/record/location.html

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,47 +70,41 @@
7070
isPageHeading: true
7171
}
7272
},
73+
value: data.locationType,
7374
hint: {
7475
text: "This is needed for payment and reporting."
7576
},
7677
items: [
7778
{
7879
text: "Hospital hub for staff and patients",
79-
value: "Hospital hub for staff and patients",
80-
checked: (data.locationType === "Hospital hub for staff and patients")
80+
value: "Hospital hub for staff and patients"
8181
},
8282
{
8383
text: "Vaccination centre open to the public",
84-
value: "Vaccination centre open to the public",
85-
checked: (data.locationType === "Vaccination centre open to the public")
84+
value: "Vaccination centre open to the public"
8685
},
8786
{
8887
text: "Community pharmacy",
89-
value: "Community pharmacy",
90-
checked: (data.locationType === "Community pharmacy")
88+
value: "Community pharmacy"
9189
},
9290
{
9391
value: "Care home",
9492
text: "Care home",
95-
checked: (data.locationType === "Care home"),
9693
conditional: {
9794
html: careHtml
9895
}
9996
},
10097
{
10198
text: "Housebound patient’s home",
102-
value: "Housebound patient’s home",
103-
checked: (data.locationType === "Housebound patient’s home")
99+
value: "Housebound patient’s home"
104100
},
105101
{
106102
text: "Outreach event",
107-
value: "Outreach event",
108-
checked: (data.locationType === "Outreach event")
103+
value: "Outreach event"
109104
},
110105
{
111106
text: "GP clinic",
112-
value: "GP clinic",
113-
checked: (data.locationType === "GP clinic")
107+
value: "GP clinic"
114108
}
115109
]
116110

app/views/lists/record/vaccinator.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,25 @@ <h1 class="nhsuk-label-wrapper">
6868
isPageHeading: "true"
6969
}
7070
},
71+
value: data.vaccinator,
7172
errorMessage: {
7273
text: vaccinatorError
7374
} if vaccinatorError,
7475
items: [
7576
{
7677
value: "Jane Smith",
77-
text: "Me (Jane Smith)",
78-
checked: (data.vaccinator === "Jane Smith")
78+
text: "Me (Jane Smith)"
7979
},
8080
{
8181
value: "Anna Brown",
82-
text: "Anna Brown ([email protected])",
83-
checked: (data.vaccinator === "Anna Brown")
82+
text: "Anna Brown ([email protected])"
8483
},
8584
{
8685
divider: "or"
8786
},
8887
{
8988
value: "Someone else",
9089
text: "Someone else",
91-
checked: (data.vaccinator === "Someone else"),
9290
conditional: {
9391
html: otherVaccinatorHtml
9492
}

0 commit comments

Comments
 (0)