@defra/forms-engine-plugin 2.0.3 → 2.1.1

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 (34) 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/.public/stylesheets/application.min.css +2 -2
  6. package/.public/stylesheets/application.min.css.map +1 -1
  7. package/.server/client/javascripts/file-upload.js +3 -3
  8. package/.server/client/javascripts/file-upload.js.map +1 -1
  9. package/.server/server/forms/page-events.yaml +87 -0
  10. package/.server/server/index.js +2 -1
  11. package/.server/server/index.js.map +1 -1
  12. package/.server/server/plugins/engine/routes/questions.d.ts +4 -2
  13. package/.server/server/plugins/engine/routes/questions.js +67 -43
  14. package/.server/server/plugins/engine/routes/questions.js.map +1 -1
  15. package/.server/server/plugins/engine/services/localFormsService.js +7 -9
  16. package/.server/server/plugins/engine/services/localFormsService.js.map +1 -1
  17. package/.server/server/routes/dummy-api.d.ts +38 -0
  18. package/.server/server/routes/dummy-api.js +33 -0
  19. package/.server/server/routes/dummy-api.js.map +1 -0
  20. package/.server/server/routes/index.d.ts +1 -0
  21. package/.server/server/routes/index.js +1 -0
  22. package/.server/server/routes/index.js.map +1 -1
  23. package/package.json +12 -10
  24. package/src/client/javascripts/file-upload.js +3 -3
  25. package/src/server/forms/page-events.yaml +87 -0
  26. package/src/server/index.ts +4 -2
  27. package/src/server/plugins/engine/routes/questions.test.ts +416 -0
  28. package/src/server/plugins/engine/routes/questions.ts +96 -40
  29. package/src/server/plugins/engine/services/localFormsService.js +7 -8
  30. package/src/server/routes/dummy-api.test.ts +96 -0
  31. package/src/server/routes/dummy-api.ts +62 -0
  32. package/src/server/routes/index.ts +1 -0
  33. package/.server/server/forms/register-as-a-unicorn-breeder.json +0 -393
  34. package/src/server/forms/register-as-a-unicorn-breeder.json +0 -393
@@ -1,393 +0,0 @@
1
- {
2
- "name": "Register as a unicorn breeder",
3
- "pages": [
4
- {
5
- "path": "/whats-your-name",
6
- "title": "What's your name?",
7
- "components": [
8
- {
9
- "type": "TextField",
10
- "name": "textField",
11
- "title": "Name",
12
- "hint": "This is a single line text box. We use it to ask for information that's likely to be 1 sentence",
13
- "options": {
14
- "required": true
15
- },
16
- "schema": {}
17
- }
18
- ],
19
- "next": [
20
- {
21
- "path": "/whats-your-email-address"
22
- }
23
- ],
24
- "section": "section"
25
- },
26
- {
27
- "title": "Summary",
28
- "path": "/summary",
29
- "controller": "./pages/summary.js",
30
- "components": [],
31
- "next": []
32
- },
33
- {
34
- "path": "/whats-your-email-address",
35
- "title": "What's your email address?",
36
- "components": [
37
- {
38
- "name": "MaTzaT",
39
- "options": {
40
- "required": true
41
- },
42
- "type": "EmailAddressField",
43
- "title": "Email adress",
44
- "schema": {},
45
- "hint": "This is an email address. An email address must contain an at sign @"
46
- }
47
- ],
48
- "next": [
49
- {
50
- "path": "/whats-your-phone-number"
51
- }
52
- ],
53
- "section": "section"
54
- },
55
- {
56
- "path": "/whats-your-phone-number",
57
- "title": "What's your phone number?",
58
- "components": [
59
- {
60
- "name": "BdKgCe",
61
- "options": {
62
- "required": true
63
- },
64
- "type": "TelephoneNumberField",
65
- "title": "Phone number",
66
- "schema": {},
67
- "hint": "This is a telephone number. This field can only contain numbers and the + symbol"
68
- }
69
- ],
70
- "next": [
71
- {
72
- "path": "/whats-your-address"
73
- }
74
- ],
75
- "section": "section"
76
- },
77
- {
78
- "path": "/whats-your-address",
79
- "title": "What's your address?",
80
- "components": [
81
- {
82
- "name": "wZLWPy",
83
- "options": {
84
- "required": true
85
- },
86
- "type": "UkAddressField",
87
- "title": "Address",
88
- "schema": {},
89
- "hint": "This is a UK address. Users must enter address line 1, town and a postcode"
90
- }
91
- ],
92
- "next": [
93
- {
94
- "path": "/do-you-want-your-unicorn-breeder-certificate-sent-to-this-address"
95
- }
96
- ],
97
- "section": "section"
98
- },
99
- {
100
- "path": "/do-you-want-your-unicorn-breeder-certificate-sent-to-this-address",
101
- "title": "Do you want your unicorn breeder certificate sent to this address?",
102
- "components": [
103
- {
104
- "name": "dBfuID",
105
- "options": {},
106
- "type": "YesNoField",
107
- "title": "Send certificate to same address",
108
- "schema": {},
109
- "hint": "This is a yes or no question. We can branch to different questions based on the answer",
110
- "values": {
111
- "type": "listRef"
112
- }
113
- }
114
- ],
115
- "next": [
116
- {
117
- "path": "/what-address-do-you-want-the-certificate-sent-to",
118
- "condition": "oyGPwP"
119
- },
120
- {
121
- "path": "/when-does-your-unicorn-insurance-policy-start",
122
- "condition": ""
123
- }
124
- ],
125
- "section": "section"
126
- },
127
- {
128
- "path": "/what-address-do-you-want-the-certificate-sent-to",
129
- "title": "What address do you want the certificate sent to?",
130
- "components": [
131
- {
132
- "name": "AegFro",
133
- "options": {},
134
- "type": "UkAddressField",
135
- "title": "Address to send certificate",
136
- "schema": {},
137
- "hint": "This is a simple branch to an extra question - it's shown to users who select 'no' when asked if this is the address where the certificate should be sent"
138
- }
139
- ],
140
- "next": [
141
- {
142
- "path": "/when-does-your-unicorn-insurance-policy-start"
143
- }
144
- ],
145
- "section": "section"
146
- },
147
- {
148
- "title": "When does your unicorn insurance policy start?",
149
- "path": "/when-does-your-unicorn-insurance-policy-start",
150
- "section": "Regnsa",
151
- "next": [
152
- {
153
- "path": "/upload-your-insurance-certificate"
154
- }
155
- ],
156
- "components": [
157
- {
158
- "name": "mjAccr",
159
- "options": {},
160
- "type": "DatePartsField",
161
- "title": "Unicorn insurance policy start date",
162
- "schema": {},
163
- "hint": "This is a date. We can add custom validation to the field based on your requirements. For example, the date entered must be before or after a certain date"
164
- }
165
- ]
166
- },
167
- {
168
- "title": "How many unicorns do you expect to breed each year?",
169
- "path": "/how-many-unicorns-do-you-expect-to-breed-each-year",
170
- "section": "susaYr",
171
- "next": [
172
- {
173
- "path": "/what-type-of-unicorns-will-you-breed"
174
- }
175
- ],
176
- "components": [
177
- {
178
- "name": "aitzzV",
179
- "options": {},
180
- "type": "RadiosField",
181
- "list": "IeFOkf",
182
- "title": "Number of unicorns",
183
- "schema": {},
184
- "hint": "This is a radio button. Users can only select one option from the list",
185
- "values": {
186
- "type": "listRef"
187
- }
188
- }
189
- ]
190
- },
191
- {
192
- "title": "What type of unicorns will you breed?",
193
- "path": "/what-type-of-unicorns-will-you-breed",
194
- "section": "susaYr",
195
- "next": [
196
- {
197
- "path": "/where-will-you-keep-the-unicorns"
198
- }
199
- ],
200
- "components": [
201
- {
202
- "name": "DyfjJC",
203
- "options": {},
204
- "type": "CheckboxesField",
205
- "list": "fXiZrL",
206
- "title": "Type of unicorn",
207
- "schema": {},
208
- "hint": "This is a check box. Users can select more than one option",
209
- "values": {
210
- "type": "listRef"
211
- }
212
- }
213
- ]
214
- },
215
- {
216
- "title": "Where will you keep the unicorns?",
217
- "path": "/where-will-you-keep-the-unicorns",
218
- "section": "susaYr",
219
- "next": [
220
- {
221
- "path": "/how-many-members-of-staff-will-look-after-the-unicorns"
222
- }
223
- ],
224
- "components": [
225
- {
226
- "name": "bClCvo",
227
- "options": {},
228
- "schema": {},
229
- "type": "MultilineTextField",
230
- "title": "Where you keep the unicorn",
231
- "hint": "This is a multi-line text box. We use it when you expect the response to be more than 1 sentence long"
232
- }
233
- ]
234
- },
235
- {
236
- "title": "How many members of staff will look after the unicorns?",
237
- "path": "/how-many-members-of-staff-will-look-after-the-unicorns",
238
- "section": "susaYr",
239
- "next": [
240
- {
241
- "path": "/summary"
242
- }
243
- ],
244
- "components": [
245
- {
246
- "name": "zhJMaM",
247
- "options": {
248
- "classes": "govuk-!-width-one-quarter"
249
- },
250
- "type": "NumberField",
251
- "title": "Number of staff",
252
- "schema": {},
253
- "hint": "This is a number field. The answer must be a number. We can use custom validation to set decimal places, minimum and maximum values"
254
- }
255
- ]
256
- },
257
- {
258
- "title": "Upload your insurance certificate",
259
- "path": "/upload-your-insurance-certificate",
260
- "controller": "FileUploadPageController",
261
- "section": "Regnsa",
262
- "next": [
263
- {
264
- "path": "/how-many-unicorns-do-you-expect-to-breed-each-year"
265
- }
266
- ],
267
- "components": [
268
- {
269
- "name": "dLzALM",
270
- "title": "Documents",
271
- "type": "FileUploadField",
272
- "hint": "We can specify the format and number of uploaded files",
273
- "options": {
274
- "required": false
275
- },
276
- "schema": {
277
- "min": 1,
278
- "max": 3
279
- }
280
- }
281
- ]
282
- }
283
- ],
284
- "conditions": [
285
- {
286
- "displayName": "Address is different",
287
- "name": "IrVmYz",
288
- "value": {
289
- "name": "Address is different",
290
- "conditions": [
291
- {
292
- "field": {
293
- "name": "dBfuID",
294
- "type": "YesNoField",
295
- "display": "Contact details: Send certificate to same address"
296
- },
297
- "operator": "is",
298
- "value": {
299
- "type": "Value",
300
- "value": "false",
301
- "display": "false"
302
- }
303
- }
304
- ]
305
- }
306
- },
307
- {
308
- "displayName": "Address is not the same",
309
- "name": "oyGPwP",
310
- "value": {
311
- "name": "Address is not the same",
312
- "conditions": [
313
- {
314
- "field": {
315
- "name": "dBfuID",
316
- "type": "YesNoField",
317
- "display": "Contact details: Send certificate to same address"
318
- },
319
- "operator": "is",
320
- "value": {
321
- "type": "Value",
322
- "value": "false",
323
- "display": "No"
324
- }
325
- }
326
- ]
327
- }
328
- }
329
- ],
330
- "sections": [
331
- {
332
- "name": "section",
333
- "title": "Contact details",
334
- "hideTitle": false
335
- },
336
- {
337
- "title": "Unicorn details",
338
- "name": "susaYr",
339
- "hideTitle": false
340
- },
341
- {
342
- "title": "Insurance details",
343
- "name": "Regnsa",
344
- "hideTitle": false
345
- }
346
- ],
347
- "lists": [
348
- {
349
- "title": "number of unicorns",
350
- "name": "IeFOkf",
351
- "type": "string",
352
- "items": [
353
- {
354
- "text": "1 to 5",
355
- "value": "1 to 5"
356
- },
357
- {
358
- "text": "6 to 10",
359
- "value": "6 to 10"
360
- },
361
- {
362
- "text": "11 or more",
363
- "value": "11 or more"
364
- }
365
- ]
366
- },
367
- {
368
- "title": "Type of unicorn",
369
- "name": "fXiZrL",
370
- "type": "string",
371
- "items": [
372
- {
373
- "text": "Flying",
374
- "value": "Flying"
375
- },
376
- {
377
- "text": "Fire breathing",
378
- "value": "Fire breathing"
379
- },
380
- {
381
- "text": "Aquatic",
382
- "value": "Aquatic"
383
- },
384
- {
385
- "text": "Rainbow",
386
- "value": "Rainbow"
387
- }
388
- ]
389
- }
390
- ],
391
- "outputEmail": "defraforms@defra.gov.uk",
392
- "startPage": "/whats-your-name"
393
- }