@ukhomeoffice/cop-react-form-renderer 6.15.4 → 6.15.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.
@@ -0,0 +1,445 @@
1
+ {
2
+ "cya": {
3
+ "actions": [
4
+ {
5
+ "type": "submit",
6
+ "label": "Submit",
7
+ "validate": true
8
+ }
9
+ ],
10
+ "confirm": [
11
+ {
12
+ "title": "Task kept with NCC",
13
+ "message": [
14
+ "<h2 class='govuk-heading-m'>What happens next</h2>",
15
+ "<p class='govuk-body'>Review the task by ${reviewTimeP} on ${reviewDateP}.</p>",
16
+ "<p class='govuk-body'>To view the task, go to <a href='/tms/open-tasks'>open NCC tasks</a>. You can track updates in the task's timeline.</p>",
17
+ "<p class='govuk-body'><a href='/'>Go to homepage</a></p>",
18
+ "<p class='govuk-body'><a href='https://lssiprod.service-now.com/ess?id=take_survey&type_id=e0e2125b1bdd1110f8655946464bcbf7'>What do you think of this service?</a></p>"
19
+ ],
20
+ "show_when": [
21
+ {
22
+ "op": "=",
23
+ "field": "assignWhere",
24
+ "value": "NCC"
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "title": "Task assigned to RCC",
30
+ "message": [
31
+ "<h2 class='govuk-heading-m'>What happens next</h2>",
32
+ "<p>This task will automatically close at 23:59 on ${autoClose} - the day after the event date.</p>",
33
+ "<p>To view the task, go to <a href='/tms/open-tasks'>open NCC tasks</a>. You can track updates in the task's timeline.</p>",
34
+ "<p>You can only work on the task when it is assigned to NCC.</p>",
35
+ "<p><a href='/'>Go to homepage</a></p>",
36
+ "<p><a href='https://lssiprod.service-now.com/ess?id=take_survey&type_id=e0e2125b1bdd1110f8655946464bcbf7'>What do you think of this service?</a></p>"
37
+ ],
38
+ "show_when": [
39
+ {
40
+ "type": "and",
41
+ "conditions": [
42
+ {
43
+ "op": "=",
44
+ "field": "assignWhere",
45
+ "value": "RCC"
46
+ },
47
+ {
48
+ "op": "=",
49
+ "field": "responseNeeded",
50
+ "value": "No"
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "title": "Task assigned to RCC",
58
+ "message": [
59
+ "<h2 class='govuk-heading-m'>What happens next</h2>",
60
+ "<p class='govuk-body'>You set a review date of ${reviewTimeP} on ${reviewDateP}.</p>",
61
+ "<p class='govuk-body'>To view the task, go to <a href='/tms/open-tasks'>open NCC tasks</a>. You can track updates in the task's timeline.</p>",
62
+ "<p class='govuk-body'>You can only work on the task when it is assigned to NCC.</p>",
63
+ "<p class='govuk-body'><a href='/'>Go to homepage</a></p>",
64
+ "<p class='govuk-body'><a href='https://lssiprod.service-now.com/ess?id=take_survey&type_id=e0e2125b1bdd1110f8655946464bcbf7'>What do you think of this service?</a></p>"
65
+ ],
66
+ "show_when": [
67
+ {
68
+ "type": "and",
69
+ "conditions": [
70
+ {
71
+ "op": "=",
72
+ "field": "assignWhere",
73
+ "value": "RCC"
74
+ },
75
+ {
76
+ "op": "=",
77
+ "field": "responseNeeded",
78
+ "value": "Yes"
79
+ }
80
+ ]
81
+ }
82
+ ]
83
+ },
84
+ {
85
+ "title": "Task assigned to RCC",
86
+ "message": [
87
+ "<h2 class='govuk-heading-m'>What happens next</h2>",
88
+ "<p class='govuk-body'>RCC will review this task.</p>",
89
+ "<p class='govuk-body'><a href='/'>Go to homepage</a></p>",
90
+ "<p class='govuk-body'><a href='https://lssiprod.service-now.com/ess?id=take_survey&type_id=e0e2125b1bdd1110f8655946464bcbf7'>What do you think of this service?</a></p>"
91
+ ],
92
+ "show_when": [
93
+ {
94
+ "type": "and",
95
+ "conditions": [
96
+ {
97
+ "op": "!includes",
98
+ "field": "keycloakContext.groups",
99
+ "value": "/BFNCC"
100
+ }
101
+ ]
102
+ }
103
+ ]
104
+ }
105
+ ],
106
+ "insertDateTime": true
107
+ },
108
+ "name": "cop-reassign-task-to-rcc",
109
+ "type": "cya",
110
+ "pages": [
111
+ {
112
+ "id": "assignTask",
113
+ "name": "assignTask",
114
+ "title": "Assign Task",
115
+ "actions": [
116
+ {
117
+ "page": "assignTaskToRCC",
118
+ "type": "next",
119
+ "label": "Continue",
120
+ "validate": true,
121
+ "show_when": {
122
+ "type": "or",
123
+ "conditions": [
124
+ {
125
+ "op": "=",
126
+ "field": "assignWhere",
127
+ "value": "RCC"
128
+ }
129
+ ]
130
+ }
131
+ },
132
+ {
133
+ "page": "reviewDateAndTime",
134
+ "type": "saveAndNavigate",
135
+ "label": "Continue",
136
+ "validate": true,
137
+ "show_when": {
138
+ "type": "or",
139
+ "conditions": [
140
+ {
141
+ "op": "!=",
142
+ "field": "assignWhere",
143
+ "value": "RCC"
144
+ }
145
+ ]
146
+ }
147
+ }
148
+ ],
149
+ "cya_link": {},
150
+ "show_when": [
151
+ {
152
+ "op": "includes",
153
+ "field": "keycloakContext.groups",
154
+ "value": "/BFNCC"
155
+ }
156
+ ],
157
+ "components": [
158
+ {
159
+ "use": "assignWhere"
160
+ }
161
+ ]
162
+ },
163
+ {
164
+ "id": "assignTaskToRCC",
165
+ "name": "assignTaskToRCC",
166
+ "title": "Assign task to RCC",
167
+ "actions": [
168
+ {
169
+ "type": "next",
170
+ "label": "Continue",
171
+ "validate": true
172
+ }
173
+ ],
174
+ "cya_link": {},
175
+ "show_when": {
176
+ "conditions": [
177
+ {
178
+ "op": "=",
179
+ "field": "assignWhere",
180
+ "value": "RCC"
181
+ }
182
+ ]
183
+ },
184
+ "components": [
185
+ {
186
+ "use": "regionalCommandCentre",
187
+ "show_when": {
188
+ "type": "and",
189
+ "conditions": [
190
+ {
191
+ "op": "!=",
192
+ "field": "definitionKey",
193
+ "value": "cop-variance-breach-v2"
194
+ }
195
+ ]
196
+ }
197
+ },
198
+ {
199
+ "use": "regionalCommandCentreDisplay",
200
+ "show_when": {
201
+ "type": "or",
202
+ "conditions": [
203
+ {
204
+ "op": "=",
205
+ "field": "definitionKey",
206
+ "value": "cop-variance-breach-v2"
207
+ }
208
+ ]
209
+ }
210
+ },
211
+ {
212
+ "use": "responseNeeded",
213
+ "show_when": {
214
+ "type": "or",
215
+ "conditions": [
216
+ {
217
+ "op": "includes",
218
+ "field": "keycloakContext.groups",
219
+ "value": "/BFNCC"
220
+ }
221
+ ]
222
+ }
223
+ },
224
+ {
225
+ "use": "assignMessage"
226
+ }
227
+ ],
228
+ "operations": [
229
+ {
230
+ "field": "reviewDateTime",
231
+ "function": "deleteValueInFormData",
232
+ "run_when": {
233
+ "field": "responseNeeded",
234
+ "condition": "changes"
235
+ },
236
+ "component": " "
237
+ }
238
+ ]
239
+ },
240
+ {
241
+ "id": "reviewDateAndTime",
242
+ "name": "reviewDateAndTime",
243
+ "title": "Set a review date and time",
244
+ "actions": [
245
+ {
246
+ "type": "next",
247
+ "label": "Continue",
248
+ "validate": true
249
+ }
250
+ ],
251
+ "cya_link": {},
252
+ "show_when": [
253
+ {
254
+ "type": "or",
255
+ "conditions": [
256
+ {
257
+ "op": "=",
258
+ "field": "responseNeeded",
259
+ "value": "Yes"
260
+ },
261
+ {
262
+ "op": "=",
263
+ "field": "assignWhere",
264
+ "value": "NCC"
265
+ }
266
+ ]
267
+ }
268
+ ],
269
+ "components": [
270
+ {
271
+ "use": "reviewDateTime"
272
+ },
273
+ {
274
+ "use": "responseNeeded",
275
+ "label": "",
276
+ "value": "Yes",
277
+ "hidden": true,
278
+ "required": true,
279
+ "show_on_cya": false,
280
+ "defaultValue": "Yes"
281
+ }
282
+ ]
283
+ }
284
+ ],
285
+ "title": "Assign task to RCC",
286
+ "components": [
287
+ {
288
+ "id": "assignMessage",
289
+ "type": "textarea",
290
+ "label": "Message",
291
+ "fieldId": "assignMessage",
292
+ "cya_link": {},
293
+ "required": true,
294
+ "custom_errors": [
295
+ {
296
+ "type": "required",
297
+ "message": "Enter a message"
298
+ }
299
+ ]
300
+ },
301
+ {
302
+ "id": "assignWhere",
303
+ "data": {
304
+ "options": [
305
+ {
306
+ "hint": "Set a review date and time.",
307
+ "label": "Keep task with NCC",
308
+ "value": "NCC"
309
+ },
310
+ {
311
+ "hint": "Either set a review date and time or set the task to automatically close.",
312
+ "label": "Assign task to RCC",
313
+ "value": "RCC"
314
+ }
315
+ ]
316
+ },
317
+ "type": "radios",
318
+ "label": " ",
319
+ "fieldId": "assignWhere",
320
+ "preserveInPayload": true,
321
+ "required": true,
322
+ "cya_label": "Assign task",
323
+ "custom_errors": [
324
+ {
325
+ "type": "required",
326
+ "message": "Select where you want to assign this task"
327
+ }
328
+ ],
329
+ "showAllValues": "true"
330
+ },
331
+ {
332
+ "id": "regionalCommandCentre",
333
+ "data": {
334
+ "url": "${environmentContext.referenceDataUrl}/v2/entities/branch?mode=dataOnly&filter=directorateid.eq=2&filter=code=in.(BFSEEU,BFHROW,BFSOUTH,BFNORTH,BFCENT)"
335
+ },
336
+ "hint": "Type to search",
337
+ "item": {
338
+ "label": "name",
339
+ "value": "id"
340
+ },
341
+ "type": "autocomplete",
342
+ "label": "Regional Command Centre",
343
+ "fieldId": "regionalCommandCentre",
344
+ "required": true,
345
+ "cya_label": "RCC",
346
+ "custom_errors": [
347
+ {
348
+ "type": "required",
349
+ "message": "Select a Regional Command Centre"
350
+ }
351
+ ],
352
+ "showAllValues": true
353
+ },
354
+ {
355
+ "id": "regionalCommandCentreDisplay",
356
+ "data": {
357
+ "url": "${environmentContext.referenceDataUrl}/v2/entities/branch?mode=dataOnly&filter=directorateid.eq=2&filter=code=in.(BFSEEU,BFHROW,BFSOUTH,BFNORTH,BFCENT)"
358
+ },
359
+ "item": {
360
+ "label": "name",
361
+ "value": "id"
362
+ },
363
+ "type": "autocomplete",
364
+ "label": "Regional Command Centre",
365
+ "fieldId": "regionalCommandCentre",
366
+ "disabled": true,
367
+ "required": true,
368
+ "cya_label": "RCC",
369
+ "showAllValues": true
370
+ },
371
+ {
372
+ "id": "reviewDateTime",
373
+ "type": "container",
374
+ "label": " ",
375
+ "fieldId": "reviewDateTime",
376
+ "required": true,
377
+ "components": [
378
+ {
379
+ "type": "html",
380
+ "content": "The review date and time will display on the open NCC tasks screen."
381
+ },
382
+ {
383
+ "id": "reviewDate",
384
+ "hint": "For example, 20 2 2023.",
385
+ "type": "date",
386
+ "label": "Review date",
387
+ "fieldId": "reviewDate",
388
+ "cya_link": {},
389
+ "required": true,
390
+ "custom_errors": [
391
+ {
392
+ "type": "required",
393
+ "message": "Enter a review date"
394
+ }
395
+ ],
396
+ "additionalValidation": [
397
+ {
398
+ "message": "Review date must be today or in the future",
399
+ "function": "mustBeInTheFuture",
400
+ "todayAllowed": true
401
+ }
402
+ ]
403
+ },
404
+ {
405
+ "id": "reviewTime",
406
+ "hint": "Use 24-hour. For example, 19:45.",
407
+ "type": "time",
408
+ "label": "Review time",
409
+ "fieldId": "reviewTime",
410
+ "cya_link": {},
411
+ "required": true,
412
+ "custom_errors": [
413
+ {
414
+ "type": "required",
415
+ "message": "Enter a review time"
416
+ }
417
+ ]
418
+ }
419
+ ]
420
+ },
421
+ {
422
+ "id": "responseNeeded",
423
+ "data": {
424
+ "options": [
425
+ {
426
+ "hint": "Set a review date for the task.",
427
+ "label": "Yes",
428
+ "value": "Yes"
429
+ },
430
+ {
431
+ "hint": "The task will automatically close at 23:59 on ${autoClose} - the day after the event date.",
432
+ "label": "No",
433
+ "value": "No"
434
+ }
435
+ ]
436
+ },
437
+ "type": "radios",
438
+ "label": "Do you need a response?",
439
+ "fieldId": "responseNeeded",
440
+ "required": true,
441
+ "showAllValues": "true"
442
+ }
443
+ ],
444
+ "version": "7b941ec0bb281e2b93ba32058b81e1a88f0f0a9a"
445
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "businessKey": "SIT-20250312-1016",
3
+ "definitionKey": "cop-ncc-task-form",
4
+ "port": {
5
+ "fixedpcp": null,
6
+ "updatedby": "Michaela Cook",
7
+ "geolong": "-3.3391",
8
+ "municipality": null,
9
+ "nonoperational": false,
10
+ "air": true,
11
+ "commandid": 22,
12
+ "juxtaposed": false,
13
+ "sea": false,
14
+ "subdivision": "NA",
15
+ "land": false,
16
+ "id": 9937,
17
+ "helipad": false,
18
+ "value": "9937",
19
+ "portablepcp": null,
20
+ "unlocode": null,
21
+ "rail": false,
22
+ "geolat": "51.39859",
23
+ "localcode": null,
24
+ "label": "Cardiff International Airport",
25
+ "countryid": 234,
26
+ "addressid": null,
27
+ "egates": null,
28
+ "iata": "CWL",
29
+ "locationid": null,
30
+ "hint": "",
31
+ "name": "Cardiff International Airport",
32
+ "icao": "EGFF",
33
+ "portsizeid": 1,
34
+ "validfrom": "2025-03-04T00:01:01.000Z",
35
+ "freightparcelposthub": false,
36
+ "validto": null
37
+ },
38
+ "terminal": null,
39
+ "leadOfficerEmail": null,
40
+ "officerEmails": null,
41
+ "regionalCommandCentre": {
42
+ "code": "BFCENT",
43
+ "updatedby": null,
44
+ "directorateid": 2,
45
+ "hint": "",
46
+ "name": "Central",
47
+ "validfrom": "2019-01-01T00:01:00.000Z",
48
+ "id": 23,
49
+ "label": "Central",
50
+ "value": "23",
51
+ "validto": null
52
+ },
53
+ "autoClose": "13 March 2025",
54
+ "assignWhere": "RCC",
55
+ "assignMessage": "test message",
56
+ "formStatus": {
57
+ "page": "cya"
58
+ },
59
+ "formInstanceId": "46d1b27d-5a6e-428b-a20e-4a432e37875f",
60
+ "form": {
61
+ "formVersionId": "7b941ec0bb281e2b93ba32058b81e1a88f0f0a9a",
62
+ "title": "Assign task to RCC",
63
+ "name": "cop-reassign-task-to-rcc",
64
+ "submissionDate": "2025-03-12T15:41:08.880Z",
65
+ "submittedBy": "acceptance.portuser1@system.local",
66
+ "submittingUsersName": "acceptance.portuser1",
67
+ "draftForm": true,
68
+ "submissionStartDate": "2025-03-12T15:41:08.880Z",
69
+ "formInstanceId": "46d1b27d-5a6e-428b-a20e-4a432e37875f",
70
+ "submissionTeam": "96e2d9db-8b3f-4b36-9ec3-eb1b7506d8c2"
71
+ }
72
+ }
@@ -85,6 +85,8 @@ var _copMandecRemoveCriminalityBefore = _interopRequireDefault(require("../clear
85
85
  var _copMandecRemoveCriminalityAfter = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/output/cop-mandec-remove-criminality-after.json"));
86
86
  var _copMandecRemoveUnspentConvictionsBefore = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/input/cop-mandec-remove-unspent-convictions-before.json"));
87
87
  var _copMandecRemoveUnspentConvictionsAfter = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/output/cop-mandec-remove-unspent-convictions-after.json"));
88
+ var _copReassignTaskToRcc = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/forms/cop-reassign-task-to-rcc.json"));
89
+ var _reassignToRcc = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/input/reassign-to-rcc.json"));
88
90
  var _formCopAirpax = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/forms/form-cop-airpax.json"));
89
91
  var _copAirpaxRemovePhotosBefore = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/input/cop-airpax-remove-photos-before.json"));
90
92
  var _copAirpaxRemovePhotosAfter = _interopRequireDefault(require("../clear-uncompleted-routes/test-data/output/cop-airpax-remove-photos-after.json"));
@@ -149,6 +151,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
149
151
 
150
152
  // Mandec Unspent convictions
151
153
 
154
+ // TMS reassign-task-to-rcc
155
+
152
156
  // Airpax photos
153
157
 
154
158
  describe('FormRenderer', () => {
@@ -332,6 +336,12 @@ describe('FormRenderer', () => {
332
336
  const result = _index.default.clearOutUncompletedRoutes(form, submissionData);
333
337
  expect(result).toEqual(_copMandecRemoveUnspentConvictionsAfter.default);
334
338
  });
339
+ it('Reassign to RCC form, preserved fields not cleansed.', () => {
340
+ const submissionData = JSON.parse(JSON.stringify(_reassignToRcc.default));
341
+ const form = JSON.parse(JSON.stringify(_copReassignTaskToRcc.default));
342
+ const result = _index.default.clearOutUncompletedRoutes(form, submissionData);
343
+ expect(result).toEqual(_reassignToRcc.default);
344
+ });
335
345
  it('photos removed from airpax.', () => {
336
346
  const submissionData = JSON.parse(JSON.stringify(_copAirpaxRemovePhotosBefore.default));
337
347
  const form = JSON.parse(JSON.stringify(_formCopAirpax.default));
@@ -88,6 +88,10 @@ const getNestedQuestionPath = (optionPath, nestedFieldId) => {
88
88
  /**
89
89
  * If the component has options, go through each option removing the data for any nested fields.
90
90
  * Required as nested options are in the payload at the same heirarchical level.
91
+ *
92
+ * There are occasions when a field shouldn't be removed from the payload, eg if a form is being used for 2 purposes
93
+ * eg the cop-reassign-task-to-rcc.json, and the field is only being hidden for display purposes. Allow these fields
94
+ * to be preserved with a property on the component.
91
95
 
92
96
  * @param {Object} payload Javascript object from which the node will be deleted. Updated by the method.
93
97
  * @param {String} path A string containing a decimal point delimited path specifying the node to delete.
@@ -97,6 +101,7 @@ const getNestedQuestionPath = (optionPath, nestedFieldId) => {
97
101
  exports.getNestedQuestionPath = getNestedQuestionPath;
98
102
  const deleteNodeAndOptions = (payload, path, component) => {
99
103
  var _component$data;
104
+ if (component.preserveInPayload) return;
100
105
  deleteNodeByPath(payload, path);
101
106
  // If the component has options, go through each option removing the data for any nested fields. Required as nested options are in the payload at the same heirarchical level.
102
107
  if (component !== null && component !== void 0 && (_component$data = component.data) !== null && _component$data !== void 0 && _component$data.options) {
@@ -335,6 +340,7 @@ const removeEmptyArraysAndUnusedCollectionIDs = payload => {
335
340
  * When the counter reaches 1 we know all other occurences of the component have been resolved
336
341
  * so it is safe to delete.
337
342
  *
343
+ *
338
344
  * @param {*} payload The form payload from which to delete the component data
339
345
  * @param {*} path The payload path of the component
340
346
  * @param {*} component The component whose data we should attempt to delete
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "6.15.4",
3
+ "version": "6.15.5",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",