generated from hmcts/expressjs-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmanual-upload.njk
348 lines (326 loc) · 19.2 KB
/
manual-upload.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
{% from "../macros/common-components.njk" import goBack, submitButton, autoCompleteFilteredResults %}
{% extends "../template.njk" %}
{% from "govuk/components/file-upload/macro.njk" import govukFileUpload %}
{% from "govuk/components/select/macro.njk" import govukSelect %}
{% from "govuk/components/input/macro.njk" import govukInput %}
{% from "govuk/components/warning-text/macro.njk" import govukWarningText %}
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
{% block pageTitle %}
{{ title }}
{% endblock %}
{% block beforeContent %}
{{ super() }}
{{ goBack(cspNonce = cspNonce) }}
{% endblock %}
{% block content %}
{% if errors.fileErrors
or errors.formErrors.courtError
or errors.formErrors.listTypeError
or errors.formErrors.contentDateError
or errors.formErrors.classificationError
or errors.formErrors.displayDateError.from
or errors.formErrors.displayDateError.to %}
{% set errorList = [] %}
{% if errors.fileErrors %}
{% set errorList = (errorList.push({ text: errors.fileErrors, href: "#manual-file-upload" }), errorList) %}
{% endif %}
{% if errors.formErrors.courtError %}
{% set errorList = (errorList.push({ text: errors.formErrors.courtError, href: "#search-input" }), errorList) %}
{% endif %}
{% if errors.formErrors.listTypeError %}
{% set errorList = (errorList.push({ text: listTypeError, href: "#listType" }), errorList) %}
{% endif %}
{% if errors.formErrors.contentDateError %}
{% set errorList = (errorList.push({ text: errors.formErrors.contentDateError, href: "#content-date-from" }), errorList) %}
{% endif %}
{% if errors.formErrors.classificationError %}
{% set errorList = (errorList.push({ text: classificationError, href: "#classification" }), errorList) %}
{% endif %}
{% if errors.formErrors.displayDateError.from %}
{% set errorList = (errorList.push({ text: errors.formErrors.displayDateError.from, href: "#display-date-from" }), errorList) %}
{% endif %}
{% if errors.formErrors.displayDateError.to %}
{% set errorList = (errorList.push({ text: errors.formErrors.displayDateError.to, href: "#display-date-to" }), errorList) %}
{% endif %}
{% if errors.formErrors.displayDateError.range %}
{% set errorList = (errorList.push({ text: errors.formErrors.displayDateError.range, href: "#display-date-from" }), errorList) %}
{% endif %}
{{ govukErrorSummary({
titleText: errorTitle,
errorList: errorList
}) }}
{% endif %}
<div class="parent-box">
<div class="govuk-callout">
<h2 class="govuk-heading-m">{{ warning }}</h2>
{{ govukWarningText({
text: warningText
}) }}
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">{{ title }}</h1>
<form method="post" enctype="multipart/form-data">
{% set fileErrorMessage = {text: errors.fileErrors} if errors.fileErrors else false %}
<div class="govuk-inset-text">
{% if nonStrategicUpload %}
{{ govukFileUpload({
id: "manual-file-upload",
name: "manual-file-upload",
accept: ".xslx",
label: {
text: nonStrategicCardFileUploadText
},
errorMessage: fileErrorMessage
}) }}
{% else %}
{{ govukFileUpload({
id: "manual-file-upload",
name: "manual-file-upload",
accept: ".json,.csv,.doc,.docx,.htm,.html",
label: {
text: fileUploadText
},
errorMessage: fileErrorMessage
}) }}
{% endif %}
</div>
{% set courtFormGroupError = 'govuk-form-group--error' if errors.formErrors.courtError else 'govuk-form-group' %}
{% set inputError = 'govuk-input--error' if errors.formErrors.courtError else '' %}
<div id="form-wrapper" class="govuk-!-margin-bottom-9 ">
<div class="govuk-!-margin-bottom-3 govuk-!-width-one-half {{ courtFormGroupError }}">
<label id="search-input-title" class="govuk-label" for="search-input">
{{ form.court }}
</label>
{% if errors.formErrors.courtError %}
<span class="govuk-error-message">{{ errors.formErrors.courtError }}</span>
{% endif %}
<div class="{{ inputError }}" id="search-input-container"></div>
</div>
{% set listTypeErrorMessage = {text: listTypeError} if errors.formErrors.listTypeError else '' %}
<div class="govuk-form-group govuk-inset-text govuk-!-padding-right-0">
<div id="list-question" class="govuk-!-margin-bottom-3 govuk-!-width-two-third">
{{ govukSelect({
classes: 'govuk-!-width-two-thirds',
id: "listType",
name: "listType",
label: {
text: form.listType
},
errorMessage: listTypeErrorMessage,
items: listItems.listSubtypes
}) }}
</div>
{% set cdFromError = 'govuk-input--error' if errors.formErrors.contentDateError else '' %}
{% set cdFormGroupError = 'govuk-form-group--error' if errors.formErrors.contentDateError else 'govuk-form-group' %}
<div class="{{ cdFormGroupError }} govuk-width-!-one-fourth">
<fieldset class="govuk-fieldset" role="group" aria-describedby="content-date">
<legend class="govuk-fieldset__legend">
{{ form.contentDate }}
</legend>
{% if errors.formErrors.contentDateError %}
<span class="govuk-error-message">{{ errors.formErrors.contentDateError }}</span>
{% endif %}
<div id="content-date-hint" class="govuk-hint">
{{ form.contentDateHint }}
</div>
<div class="govuk-date-input" id="content-date-from">
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="content-date-from-day">
{{ form.day }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-2 {{ cdFromError }}" id="content-date-from-day" name="content-date-from-day" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="content-date-from-month">
{{ form.month }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-2 {{ cdFromError }}" id="content-date-from-month" name="content-date-from-month" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="content-date-from-year">
{{ form.year }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-4 {{ cdFromError }}" id="content-date-from-year" name="content-date-from-year" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
</div>
</fieldset>
</div>
</div>
{% set availableToErrorMessage = {text: classificationError } if errors.formErrors.classificationError else '' %}
{{ govukSelect({
classes: 'govuk-!-width-one-half',
id: "classification",
name: "classification",
label: {
text: form.classificationText
},
items: form.classification,
errorMessage: availableToErrorMessage
}) }}
{{ govukSelect({
classes: 'govuk-!-width-one-half',
id: "language",
name: "language",
label: {
text: form.languageText
},
items: form.language
}) }}
{% set displayFromError = 'govuk-input--error' if errors.formErrors.displayDateError.from else '' %}
{% set displayToError = 'govuk-input--error' if errors.formErrors.displayDateError.to else '' %}
{% set displayFormGroupError = 'govuk-form-group--error' if errors.formErrors.displayDateError else 'govuk-form-group' %}
{% set displayErrorMessage = errors.formErrors.displayDateError.from or errors.formErrors.displayDateError.to or errors.formErrors.displayDateError.range%}
{% set displayFromErrorMessage = errors.formErrors.displayDateError.from or errors.formErrors.displayDateError.range%}
{% set displayToErrorMessage = errors.formErrors.displayDateError.to or errors.formErrors.displayDateError.range%}
<div class="{{ displayFormGroupError }}">
<fieldset class="govuk-fieldset" role="group" aria-describedby="display-date-from">
<legend class="govuk-fieldset__legend">{{ form.displayDateFrom }}</legend>
{% if errors.formErrors.displayDateError %}
<span class="govuk-error-message">{{ displayFromErrorMessage }}</span>
{% endif %}
<div id="display-date-hint" class="govuk-hint">
{{ form.displayDateFromHint }}
</div>
<div class="govuk-date-input" id="display-date-from">
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="display-date-from-day">
{{ form.day }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-2 {{ displayFromError }}" id="display-date-from-day" name="display-date-from-day" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="display-date-from-month">
{{ form.month }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-2 {{ displayFromError }}" id="display-date-from-month" name="display-date-from-month" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="display-date-from-year">
{{ form.year }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-4 {{ displayFromError }}" id="display-date-from-year" name="display-date-from-year" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
</div>
</fieldset>
<fieldset class="govuk-fieldset govuk-!-margin-top-6" role="group" aria-describedby="display-date-to">
<legend class="govuk-fieldset__legend">{{ form.displayDateTo }}</legend>
{% if errors.formErrors.displayDateError %}
<span class="govuk-error-message">{{ displayToErrorMessage }}</span>
{% endif %}
<div id="display-date-to-hint" class="govuk-hint">
{{ form.displayDateToHint }}
</div>
<div class="govuk-date-input" id="display-date-to">
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="display-date-to-day">
{{ form.day }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-2 {{ displayToError }}" id="display-date-to-day" name="display-date-to-day" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="display-date-to-month">
{{ form.month }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-2 {{ displayToError }}" id="display-date-to-month" name="display-date-to-month" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
<div class="govuk-date-input__item">
<div class="govuk-form-group">
<label class="govuk-label govuk-date-input__label" for="display-date-to-year">
{{ form.year }}
</label>
<input class="govuk-input govuk-date-input__input govuk-input--width-4 {{ displayToError }}" id="display-date-to-year" name="display-date-to-year" type="text" pattern="[0-9]*" inputmode="numeric"></div>
</div>
</div>
</fieldset>
</div>
</div>
{{ submitButton(continueButton) }}
</form>
</div>
<div class="govuk-grid-column-one-third">
<h2 class="govuk-heading-l">{{ pageHelpHeading }}</h2>
<h3 class="govuk-heading-s">{{ pageHelp[0].heading }}</h3>
<p class="govuk-body">{{ pageHelp[0].text }}</p>
<h3 class="govuk-heading-s">{{ pageHelp[1].heading }}</h3>
<p class="govuk-body">{{ pageHelp[1].text }}</p>
<h3 class="govuk-heading-s no-margin-bottom">{{ pageHelp[2].heading }}</h3>
<p class="govuk-body">{{ pageHelp[2].text }}</p>
<h3 class="govuk-heading-s no-margin-bottom">{{ pageHelp[3].heading }}</h3>
<p class="govuk-body">{{ pageHelp[3].text }}</p>
<h3 class="govuk-heading-s no-margin-bottom">{{ pageHelp[4].heading }}</h3>
<p class="govuk-body">{{ pageHelp[4].text }}</p>
<h3 class="govuk-heading-s no-margin-bottom">{{ pageHelp[5].heading }}</h3>
<p class="govuk-body">{{ pageHelp[5].text }}</p>
<h3 class="govuk-heading-s no-margin-bottom">{{ pageHelp[6].heading }}</h3>
<p class="govuk-body">{{ pageHelp[6].text }}</p>
</div>
</div>
{{ super() }}
</div>
{% endblock %}
{% block bodyEnd %}
<script src="/assets/js/accessible-autocomplete.min.js"></script>
<script nonce="{{ cspNonce}}">
{% set optionList = [] %}
{% for item in listItems.courtList %}
{% set _ = optionList.push(
item.name
) %}
{% endfor %}
{% set defaultValue = formData['input-autocomplete'] if formData['input-autocomplete'] else '' %}
{% set populatedContentDateFromDay = formData['content-date-from-day'] if formData['content-date-from-day'] else '' %}
{% set populatedContentDateFromMonth = formData['content-date-from-month'] if formData['content-date-from-month'] else '' %}
{% set populatedContentDateFromYear = formData['content-date-from-year'] if formData['content-date-from-year'] else '' %}
{% set populatedClassification = formData['classification'] if formData['classification'] else '' %}
{% set populatedLanguage = formData['language'] if formData['language'] else 'ENGLISH' %}
{% set populatedDisplayDateFromDay = formData['display-date-from-day'] if formData['display-date-from-day'] else '' %}
{% set populatedDisplayDateFromMonth = formData['display-date-from-month'] if formData['display-date-from-month'] else '' %}
{% set populatedDisplayDateFromYear = formData['display-date-from-year'] if formData['display-date-from-year'] else '' %}
{% set populatedDisplayDateToDay = formData['display-date-to-day'] if formData['display-date-to-day'] else '' %}
{% set populatedDisplayDateToMonth = formData['display-date-to-month'] if formData['display-date-to-month'] else '' %}
{% set populatedDisplayDateToYear = formData['display-date-to-year'] if formData['display-date-to-year'] else '' %}
document.getElementById('content-date-from-day').value = {{ populatedContentDateFromDay | dump | safe }};
document.getElementById('content-date-from-month').value = {{ populatedContentDateFromMonth | dump | safe }};
document.getElementById('content-date-from-year').value = {{ populatedContentDateFromYear | dump | safe }};
document.getElementById('classification').value = {{ populatedClassification | dump | safe }};
document.getElementById('language').value = {{ populatedLanguage | dump | safe }};
document.getElementById('display-date-from-day').value = {{ populatedDisplayDateFromDay | dump | safe }};
document.getElementById('display-date-from-month').value = {{ populatedDisplayDateFromMonth | dump | safe }};
document.getElementById('display-date-from-year').value = {{ populatedDisplayDateFromYear | dump | safe }};
document.getElementById('display-date-to-day').value = {{ populatedDisplayDateToDay | dump | safe }};
document.getElementById('display-date-to-month').value = {{ populatedDisplayDateToMonth | dump | safe }};
document.getElementById('display-date-to-year').value = {{ populatedDisplayDateToYear | dump | safe }};
const defaultVal = {{ defaultValue | dump | safe }}
const element = document.querySelector('#search-input-container');
const source = {{ optionList | dump |safe }};
const autocompleteParam = {
element: element,
id: 'search-input',
displayMenu: 'overlay',
defaultValue: defaultVal,
};
if (window.history.replaceState) {
window.history.replaceState(null, null, window.location.href);
}
function onListTypeChange() {
let listType = document.getElementById('listType').value;
let listTypeClassifications = {{ listTypeClassifications | dump | safe }}
document.getElementById('classification').value = listTypeClassifications[listType];
}
document.getElementById('listType').addEventListener("change", onListTypeChange)
// Set first govuk-grid-row back to display block as custom scss is written to change it to flex as that is required on other pages
// Block is required on this page so the help section goes underneath the form on mobile devices
document.querySelectorAll(".govuk-grid-row")[0].style.display = 'block';
</script>
{{ autoCompleteFilteredResults(autocompleteParam, cspNonce) }}
{{ super() }}
{% endblock %}