@defra/forms-engine-plugin 5.0.0-alpha.2 → 5.0.0-alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.public/javascripts/application.min.js +1 -1
  2. package/.public/javascripts/application.min.js.map +1 -1
  3. package/.public/javascripts/shared.min.js +1 -1
  4. package/.public/javascripts/shared.min.js.map +1 -1
  5. package/.server/client/javascripts/file-upload.js +5 -3
  6. package/.server/client/javascripts/file-upload.js.map +1 -1
  7. package/.server/server/plugins/engine/components/AutocompleteField.d.ts +1 -0
  8. package/.server/server/plugins/engine/components/DatePartsField.d.ts +1 -0
  9. package/.server/server/plugins/engine/components/DeclarationField.d.ts +1 -0
  10. package/.server/server/plugins/engine/components/Details.d.ts +1 -0
  11. package/.server/server/plugins/engine/components/EastingNorthingField.d.ts +2 -0
  12. package/.server/server/plugins/engine/components/EmailAddressField.d.ts +1 -0
  13. package/.server/server/plugins/engine/components/FileUploadField.js +2 -2
  14. package/.server/server/plugins/engine/components/FileUploadField.js.map +1 -1
  15. package/.server/server/plugins/engine/components/FormComponent.d.ts +1 -0
  16. package/.server/server/plugins/engine/components/GeospatialField.d.ts +1 -0
  17. package/.server/server/plugins/engine/components/Html.d.ts +1 -0
  18. package/.server/server/plugins/engine/components/InsetText.d.ts +1 -0
  19. package/.server/server/plugins/engine/components/LatLongField.d.ts +2 -0
  20. package/.server/server/plugins/engine/components/List.d.ts +1 -0
  21. package/.server/server/plugins/engine/components/ListFormComponent.d.ts +1 -0
  22. package/.server/server/plugins/engine/components/LocationFieldBase.d.ts +2 -0
  23. package/.server/server/plugins/engine/components/LocationFieldHelpers.d.ts +2 -0
  24. package/.server/server/plugins/engine/components/Markdown.d.ts +1 -0
  25. package/.server/server/plugins/engine/components/MonthYearField.d.ts +1 -0
  26. package/.server/server/plugins/engine/components/MultilineTextField.d.ts +1 -0
  27. package/.server/server/plugins/engine/components/NotificationBanner.d.ts +1 -0
  28. package/.server/server/plugins/engine/components/NumberField.d.ts +1 -0
  29. package/.server/server/plugins/engine/components/PaymentField.d.ts +2 -0
  30. package/.server/server/plugins/engine/components/PaymentField.js +8 -1
  31. package/.server/server/plugins/engine/components/PaymentField.js.map +1 -1
  32. package/.server/server/plugins/engine/components/SelectField.d.ts +1 -0
  33. package/.server/server/plugins/engine/components/SelectionControlField.d.ts +1 -0
  34. package/.server/server/plugins/engine/components/TelephoneNumberField.d.ts +1 -0
  35. package/.server/server/plugins/engine/components/UkAddressField.d.ts +1 -0
  36. package/.server/server/plugins/engine/components/types.d.ts +1 -0
  37. package/.server/server/plugins/engine/components/types.js.map +1 -1
  38. package/.server/server/plugins/engine/i18n/createFormTranslator.js +7 -0
  39. package/.server/server/plugins/engine/i18n/createFormTranslator.js.map +1 -1
  40. package/.server/server/plugins/engine/i18n/translations/cy.json +53 -3
  41. package/.server/server/plugins/engine/i18n/translations/en-GB.json +24 -2
  42. package/.server/server/plugins/engine/i18n/types.d.ts +1 -0
  43. package/.server/server/plugins/engine/i18n/types.js.map +1 -1
  44. package/.server/server/plugins/engine/pageControllers/FileUploadPageController.js +20 -7
  45. package/.server/server/plugins/engine/pageControllers/FileUploadPageController.js.map +1 -1
  46. package/.server/server/plugins/engine/pageControllers/QuestionPageController.js +5 -1
  47. package/.server/server/plugins/engine/pageControllers/QuestionPageController.js.map +1 -1
  48. package/.server/server/plugins/engine/views/components/fileuploadfield.html +1 -1
  49. package/.server/server/plugins/engine/views/components/multilinetextfield.html +12 -1
  50. package/.server/server/plugins/engine/views/components/paymentfield.html +1 -1
  51. package/.server/server/plugins/engine/views/partials/preview-banner.html +3 -1
  52. package/package.json +1 -1
  53. package/src/client/javascripts/file-upload.js +10 -3
  54. package/src/server/plugins/engine/components/FileUploadField.ts +2 -2
  55. package/src/server/plugins/engine/components/PaymentField.ts +6 -1
  56. package/src/server/plugins/engine/components/types.ts +1 -0
  57. package/src/server/plugins/engine/i18n/createFormTranslator.ts +21 -1
  58. package/src/server/plugins/engine/i18n/translations/cy.json +53 -3
  59. package/src/server/plugins/engine/i18n/translations/en-GB.json +24 -2
  60. package/src/server/plugins/engine/i18n/types.ts +1 -0
  61. package/src/server/plugins/engine/pageControllers/FileUploadPageController.ts +16 -6
  62. package/src/server/plugins/engine/pageControllers/QuestionPageController.ts +8 -3
  63. package/src/server/plugins/engine/views/components/fileuploadfield.html +1 -1
  64. package/src/server/plugins/engine/views/components/multilinetextfield.html +12 -1
  65. package/src/server/plugins/engine/views/components/paymentfield.html +1 -1
  66. package/src/server/plugins/engine/views/partials/preview-banner.html +3 -1
@@ -60,6 +60,12 @@
60
60
  "totalAmount": "Cyfanswm",
61
61
  "reference": "Cyfeirnod",
62
62
  "dateOfPayment": "Dyddiad talu",
63
+ "fileUpload_zero": "Ni uwchlwythwyd unrhyw ffeiliau",
64
+ "fileUpload_one": "Uwchlwythwyd [[count]] ffeil",
65
+ "fileUpload_two": "Uwchlwythwyd dwy feil",
66
+ "fileUpload_few": "Uwchlwythwyd [[count]] ffeil",
67
+ "fileUpload_many": "Uwchlwythwyd [[count]] o ffeiliau",
68
+ "fileUpload_other": "Uwchlwythwyd [[count]] ffeil",
63
69
  "submissionFailed": "Roedd problem ac ni chyflwynwyd eich ffurflen. Ceisiwch gyflwyno'r ffurflen eto",
64
70
  "submissionFailedContactSuffix": " neu gallwch [[contactUsLink]] a dyfynnu'ch cyfeirnod i drefnu ad-daliad",
65
71
  "contactUsLinkText": "cysylltu â ni (yn agor mewn tab newydd)",
@@ -79,17 +85,34 @@
79
85
  "change": "Newid",
80
86
  "notProvided": "Heb ei ddarparu",
81
87
  "visuallyHiddenItem": "eitem [[index]]",
88
+ "pageTitle_zero": "Nid ydych wedi ychwanegu unrhyw atebion",
82
89
  "pageTitle_one": "Rydych wedi ychwanegu [[count]] ateb",
90
+ "pageTitle_two": "Rydych wedi ychwanegu dau ateb",
91
+ "pageTitle_few": "Rydych wedi ychwanegu [[count]] ateb",
92
+ "pageTitle_many": "Rydych wedi ychwanegu [[count]] o atebion",
83
93
  "pageTitle_other": "Rydych wedi ychwanegu [[count]] ateb",
94
+ "tooMany_zero": "Ni allwch ychwanegu unrhyw atebion",
84
95
  "tooMany_one": "Dim ond hyd at [[count]] ateb y gallwch ei ychwanegu",
96
+ "tooMany_two": "Dim ond hyd at ddau gateb y gallwch eu hychwanegu",
97
+ "tooMany_few": "Dim ond hyd at [[count]] ateb y gallwch eu hychwanegu",
98
+ "tooMany_many": "Dim ond hyd at [[count]] o atebion y gallwch eu hychwanegu",
85
99
  "tooMany_other": "Dim ond hyd at [[count]] ateb y gallwch eu hychwanegu",
100
+ "tooFew_zero": "Rhaid i chi ychwanegu atebion",
86
101
  "tooFew_one": "Rhaid i chi ychwanegu o leiaf [[count]] ateb",
102
+ "tooFew_two": "Rhaid i chi ychwanegu o leiaf ddau gateb",
103
+ "tooFew_few": "Rhaid i chi ychwanegu o leiaf [[count]] ateb",
104
+ "tooFew_many": "Rhaid i chi ychwanegu o leiaf [[count]] o atebion",
87
105
  "tooFew_other": "Rhaid i chi ychwanegu o leiaf [[count]] ateb"
88
106
  },
89
107
 
90
108
  "fileUpload": {
91
109
  "upload": "Uwchlwytho ffeil",
92
- "maxFilesReached": "Rydych wedi cyrraedd nifer uchaf y ffeiliau. Tynnwch ffeil i uwchlwytho rhagor."
110
+ "maxFilesReached": "Rydych wedi cyrraedd nifer uchaf y ffeiliau. Tynnwch ffeil i uwchlwytho rhagor.",
111
+ "remove": "Tynnu",
112
+ "removeFileTitle": "Ydych chi'n siŵr eich bod chi eisiau dileu'r ffeil hon?",
113
+ "removeFileBody": "Ni allwch adfer ffeiliau a dynnwyd.",
114
+ "removeFileButton": "Dileu ffeil",
115
+ "cancel": "Canslo"
93
116
  },
94
117
 
95
118
  "exit": {
@@ -111,6 +134,7 @@
111
134
  "body": "Os hoffech dderbyn e-bost prawf, [[link]] yr hoffech i gyflwyniadau ffurflen fynd iddo.",
112
135
  "linkText": "nodwch y cyfeiriad e-bost (yn agor mewn tab newydd)"
113
136
  },
137
+ "bannerTitle": "Pwysig",
114
138
  "bannerForce": "Rhagolwg o ffurflen [[previewMode]] yw hon. Peidiwch â rhoi gwybodaeth bersonol.",
115
139
  "bannerText": "Dyma ragolwg o dudalen ffurflen [[previewMode]] rydych chi'n ei golygu.",
116
140
  "previousPages": "Mae'n dibynnu ar atebion o dudalennau cynharach yn y ffurflen. Yn y fersiwn fyw, bydd angen i ddefnyddwyr gwblhau'r cwestiynau hynny yn gyntaf."
@@ -134,7 +158,11 @@
134
158
  "findAnAddressInstead": "dod o hyd i gyfeiriad yn lle hynny",
135
159
  "noAddressFoundTitle": "Ni chanfuwyd cyfeiriad",
136
160
  "noAddressFoundBody": "Ni allem ddod o hyd i gyfeiriad cyfatebol",
161
+ "addressFound_zero": "Ni chanfuwyd unrhyw gyfeiriadau ar gyfer",
137
162
  "addressFound_one": "Canfuwyd [[count]] cyfeiriad ar gyfer",
163
+ "addressFound_two": "Canfuwyd dau gyfeiriad ar gyfer",
164
+ "addressFound_few": "Canfuwyd [[count]] chyfeiriad ar gyfer",
165
+ "addressFound_many": "Canfuwyd [[count]] o gyfeiriadau ar gyfer",
138
166
  "addressFound_other": "Canfuwyd [[count]] cyfeiriad ar gyfer",
139
167
  "validation": {
140
168
  "invalidPostcode": "Nodwch god post dilys neu nodwch gyfeiriad â llaw",
@@ -220,7 +248,7 @@
220
248
 
221
249
  "yesNoField": {
222
250
  "yes": "Ie",
223
- "no": "Na",
251
+ "no": "Nage",
224
252
  "validation": {
225
253
  "selectYesNoRequired": "{{#label}} - dewiswch ie neu na"
226
254
  }
@@ -236,7 +264,11 @@
236
264
  },
237
265
 
238
266
  "geospatialField": {
267
+ "added_zero": "Ni ychwanegwyd unrhyw leoliadau",
239
268
  "added_one": "Ychwanegwyd [[count]] lleoliad",
269
+ "added_two": "Ychwanegwyd dau leoliad",
270
+ "added_few": "Ychwanegwyd [[count]] lleoliad",
271
+ "added_many": "Ychwanegwyd [[count]] o leoliadau",
240
272
  "added_other": "Ychwanegwyd [[count]] lleoliad",
241
273
  "validation": {
242
274
  "descriptionRequired": "Rhowch ddisgrifiad ar gyfer lleoliad [[count]]",
@@ -245,7 +277,7 @@
245
277
  },
246
278
 
247
279
  "paymentField": {
248
- "detailsRequired": "Angen manylion talu",
280
+ "detailsRequired": "Angen talu",
249
281
  "pendingTransaction": "Mae'n bosibl y gwelwch drafodiad ar y gweill yn eich cyfrif banc ond dim ond pan fyddwch yn cyflwyno'r ffurflen y codir tâl arnoch.",
250
282
  "addPaymentDetails": "Ychwanegu manylion talu",
251
283
  "cannotTakePayment": "Mae problem ac ni allwn dderbyn taliad. Cysylltwch â ni (manylion yn nhroedyn y ffurflen hon) neu cadwch eich cynnydd a dychwelyd at y ffurflen yn ddiweddarach.",
@@ -261,11 +293,29 @@
261
293
  },
262
294
 
263
295
  "fileUploadField": {
296
+ "uploading": "Yn uwchlwytho…",
264
297
  "uploaded": "Wedi'i uwchlwytho",
265
298
  "uploadFailed": "Roedd problem gyda'ch ffeiliau a uwchlwythwyd. Uwchlwythwch nhw eto cyn cyflwyno'r ffurflen.",
266
299
  "uploadedFilesHeading": "Ffeiliau a uwchlwythwyd",
300
+ "filesCount_zero": "Uwchlwythwyd [[count]] o ffeiliau",
267
301
  "filesCount_one": "Uwchlwythwyd [[count]] ffeil",
302
+ "filesCount_two": "Uwchlwythwyd [[count]] ffeil",
303
+ "filesCount_few": "Uwchlwythwyd [[count]] ffeil",
304
+ "filesCount_many": "Uwchlwythwyd [[count]] o ffeiliau",
268
305
  "filesCount_other": "Uwchlwythwyd [[count]] ffeil"
306
+ },
307
+
308
+ "characterCount": {
309
+ "_comment": "Note the use of %{count} instead of [[count]]. This is because we are passing to the govuk template, not passing to Joi",
310
+ "underLimit": {
311
+ "one": "Mae gennych %{count} nod ar ôl",
312
+ "other": "Mae gennych %{count} nod ar ôl"
313
+ },
314
+ "atLimit": "Mae gennych 0 nod ar ôl",
315
+ "overLimit": {
316
+ "one": "Mae gennych %{count} nod yn ormod",
317
+ "other": "Mae gennych %{count} nod yn ormod"
318
+ }
269
319
  }
270
320
  }
271
321
  }
@@ -60,6 +60,8 @@
60
60
  "totalAmount": "Total amount",
61
61
  "reference": "Reference",
62
62
  "dateOfPayment": "Date of payment",
63
+ "fileUpload_one": "Uploaded [[count]] file",
64
+ "fileUpload_other": "Uploaded [[count]] files",
63
65
  "submissionFailed": "There was a problem and your form was not submitted. Try submitting the form again",
64
66
  "submissionFailedContactSuffix": " or you can [[contactUsLink]] and quote your reference number to arrange a refund",
65
67
  "contactUsLinkText": "contact us (opens in new tab)",
@@ -89,7 +91,12 @@
89
91
 
90
92
  "fileUpload": {
91
93
  "upload": "Upload file",
92
- "maxFilesReached": "You have reached the maximum number of files. Please remove a file to upload more."
94
+ "maxFilesReached": "You have reached the maximum number of files. Please remove a file to upload more.",
95
+ "remove": "Remove",
96
+ "removeFileTitle": "Are you sure you want to remove this file?",
97
+ "removeFileBody": "You cannot recover removed files.",
98
+ "removeFileButton": "Remove file",
99
+ "cancel": "Cancel"
93
100
  },
94
101
 
95
102
  "exit": {
@@ -111,6 +118,7 @@
111
118
  "body": "If you want to receive a test email, [[link]] you want form submissions to go to.",
112
119
  "linkText": "enter the email address (opens in new tab)"
113
120
  },
121
+ "bannerTitle": "Important",
114
122
  "bannerForce": "This is a preview of a [[previewMode]] form. Do not enter personal information.",
115
123
  "bannerText": "This is a preview of a [[previewMode]] form page you are editing.",
116
124
  "previousPages": "It depends on answers from earlier pages in the form. In the live version, users will need to complete those questions first."
@@ -245,7 +253,7 @@
245
253
  },
246
254
 
247
255
  "paymentField": {
248
- "detailsRequired": "Payment details required",
256
+ "detailsRequired": "Payment required",
249
257
  "pendingTransaction": "You may see a pending transaction in your bank account but you will only be charged when you submit the form.",
250
258
  "addPaymentDetails": "Add payment details",
251
259
  "cannotTakePayment": "There is a problem and we cannot take a payment. Contact us (details in the footer of this form) or save your progress and return to the form later.",
@@ -261,11 +269,25 @@
261
269
  },
262
270
 
263
271
  "fileUploadField": {
272
+ "uploading": "Uploading…",
264
273
  "uploaded": "Uploaded",
265
274
  "uploadFailed": "There was a problem with your uploaded files. Re-upload them before submitting the form again.",
266
275
  "uploadedFilesHeading": "Uploaded files",
267
276
  "filesCount_one": "[[count]] file uploaded",
268
277
  "filesCount_other": "[[count]] files uploaded"
278
+ },
279
+
280
+ "characterCount": {
281
+ "_comment": "Note the use of %{count} instead of [[count]]. This is because we are passing to the govuk template, not passing to Joi",
282
+ "underLimit": {
283
+ "one": "You have %{count} character remaining",
284
+ "other": "You have %{count} characters remaining"
285
+ },
286
+ "atLimit": "You have 0 characters remaining",
287
+ "overLimit": {
288
+ "one": "You have %{count} character too many",
289
+ "other": "You have %{count} characters too many"
290
+ }
269
291
  }
270
292
  }
271
293
  }
@@ -22,6 +22,7 @@ export type FormDefinitionTranslations = Record<
22
22
  hint: string
23
23
  content: string
24
24
  shortDescription: string
25
+ paymentDescription: string
25
26
  }>
26
27
  >
27
28
  sections: Record<string, Partial<Pick<Section, 'title'>>>
@@ -188,17 +188,19 @@ export class FileUploadPageController extends QuestionPageController {
188
188
 
189
189
  const { filename } = fileToRemove.status.form.file
190
190
 
191
- const { t } = this.getTranslator(request)
191
+ const translator = this.getTranslator(request)
192
+ const { t } = translator
192
193
 
193
194
  return h.view(this.fileDeleteViewName, {
194
195
  ...viewModel,
195
196
  context,
196
197
  backLink: this.getBackLink(request, context, t),
197
- pageTitle: `Are you sure you want to remove this file?`,
198
+ pageTitle: t('pages.fileUpload.removeFileTitle'),
198
199
  itemTitle: filename,
199
- confirmation: { text: 'You cannot recover removed files.' },
200
- buttonConfirm: { text: 'Remove file' },
201
- buttonCancel: { text: 'Cancel' }
200
+ confirmation: { text: t('pages.fileUpload.removeFileBody') },
201
+ buttonConfirm: { text: t('pages.fileUpload.removeFileButton') },
202
+ buttonCancel: { text: t('pages.fileUpload.cancel') },
203
+ t
202
204
  } satisfies ItemDeletePageViewModel)
203
205
  }
204
206
  }
@@ -266,6 +268,7 @@ export class FileUploadPageController extends QuestionPageController {
266
268
  ): FeaturedFormPageViewModel {
267
269
  const { fileUpload } = this
268
270
  const { state } = context
271
+ const { t } = translator
269
272
 
270
273
  const upload = this.getUploadFromState(state)
271
274
 
@@ -277,6 +280,12 @@ export class FileUploadPageController extends QuestionPageController {
277
280
  ({ model }) => model.id === fileUpload.name
278
281
  )
279
282
 
283
+ formComponent.model.upload = {
284
+ count: formComponent.model.upload?.count ?? 0,
285
+ summaryList: formComponent.model.upload?.summaryList ?? { rows: [] },
286
+ uploadingLabel: t('components.fileUploadField.uploading')
287
+ }
288
+
280
289
  const index = components.indexOf(formComponent)
281
290
 
282
291
  const proxyUrl = getProxyUrlForLocalDevelopment(upload?.uploadUrl)
@@ -290,7 +299,8 @@ export class FileUploadPageController extends QuestionPageController {
290
299
  // Split out components before/after
291
300
  componentsBefore: components.slice(0, index),
292
301
  components: components.slice(index),
293
- proxyUrl
302
+ proxyUrl,
303
+ t
294
304
  }
295
305
  }
296
306
 
@@ -174,9 +174,14 @@ export class QuestionPageController extends PageController {
174
174
  if (!pageTitle) {
175
175
  pageTitle = labelOrLegend.text
176
176
  }
177
- labelOrLegend.text = isOptional
178
- ? `${pageTitle} ${t('common.optional')}`
179
- : pageTitle
177
+
178
+ // The question text may have already appended 'optional' in the relevant language
179
+ const optionalWord = t('common.optional')
180
+ const optionalAlreadyAppended = pageTitle.endsWith(` ${optionalWord}`)
181
+ labelOrLegend.text =
182
+ isOptional && !optionalAlreadyAppended
183
+ ? `${pageTitle} ${optionalWord}`
184
+ : pageTitle
180
185
  }
181
186
 
182
187
  // Fallback if still no pageTitle set
@@ -3,7 +3,7 @@
3
3
  {% macro FileUploadField(component) %}
4
4
  {% set upload = component.model.upload %}
5
5
 
6
- <div id="uploadedFilesContainer">
6
+ <div id="uploadedFilesContainer" data-uploadinglabel="{{ upload.uploadingLabel }}">
7
7
  <h2 class="govuk-heading-m">{{ t('components.fileUploadField.uploadedFilesHeading') }}</h2>
8
8
  {% if upload.count %}
9
9
  <p class="govuk-body" role="alert">{{ t('components.fileUploadField.filesCount', { count: upload.count }) }}</p>
@@ -3,7 +3,18 @@
3
3
 
4
4
  {% macro MultilineTextField(component) %}
5
5
  {% if component.model.isCharacterOrWordCount == true %}
6
- {{ govukCharacterCount(component.model) }}
6
+ {% set characterParams = component.model | merge({
7
+ charactersUnderLimitText: {
8
+ one: t('components.characterCount.underLimit.one'),
9
+ other: t('components.characterCount.underLimit.other')
10
+ },
11
+ charactersAtLimitText: t('components.characterCount.atLimit'),
12
+ charactersOverLimitText: {
13
+ one: t('components.characterCount.overLimit.one'),
14
+ other: t('components.characterCount.overLimit.other')
15
+ }
16
+ } ) %}
17
+ {{ govukCharacterCount(characterParams) }}
7
18
  {% else %}
8
19
  {{ govukTextarea(component.model) }}
9
20
  {% endif %}
@@ -16,7 +16,7 @@
16
16
  <p class="govuk-body">{{ t('components.paymentField.preAuthorisedBody') }}</p>
17
17
  {% else %}
18
18
  {# No pre-authorisation - show payment form #}
19
- <h2 class="govuk-heading-m">{{ model.label.text if model.label and model.label.text else t('components.paymentField.detailsRequired') }}</h2>
19
+ <h2 class="govuk-heading-m">{{ t('components.paymentField.detailsRequired') }}</h2>
20
20
 
21
21
  <p class="govuk-body">{{ description }}</p>
22
22
 
@@ -8,7 +8,9 @@
8
8
  </p>
9
9
  {%- endmacro -%}
10
10
 
11
- {% call govukNotificationBanner() %}
11
+ {% call govukNotificationBanner({
12
+ titleText: t('pages.preview.bannerTitle')
13
+ }) %}
12
14
  {% set previewModeTranslated = t('common.' + previewMode) %}
13
15
  {% if not context.isForceAccess %}
14
16
  <p class="govuk-notification-banner__heading govuk-!-margin-bottom-0">