@defra/forms-engine-plugin 5.0.0-alpha.3 → 5.0.0-alpha.5

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 (58) 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/client/javascripts/geospatial-map.js +31 -26
  8. package/.server/client/javascripts/geospatial-map.js.map +1 -1
  9. package/.server/client/javascripts/location-map.js +9 -1
  10. package/.server/client/javascripts/location-map.js.map +1 -1
  11. package/.server/client/javascripts/sssi-dataset.d.ts +18 -20
  12. package/.server/client/javascripts/sssi-dataset.js +37 -40
  13. package/.server/client/javascripts/sssi-dataset.js.map +1 -1
  14. package/.server/server/plugins/engine/components/AutocompleteField.d.ts +1 -0
  15. package/.server/server/plugins/engine/components/DatePartsField.d.ts +1 -0
  16. package/.server/server/plugins/engine/components/DeclarationField.d.ts +1 -0
  17. package/.server/server/plugins/engine/components/Details.d.ts +1 -0
  18. package/.server/server/plugins/engine/components/EastingNorthingField.d.ts +2 -0
  19. package/.server/server/plugins/engine/components/EmailAddressField.d.ts +1 -0
  20. package/.server/server/plugins/engine/components/FileUploadField.js +2 -2
  21. package/.server/server/plugins/engine/components/FileUploadField.js.map +1 -1
  22. package/.server/server/plugins/engine/components/FormComponent.d.ts +1 -0
  23. package/.server/server/plugins/engine/components/GeospatialField.d.ts +1 -0
  24. package/.server/server/plugins/engine/components/Html.d.ts +1 -0
  25. package/.server/server/plugins/engine/components/InsetText.d.ts +1 -0
  26. package/.server/server/plugins/engine/components/LatLongField.d.ts +2 -0
  27. package/.server/server/plugins/engine/components/List.d.ts +1 -0
  28. package/.server/server/plugins/engine/components/ListFormComponent.d.ts +1 -0
  29. package/.server/server/plugins/engine/components/LocationFieldBase.d.ts +2 -0
  30. package/.server/server/plugins/engine/components/LocationFieldHelpers.d.ts +2 -0
  31. package/.server/server/plugins/engine/components/Markdown.d.ts +1 -0
  32. package/.server/server/plugins/engine/components/MonthYearField.d.ts +1 -0
  33. package/.server/server/plugins/engine/components/MultilineTextField.d.ts +1 -0
  34. package/.server/server/plugins/engine/components/NotificationBanner.d.ts +1 -0
  35. package/.server/server/plugins/engine/components/NumberField.d.ts +1 -0
  36. package/.server/server/plugins/engine/components/PaymentField.d.ts +1 -0
  37. package/.server/server/plugins/engine/components/SelectField.d.ts +1 -0
  38. package/.server/server/plugins/engine/components/SelectionControlField.d.ts +1 -0
  39. package/.server/server/plugins/engine/components/TelephoneNumberField.d.ts +1 -0
  40. package/.server/server/plugins/engine/components/UkAddressField.d.ts +1 -0
  41. package/.server/server/plugins/engine/components/types.d.ts +1 -0
  42. package/.server/server/plugins/engine/components/types.js.map +1 -1
  43. package/.server/server/plugins/engine/i18n/translations/cy.json +37 -1
  44. package/.server/server/plugins/engine/i18n/translations/en-GB.json +9 -1
  45. package/.server/server/plugins/engine/pageControllers/FileUploadPageController.js +20 -7
  46. package/.server/server/plugins/engine/pageControllers/FileUploadPageController.js.map +1 -1
  47. package/.server/server/plugins/engine/views/components/fileuploadfield.html +1 -1
  48. package/package.json +1 -1
  49. package/src/client/javascripts/file-upload.js +10 -3
  50. package/src/client/javascripts/geospatial-map.js +32 -30
  51. package/src/client/javascripts/location-map.js +7 -1
  52. package/src/client/javascripts/sssi-dataset.js +39 -42
  53. package/src/server/plugins/engine/components/FileUploadField.ts +2 -2
  54. package/src/server/plugins/engine/components/types.ts +1 -0
  55. package/src/server/plugins/engine/i18n/translations/cy.json +37 -1
  56. package/src/server/plugins/engine/i18n/translations/en-GB.json +9 -1
  57. package/src/server/plugins/engine/pageControllers/FileUploadPageController.ts +16 -6
  58. package/src/server/plugins/engine/views/components/fileuploadfield.html +1 -1
@@ -49,50 +49,47 @@ export function sssiScotlandRequestTransformer(url, { bbox }) {
49
49
  }
50
50
  }
51
51
 
52
- export default {
53
- datasets: [
54
- {
55
- id: 'sssi-england',
56
- label: 'Sites of Special Scientific Interest',
57
- dynamicGeoJSON: {
58
- url: englandWFS,
59
- idProperty: 'ref_code',
60
- transformRequest: sssiEnglandRequestTransformer
61
- },
62
- minZoom,
63
- style,
64
- showInKey: true,
65
- showInMenu: false
52
+ export default [
53
+ {
54
+ id: 'sssi-england',
55
+ label: 'Sites of Special Scientific Interest',
56
+ dynamicGeoJSON: {
57
+ url: englandWFS,
58
+ idProperty: 'ref_code',
59
+ transformRequest: sssiEnglandRequestTransformer
66
60
  },
67
- {
68
- id: 'sssi-wales',
69
- label: 'SSSI Wales',
70
- dynamicGeoJSON: {
71
- url: walesWFS,
72
- idProperty: 'id',
73
- transformRequest: sssiWalesRequestTransformer
74
- },
75
- minZoom,
76
- style,
77
- showInKey: false,
78
- showInMenu: false
61
+ minZoom,
62
+ style,
63
+ showInKey: true,
64
+ showInMenu: false
65
+ },
66
+ {
67
+ id: 'sssi-wales',
68
+ label: 'SSSI Wales',
69
+ dynamicGeoJSON: {
70
+ url: walesWFS,
71
+ idProperty: 'id',
72
+ transformRequest: sssiWalesRequestTransformer
79
73
  },
80
- {
81
- id: 'sssi-scotland',
82
- label: 'SSSI Scotland',
83
- dynamicGeoJSON: {
84
- url: scotlandWFS,
85
- idProperty: 'OBJECTID',
86
- transformRequest: sssiScotlandRequestTransformer
87
- },
88
- minZoom,
89
- style,
90
- showInKey: false,
91
- showInMenu: false
92
- }
93
- ]
94
- }
95
-
74
+ minZoom,
75
+ style,
76
+ showInKey: false,
77
+ showInMenu: false
78
+ },
79
+ {
80
+ id: 'sssi-scotland',
81
+ label: 'SSSI Scotland',
82
+ dynamicGeoJSON: {
83
+ url: scotlandWFS,
84
+ idProperty: 'OBJECTID',
85
+ transformRequest: sssiScotlandRequestTransformer
86
+ },
87
+ minZoom,
88
+ style,
89
+ showInKey: false,
90
+ showInMenu: false
91
+ }
92
+ ]
96
93
  /**
97
94
  * @typedef {object} TransformRequestOptions
98
95
  * @property {string[]} bbox - the bounding box coordinates
@@ -169,7 +169,7 @@ export class FileUploadField extends FormComponent {
169
169
  return ''
170
170
  }
171
171
 
172
- return translator.t('components.fileUploadField.filesCount', {
172
+ return translator.t('pages.summary.fileUpload', {
173
173
  count: files.length
174
174
  })
175
175
  }
@@ -244,7 +244,7 @@ export class FileUploadField extends FormComponent {
244
244
 
245
245
  items.push({
246
246
  href,
247
- text: 'Remove',
247
+ text: t('pages.fileUpload.remove'),
248
248
  classes: 'govuk-link--no-visited-state',
249
249
  attributes: { id: `${id}__${index}` },
250
250
  visuallyHiddenText: file.filename
@@ -124,6 +124,7 @@ export interface ViewModel extends Record<string, unknown> {
124
124
  upload?: {
125
125
  count: number
126
126
  summaryList: SummaryList
127
+ uploadingLabel?: string
127
128
  }
128
129
  }
129
130
 
@@ -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": {
@@ -135,7 +158,11 @@
135
158
  "findAnAddressInstead": "dod o hyd i gyfeiriad yn lle hynny",
136
159
  "noAddressFoundTitle": "Ni chanfuwyd cyfeiriad",
137
160
  "noAddressFoundBody": "Ni allem ddod o hyd i gyfeiriad cyfatebol",
161
+ "addressFound_zero": "Ni chanfuwyd unrhyw gyfeiriadau ar gyfer",
138
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",
139
166
  "addressFound_other": "Canfuwyd [[count]] cyfeiriad ar gyfer",
140
167
  "validation": {
141
168
  "invalidPostcode": "Nodwch god post dilys neu nodwch gyfeiriad â llaw",
@@ -237,7 +264,11 @@
237
264
  },
238
265
 
239
266
  "geospatialField": {
267
+ "added_zero": "Ni ychwanegwyd unrhyw leoliadau",
240
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",
241
272
  "added_other": "Ychwanegwyd [[count]] lleoliad",
242
273
  "validation": {
243
274
  "descriptionRequired": "Rhowch ddisgrifiad ar gyfer lleoliad [[count]]",
@@ -262,10 +293,15 @@
262
293
  },
263
294
 
264
295
  "fileUploadField": {
296
+ "uploading": "Yn uwchlwytho…",
265
297
  "uploaded": "Wedi'i uwchlwytho",
266
298
  "uploadFailed": "Roedd problem gyda'ch ffeiliau a uwchlwythwyd. Uwchlwythwch nhw eto cyn cyflwyno'r ffurflen.",
267
299
  "uploadedFilesHeading": "Ffeiliau a uwchlwythwyd",
300
+ "filesCount_zero": "Uwchlwythwyd [[count]] o ffeiliau",
268
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",
269
305
  "filesCount_other": "Uwchlwythwyd [[count]] ffeil"
270
306
  },
271
307
 
@@ -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": {
@@ -262,6 +269,7 @@
262
269
  },
263
270
 
264
271
  "fileUploadField": {
272
+ "uploading": "Uploading…",
265
273
  "uploaded": "Uploaded",
266
274
  "uploadFailed": "There was a problem with your uploaded files. Re-upload them before submitting the form again.",
267
275
  "uploadedFilesHeading": "Uploaded files",
@@ -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
 
@@ -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>