@ukhomeoffice/cop-react-form-renderer 4.27.0 → 4.29.0-alpha
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.
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +23 -5
- package/dist/components/FormRenderer/FormRenderer.js +64 -7
- package/dist/components/FormRenderer/FormRenderer.test.js +58 -0
- package/dist/components/FormRenderer/handlers/navigate.js +2 -2
- package/dist/json/multiQuestionTaskList.json +275 -0
- package/dist/json/multiQuestionTaskListData.json +39 -0
- package/dist/models/PageAction.js +7 -1
- package/dist/utils/Condition/meetsCondition.js +24 -0
- package/dist/utils/Condition/meetsCondition.test.js +72 -0
- package/package.json +1 -1
|
@@ -69,7 +69,9 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
69
69
|
noChangeAction = _ref.noChangeAction,
|
|
70
70
|
groups = _ref.groups,
|
|
71
71
|
sections = _ref.sections,
|
|
72
|
-
type = _ref.type
|
|
72
|
+
type = _ref.type,
|
|
73
|
+
cysa = _ref.cysa,
|
|
74
|
+
currentPage = _ref.currentPage;
|
|
73
75
|
|
|
74
76
|
var _useState = (0, _react.useState)([]),
|
|
75
77
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -86,7 +88,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
86
88
|
|
|
87
89
|
(0, _react.useEffect)(function () {
|
|
88
90
|
var getRows = function getRows(page, pageIndex) {
|
|
89
|
-
var rows = _utils.default.CheckYourAnswers.getRows(page, onRowAction);
|
|
91
|
+
var rows = _utils.default.CheckYourAnswers.getRows(page, onRowAction, currentPage);
|
|
90
92
|
|
|
91
93
|
return rows.map(function (row, index) {
|
|
92
94
|
return _objectSpread(_objectSpread({}, row), {}, {
|
|
@@ -109,8 +111,23 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
109
111
|
}).filter(function (p) {
|
|
110
112
|
return !!p;
|
|
111
113
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
|
|
115
|
+
if (cysa) {
|
|
116
|
+
var indexOfCurrentPage = pagesWithRows.map(function (object) {
|
|
117
|
+
return object.id;
|
|
118
|
+
}).indexOf(currentPage);
|
|
119
|
+
|
|
120
|
+
if (indexOfCurrentPage === 0) {
|
|
121
|
+
setPages(pagesWithRows.slice(0, 1));
|
|
122
|
+
} else {
|
|
123
|
+
setPages(pagesWithRows.slice(0, indexOfCurrentPage));
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
setPages(pagesWithRows);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
;
|
|
130
|
+
}, [_pages, onRowAction, setPages, currentPage, cysa]);
|
|
114
131
|
var listMarginBottom = hide_page_titles ? 0 : DEFAULT_MARGIN_BOTTOM;
|
|
115
132
|
|
|
116
133
|
var isLastPage = function isLastPage(index) {
|
|
@@ -144,11 +161,12 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
144
161
|
return groupAnswer;
|
|
145
162
|
};
|
|
146
163
|
|
|
164
|
+
var cysaTitle = 'Check your saved answers';
|
|
147
165
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
148
166
|
className: DEFAULT_CLASS
|
|
149
167
|
}, title && !hide_title && /*#__PURE__*/_react.default.createElement(_copReactComponents.LargeHeading, {
|
|
150
168
|
key: "heading"
|
|
151
|
-
}, title), errors && errors.length > 0 && /*#__PURE__*/_react.default.createElement(_copReactComponents.ErrorSummary, {
|
|
169
|
+
}, cysa ? cysaTitle : title), errors && errors.length > 0 && /*#__PURE__*/_react.default.createElement(_copReactComponents.ErrorSummary, {
|
|
152
170
|
errors: errors
|
|
153
171
|
}), type === 'task-list-cya' && pages.length > 0 && sections && sections.map(function (section) {
|
|
154
172
|
return section.tasks.map(function (task) {
|
|
@@ -170,7 +170,17 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
170
170
|
var _useState19 = (0, _react.useState)(false),
|
|
171
171
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
172
172
|
goingBack = _useState20[0],
|
|
173
|
-
setGoingBack = _useState20[1];
|
|
173
|
+
setGoingBack = _useState20[1];
|
|
174
|
+
|
|
175
|
+
var _useState21 = (0, _react.useState)(false),
|
|
176
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
177
|
+
continueOnly = _useState22[0],
|
|
178
|
+
setContinueOnly = _useState22[1];
|
|
179
|
+
|
|
180
|
+
var _useState23 = (0, _react.useState)(),
|
|
181
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
182
|
+
currentTaskListPage = _useState24[0],
|
|
183
|
+
setCurrentTaskListPage = _useState24[1]; // Set up hooks.
|
|
174
184
|
|
|
175
185
|
|
|
176
186
|
var _useHooks = (0, _hooks.useHooks)(),
|
|
@@ -183,13 +193,29 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
183
193
|
validate = _useValidation.validate; // Need to set submission data when going back
|
|
184
194
|
|
|
185
195
|
|
|
186
|
-
window.onpopstate = function () {
|
|
196
|
+
window.onpopstate = function (e) {
|
|
187
197
|
var _formState$page;
|
|
188
198
|
|
|
189
199
|
if (document.location.hash) {
|
|
190
200
|
return;
|
|
191
201
|
}
|
|
192
202
|
|
|
203
|
+
if (e.state && e.state.continueOnly !== undefined) {
|
|
204
|
+
var _e$state;
|
|
205
|
+
|
|
206
|
+
setContinueOnly((_e$state = e.state) === null || _e$state === void 0 ? void 0 : _e$state.continueOnly);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (e.state && e.state.fullPages !== undefined) {
|
|
210
|
+
setCurrentTask(function (prev) {
|
|
211
|
+
var _e$state2;
|
|
212
|
+
|
|
213
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
214
|
+
fullPages: (_e$state2 = e.state) === null || _e$state2 === void 0 ? void 0 : _e$state2.fullPages
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
193
219
|
setGoingBack(true);
|
|
194
220
|
hooks.onGoingBack();
|
|
195
221
|
clearErrors();
|
|
@@ -292,9 +318,10 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
292
318
|
}, [currentTask.fullPages, data, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.sections, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.nonSequential]);
|
|
293
319
|
|
|
294
320
|
var onPageChange = function onPageChange(newPageId) {
|
|
321
|
+
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
295
322
|
clearErrors();
|
|
296
323
|
setPageId(newPageId);
|
|
297
|
-
hooks.onPageChange(newPageId);
|
|
324
|
+
hooks.onPageChange(newPageId, state);
|
|
298
325
|
};
|
|
299
326
|
|
|
300
327
|
(0, _react.useEffect)(function () {
|
|
@@ -336,8 +363,13 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
336
363
|
break;
|
|
337
364
|
|
|
338
365
|
case _models.PageAction.TYPES.SAVE_AND_NAVIGATE:
|
|
366
|
+
var state = {
|
|
367
|
+
'continueOnly': false,
|
|
368
|
+
'fullPages': currentTask.fullPages
|
|
369
|
+
};
|
|
370
|
+
|
|
339
371
|
pageUpdate = function pageUpdate() {
|
|
340
|
-
return _handlers.default.navigate(action, pageId, onPageChange);
|
|
372
|
+
return _handlers.default.navigate(action, pageId, onPageChange, state);
|
|
341
373
|
};
|
|
342
374
|
|
|
343
375
|
break;
|
|
@@ -450,6 +482,8 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
450
482
|
}
|
|
451
483
|
|
|
452
484
|
if (page) {
|
|
485
|
+
setContinueOnly(false);
|
|
486
|
+
|
|
453
487
|
_handlers.default.cyaAction(page, pageId, onPageChange);
|
|
454
488
|
}
|
|
455
489
|
}; //Kick off a task, gather required pages and move to the correct point
|
|
@@ -472,7 +506,18 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
472
506
|
}
|
|
473
507
|
} else if (currentTask.state === _models.TaskStates.TYPES.IN_PROGRESS) {
|
|
474
508
|
var _currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
475
|
-
|
|
509
|
+
|
|
510
|
+
if (currentTask.pages.length > 1 && _currentPage !== _models.FormPages.CYA && _currentPage !== currentTask.pages[0]) {
|
|
511
|
+
setContinueOnly(true);
|
|
512
|
+
setCurrentTaskListPage(_currentPage);
|
|
513
|
+
var state = {
|
|
514
|
+
'continueOnly': true,
|
|
515
|
+
'fullPages': currentTask.fullPages
|
|
516
|
+
};
|
|
517
|
+
onPageChange(_models.FormPages.CYA, state);
|
|
518
|
+
} else {
|
|
519
|
+
onPageChange(_currentPage);
|
|
520
|
+
}
|
|
476
521
|
} else if (currentTask.firstPage) {
|
|
477
522
|
var _currentPage2 = currentTask.firstPage;
|
|
478
523
|
onPageChange(_currentPage2 || currentTask.pages[0]);
|
|
@@ -575,6 +620,12 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
575
620
|
onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, (_formState$page4 = formState.page) === null || _formState$page4 === void 0 ? void 0 : _formState$page4.formData));
|
|
576
621
|
}
|
|
577
622
|
|
|
623
|
+
if (action.type === _models.PageAction.TYPES.CONTINUE) {
|
|
624
|
+
var currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
625
|
+
onPageChange(currentPage || currentTask.pages[0]);
|
|
626
|
+
setContinueOnly(false);
|
|
627
|
+
}
|
|
628
|
+
|
|
578
629
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
579
630
|
hooks.onCancel();
|
|
580
631
|
}
|
|
@@ -583,7 +634,11 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
583
634
|
var classes = _utils.default.classBuilder(classBlock, classModifiers, className);
|
|
584
635
|
|
|
585
636
|
if (hub === _models.HubFormats.TASK) {
|
|
586
|
-
|
|
637
|
+
if (continueOnly) {
|
|
638
|
+
cya.actions = [_models.PageAction.TYPES.CONTINUE];
|
|
639
|
+
} else {
|
|
640
|
+
cya.actions = [_models.PageAction.TYPES.SAVE_AND_CONTINUE, _models.PageAction.TYPES.SAVE_AND_RETURN];
|
|
641
|
+
}
|
|
587
642
|
}
|
|
588
643
|
|
|
589
644
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -599,7 +654,9 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
599
654
|
hide_title: hide_title,
|
|
600
655
|
noChangeAction: noChangeAction,
|
|
601
656
|
sections: typeof hubDetails !== 'undefined' ? hubDetails.sections : [],
|
|
602
|
-
type: type
|
|
657
|
+
type: type,
|
|
658
|
+
cysa: continueOnly,
|
|
659
|
+
currentPage: currentTaskListPage
|
|
603
660
|
})), hub === _models.HubFormats.TASK && formState.pageId === _models.FormPages.HUB && /*#__PURE__*/_react.default.createElement(_TaskList.default, _extends({}, hubDetails, {
|
|
604
661
|
refNumber: data.businessKey,
|
|
605
662
|
onTaskAction: onTaskAction
|
|
@@ -36,6 +36,10 @@ var _taskList = _interopRequireDefault(require("../../json/taskList.json"));
|
|
|
36
36
|
|
|
37
37
|
var _firstForm = _interopRequireDefault(require("../../json/firstForm.json"));
|
|
38
38
|
|
|
39
|
+
var _multiQuestionTaskListData = _interopRequireDefault(require("../../json/multiQuestionTaskListData.json"));
|
|
40
|
+
|
|
41
|
+
var _multiQuestionTaskList = _interopRequireDefault(require("../../json/multiQuestionTaskList.json"));
|
|
42
|
+
|
|
39
43
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
40
44
|
|
|
41
45
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -1002,5 +1006,59 @@ describe('components', function () {
|
|
|
1002
1006
|
}
|
|
1003
1007
|
}, _callee28);
|
|
1004
1008
|
})));
|
|
1009
|
+
it('should display CYSA page when resuming an in-progress form, with Action buttons replaced with a single Continue button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee30() {
|
|
1010
|
+
var ON_SUBMIT, HOOKS, taskList;
|
|
1011
|
+
return regeneratorRuntime.wrap(function _callee30$(_context30) {
|
|
1012
|
+
while (1) {
|
|
1013
|
+
switch (_context30.prev = _context30.next) {
|
|
1014
|
+
case 0:
|
|
1015
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
1016
|
+
onSuccess();
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
HOOKS = {
|
|
1020
|
+
onSubmit: ON_SUBMIT
|
|
1021
|
+
};
|
|
1022
|
+
_context30.next = 4;
|
|
1023
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29() {
|
|
1024
|
+
return regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
1025
|
+
while (1) {
|
|
1026
|
+
switch (_context29.prev = _context29.next) {
|
|
1027
|
+
case 0:
|
|
1028
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _multiQuestionTaskList.default, {
|
|
1029
|
+
data: _multiQuestionTaskListData.default,
|
|
1030
|
+
hooks: HOOKS
|
|
1031
|
+
})), container);
|
|
1032
|
+
|
|
1033
|
+
case 1:
|
|
1034
|
+
case "end":
|
|
1035
|
+
return _context29.stop();
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}, _callee29);
|
|
1039
|
+
})));
|
|
1040
|
+
|
|
1041
|
+
case 4:
|
|
1042
|
+
taskList = container.childNodes[0].childNodes[1]; //Resume the first task
|
|
1043
|
+
|
|
1044
|
+
_react.fireEvent.click(taskList.childNodes[5].childNodes[1].childNodes[0].childNodes[0], {}); // Verify the correct title has been rendered, and the Action buttons have been changed to Continue Only
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Check your saved answers');
|
|
1048
|
+
expect(container.childNodes[0].childNodes[0].childNodes[5].childNodes[0].childNodes[0].textContent).toEqual('Continue'); // Click Continue
|
|
1049
|
+
|
|
1050
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[0].childNodes[5].childNodes[0].childNodes[0], {}); // Verify that Save & Continue / Save and Return Later buttons are restored on the next screen
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
expect(container.childNodes[0].childNodes[0].childNodes[6].childNodes[0].textContent).toEqual('Save and continue');
|
|
1054
|
+
expect(container.childNodes[0].childNodes[0].childNodes[6].childNodes[1].textContent).toEqual('Save and return later');
|
|
1055
|
+
|
|
1056
|
+
case 11:
|
|
1057
|
+
case "end":
|
|
1058
|
+
return _context30.stop();
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}, _callee30);
|
|
1062
|
+
})));
|
|
1005
1063
|
});
|
|
1006
1064
|
});
|
|
@@ -16,11 +16,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
* @param {string} currentPageId The current pageId.
|
|
17
17
|
* @param {Function} onNavigate The handler to call if the pageId is different to the currentPageId.
|
|
18
18
|
*/
|
|
19
|
-
var navigate = function navigate(action, currentPageId, onNavigate) {
|
|
19
|
+
var navigate = function navigate(action, currentPageId, onNavigate, state) {
|
|
20
20
|
var pageId = (0, _getPageId.default)(action, currentPageId);
|
|
21
21
|
|
|
22
22
|
if (pageId !== currentPageId) {
|
|
23
|
-
onNavigate(pageId);
|
|
23
|
+
onNavigate(pageId, state);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "cop-multiTaskList",
|
|
3
|
+
"cya": {
|
|
4
|
+
"actions": [
|
|
5
|
+
{ "type": "saveAndContinue", "label": "save cont", "validate": true }
|
|
6
|
+
],
|
|
7
|
+
"hide_page_titles": false
|
|
8
|
+
},
|
|
9
|
+
"hub": {
|
|
10
|
+
"format": "CYA",
|
|
11
|
+
"refTitle": "COP reference number",
|
|
12
|
+
"sections": [
|
|
13
|
+
{
|
|
14
|
+
"name": "Add passenger details",
|
|
15
|
+
"tasks": [
|
|
16
|
+
{
|
|
17
|
+
"name": "Passenger 1",
|
|
18
|
+
"pages": ["officer", "p1Name", "p1details"],
|
|
19
|
+
"state": "complete"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "Passenger 2",
|
|
23
|
+
"pages": ["relationship", "p2Name", "p2details"],
|
|
24
|
+
"state": "inProgress"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Submit form",
|
|
30
|
+
"tasks": [
|
|
31
|
+
{
|
|
32
|
+
"name": "Accept and submit",
|
|
33
|
+
"pages": ["submitForm"],
|
|
34
|
+
"state": "inProgress"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"name": "cop-multiTaskList",
|
|
41
|
+
"type": "task-list",
|
|
42
|
+
"pages": [
|
|
43
|
+
{
|
|
44
|
+
"id": "officer",
|
|
45
|
+
"name": "officer",
|
|
46
|
+
"title": "Officer Details",
|
|
47
|
+
"actions": [
|
|
48
|
+
{ "page": "p1Name", "type": "saveAndNavigate" },
|
|
49
|
+
"saveAndReturn"
|
|
50
|
+
],
|
|
51
|
+
"cya_link": { "page": "officer", "aria_suffix": "Officer Details" },
|
|
52
|
+
"components": [{ "use": "officerName" }]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": "p1Name",
|
|
56
|
+
"name": "p1Name",
|
|
57
|
+
"title": "Passenger 1 Names",
|
|
58
|
+
"actions": [
|
|
59
|
+
{ "page": "p1details", "type": "saveAndNavigate" },
|
|
60
|
+
"saveAndReturn"
|
|
61
|
+
],
|
|
62
|
+
"cya_link": { "page": "p1Name", "aria_suffix": "Passenger 1 name" },
|
|
63
|
+
"components": [
|
|
64
|
+
{ "use": "passenger1firstname" },
|
|
65
|
+
{ "use": "passenger1surname" }
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "p1details",
|
|
70
|
+
"name": "p1details",
|
|
71
|
+
"title": "Passenger 1 Details",
|
|
72
|
+
"actions": [
|
|
73
|
+
{ "page": "cya", "type": "saveAndNavigate" },
|
|
74
|
+
"saveAndReturn"
|
|
75
|
+
],
|
|
76
|
+
"cya_link": { "page": "p1details", "aria_suffix": "Passenger 1 Details" },
|
|
77
|
+
"components": [
|
|
78
|
+
{ "use": "dateofarrivalp1" },
|
|
79
|
+
{ "use": "dateofdeparturep1" },
|
|
80
|
+
{ "use": "doesp1havevisa" },
|
|
81
|
+
{ "use": "p1flightNo" },
|
|
82
|
+
{ "use": "p1extraDetails" }
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "relationship",
|
|
87
|
+
"name": "relationship",
|
|
88
|
+
"title": "Passenger relationship",
|
|
89
|
+
"actions": [
|
|
90
|
+
{ "page": "p2Name", "type": "saveAndNavigate" },
|
|
91
|
+
"saveAndReturn"
|
|
92
|
+
],
|
|
93
|
+
"cya_link": {
|
|
94
|
+
"page": "relationship",
|
|
95
|
+
"aria_suffix": "Passenger Relationship"
|
|
96
|
+
},
|
|
97
|
+
"components": [{ "use": "p2relationship" }]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "p2Name",
|
|
101
|
+
"name": "p2Name",
|
|
102
|
+
"title": "Passenger 2 Names",
|
|
103
|
+
"actions": [
|
|
104
|
+
{ "page": "p2details", "type": "saveAndNavigate" },
|
|
105
|
+
"saveAndReturn"
|
|
106
|
+
],
|
|
107
|
+
"cya_link": { "page": "p2Name", "aria_suffix": "Passenger 2 name" },
|
|
108
|
+
"components": [
|
|
109
|
+
{ "use": "passenger2firstname" },
|
|
110
|
+
{ "use": "passenger2surname" }
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "p2details",
|
|
115
|
+
"name": "p2details",
|
|
116
|
+
"title": "Passenger 2 Details",
|
|
117
|
+
"actions": [
|
|
118
|
+
{ "page": "cya", "type": "saveAndNavigate" },
|
|
119
|
+
"saveAndReturn"
|
|
120
|
+
],
|
|
121
|
+
"cya_link": { "page": "p2details", "aria_suffix": "Passenger 2 Details" },
|
|
122
|
+
"components": [
|
|
123
|
+
{ "use": "dateofarrivalp2" },
|
|
124
|
+
{ "use": "dateofdeparturep2" },
|
|
125
|
+
{ "use": "doesp2havevisa" },
|
|
126
|
+
{ "use": "p2flightNo" },
|
|
127
|
+
{ "use": "p2extraDetails" }
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": "submitForm",
|
|
132
|
+
"name": "submitForm",
|
|
133
|
+
"title": "Submit",
|
|
134
|
+
"actions": [
|
|
135
|
+
{ "type": "submit", "label": "Submit", "validate": true },
|
|
136
|
+
"saveAndReturn"
|
|
137
|
+
],
|
|
138
|
+
"components": []
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"title": "Task List Multi Question Form",
|
|
142
|
+
"version": "1",
|
|
143
|
+
"components": [
|
|
144
|
+
{
|
|
145
|
+
"id": "officerName",
|
|
146
|
+
"type": "text",
|
|
147
|
+
"label": "Officer name",
|
|
148
|
+
"fieldId": "officerName",
|
|
149
|
+
"required": true
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"id": "passenger1firstname",
|
|
153
|
+
"type": "text",
|
|
154
|
+
"label": "Passenger 1 first name",
|
|
155
|
+
"fieldId": "passenger1firstname",
|
|
156
|
+
"required": true
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"id": "passenger1surname",
|
|
160
|
+
"type": "text",
|
|
161
|
+
"label": "Passenger 1 last name",
|
|
162
|
+
"fieldId": "passenger1surname",
|
|
163
|
+
"required": true
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": "dateofarrivalp1",
|
|
167
|
+
"type": "date",
|
|
168
|
+
"label": "Date of Arrival for passenger 1",
|
|
169
|
+
"fieldId": "dateofarrivalp1",
|
|
170
|
+
"required": true
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"id": "dateofdeparturep1",
|
|
174
|
+
"type": "date",
|
|
175
|
+
"label": "Date of Departure for passenger 1",
|
|
176
|
+
"fieldId": "dateofdeparturep1",
|
|
177
|
+
"required": true
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"id": "doesp1havevisa",
|
|
181
|
+
"data": {
|
|
182
|
+
"options": [
|
|
183
|
+
{ "label": "Yes, passenger 1 has a valid visa", "value": "yes" },
|
|
184
|
+
{
|
|
185
|
+
"label": "No, passenger 1 does not have a valid visa",
|
|
186
|
+
"value": "no"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
"type": "radios",
|
|
191
|
+
"label": "Valid visa",
|
|
192
|
+
"fieldId": "doesp1havevisa",
|
|
193
|
+
"required": true
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"id": "p1flightNo",
|
|
197
|
+
"type": "text",
|
|
198
|
+
"label": "Passenger 1 outbound flight number",
|
|
199
|
+
"fieldId": "p1flightNo",
|
|
200
|
+
"required": true
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"id": "p2relationship",
|
|
204
|
+
"type": "text",
|
|
205
|
+
"label": "What is the relationship of passenger 2 to passenger 1",
|
|
206
|
+
"fieldId": "p2relationship",
|
|
207
|
+
"required": true
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": "p1extraDetails",
|
|
211
|
+
"type": "textarea",
|
|
212
|
+
"label": "Enter any extra details about journey for passenger 1",
|
|
213
|
+
"fieldId": "p1extraDetails",
|
|
214
|
+
"required": true
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"id": "passenger2firstname",
|
|
218
|
+
"type": "text",
|
|
219
|
+
"label": "Passenger 2 first name",
|
|
220
|
+
"fieldId": "passenger2firstname",
|
|
221
|
+
"required": true
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"id": "passenger2surname",
|
|
225
|
+
"type": "text",
|
|
226
|
+
"label": "Passenger 2 last name",
|
|
227
|
+
"fieldId": "passenger2surname",
|
|
228
|
+
"required": true
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"id": "dateofarrivalp2",
|
|
232
|
+
"type": "date",
|
|
233
|
+
"label": "Date of Arrival for passenger 2",
|
|
234
|
+
"fieldId": "dateofarrivalp2",
|
|
235
|
+
"required": true
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"id": "dateofdeparturep2",
|
|
239
|
+
"type": "date",
|
|
240
|
+
"label": "Date of Departure for passenger 2",
|
|
241
|
+
"fieldId": "dateofdeparturep2",
|
|
242
|
+
"required": true
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"id": "doesp2havevisa",
|
|
246
|
+
"data": {
|
|
247
|
+
"options": [
|
|
248
|
+
{ "label": "Yes, passenger 2 has a valid visa", "value": "yes" },
|
|
249
|
+
{
|
|
250
|
+
"label": "No, passenger 2 does not have a valid visa",
|
|
251
|
+
"value": "no"
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
"type": "radios",
|
|
256
|
+
"label": "Valid visa",
|
|
257
|
+
"fieldId": "doesp2havevisa",
|
|
258
|
+
"required": true
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"id": "p2flightNo",
|
|
262
|
+
"type": "text",
|
|
263
|
+
"label": "Passenger 2 outbound flight number",
|
|
264
|
+
"fieldId": "p2flightNo",
|
|
265
|
+
"required": true
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"id": "p2extraDetails",
|
|
269
|
+
"type": "textarea",
|
|
270
|
+
"label": "Enter any extra details about journey for passenger 2",
|
|
271
|
+
"fieldId": "p2extraDetails",
|
|
272
|
+
"required": true
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "695735b6-7187-11ed-a74f-4a1f833894ff",
|
|
3
|
+
"businessKey": "DEV-20221201-1250",
|
|
4
|
+
"officerName": "Bob Smith",
|
|
5
|
+
"formStatus": {
|
|
6
|
+
"tasks": {
|
|
7
|
+
"Passenger 1": { "complete": false, "currentPage": "p1details" }
|
|
8
|
+
},
|
|
9
|
+
"taskPage": "p1details"
|
|
10
|
+
},
|
|
11
|
+
"links": [
|
|
12
|
+
{
|
|
13
|
+
"method": "GET",
|
|
14
|
+
"href": "https://workflow-service-green.dev.cop.homeoffice.gov.uk/camunda/engine-rest/process-instance/695735b6-7187-11ed-a74f-4a1f833894ff",
|
|
15
|
+
"rel": "self"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"definitionId": "cop-multiTaskList:2:04acd47e-6a95-11ed-89dc-8e447b30f638",
|
|
19
|
+
"caseInstanceId": null,
|
|
20
|
+
"ended": false,
|
|
21
|
+
"suspended": false,
|
|
22
|
+
"tenantId": null,
|
|
23
|
+
"passenger1firstname": "James",
|
|
24
|
+
"passenger1surname": "Jones",
|
|
25
|
+
"dateofarrivalp1": "1-1-2022",
|
|
26
|
+
"dateofdeparturep1": "3-2-2022",
|
|
27
|
+
"doesp1havevisa": "yes",
|
|
28
|
+
"p1flightNo": "564131946",
|
|
29
|
+
"p1extraDetails": "N/A",
|
|
30
|
+
"form": {
|
|
31
|
+
"formId": "cop-multiTaskList",
|
|
32
|
+
"formVersionId": "1",
|
|
33
|
+
"title": "Task List Multi Question Form",
|
|
34
|
+
"name": "cop-multiTaskList",
|
|
35
|
+
"submissionDate": "2022-12-01T14:50:58.363Z",
|
|
36
|
+
"submittedBy": "james.bowers@digital.homeoffice.gov.uk",
|
|
37
|
+
"draftForm": true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -14,6 +14,7 @@ var TYPE_COLLECTION_ADD = 'collectionAdd';
|
|
|
14
14
|
var TYPE_COLLECTION_DUPLICATE = 'collectionDuplicate';
|
|
15
15
|
var TYPE_COLLECTION_REMOVE = 'collectionRemove';
|
|
16
16
|
var TYPE_NAVIGATE = 'navigate';
|
|
17
|
+
var TYPE_CONTINUE = 'continue';
|
|
17
18
|
var TYPE_SAVE_AND_CONTINUE = 'saveAndContinue';
|
|
18
19
|
var TYPE_SAVE_AND_NAVIGATE = 'saveAndNavigate';
|
|
19
20
|
var TYPE_SAVE_AND_RETURN = 'saveAndReturn';
|
|
@@ -24,6 +25,7 @@ var PageActionTypes = {
|
|
|
24
25
|
COLLECTION_DUPLICATE: TYPE_COLLECTION_DUPLICATE,
|
|
25
26
|
COLLECTION_REMOVE: TYPE_COLLECTION_REMOVE,
|
|
26
27
|
NAVIGATE: TYPE_NAVIGATE,
|
|
28
|
+
CONTINUE: TYPE_CONTINUE,
|
|
27
29
|
SAVE_AND_CONTINUE: TYPE_SAVE_AND_CONTINUE,
|
|
28
30
|
SAVE_AND_NAVIGATE: TYPE_SAVE_AND_NAVIGATE,
|
|
29
31
|
SAVE_AND_RETURN: TYPE_SAVE_AND_RETURN,
|
|
@@ -35,7 +37,11 @@ var DefaultPageActions = (_DefaultPageActions = {}, _defineProperty(_DefaultPage
|
|
|
35
37
|
validate: false,
|
|
36
38
|
label: 'Cancel',
|
|
37
39
|
classModifiers: 'secondary'
|
|
38
|
-
}), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_ADD, undefined), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_DUPLICATE, undefined), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_REMOVE, undefined), _defineProperty(_DefaultPageActions, TYPE_NAVIGATE, undefined), _defineProperty(_DefaultPageActions,
|
|
40
|
+
}), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_ADD, undefined), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_DUPLICATE, undefined), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_REMOVE, undefined), _defineProperty(_DefaultPageActions, TYPE_NAVIGATE, undefined), _defineProperty(_DefaultPageActions, TYPE_CONTINUE, {
|
|
41
|
+
type: TYPE_CONTINUE,
|
|
42
|
+
validate: true,
|
|
43
|
+
label: 'Continue'
|
|
44
|
+
}), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_CONTINUE, {
|
|
39
45
|
type: TYPE_SAVE_AND_CONTINUE,
|
|
40
46
|
validate: true,
|
|
41
47
|
label: 'Save and continue'
|
|
@@ -67,6 +67,30 @@ var meetsCondition = function meetsCondition(condition, value) {
|
|
|
67
67
|
return true;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
case '<':
|
|
71
|
+
{
|
|
72
|
+
if (!value || !compare) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var valFloat = parseFloat(value.replace(',', ''));
|
|
77
|
+
var compareFloat = parseFloat(compare.replace(',', ''));
|
|
78
|
+
return valFloat < compareFloat;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
case '>':
|
|
82
|
+
{
|
|
83
|
+
if (!value || !compare) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var _valFloat = parseFloat(value.replace(',', ''));
|
|
88
|
+
|
|
89
|
+
var _compareFloat = parseFloat(compare.replace(',', ''));
|
|
90
|
+
|
|
91
|
+
return _valFloat > _compareFloat;
|
|
92
|
+
}
|
|
93
|
+
|
|
70
94
|
case 'contains':
|
|
71
95
|
{
|
|
72
96
|
return value === null || value === void 0 ? void 0 : value.toString().toLowerCase().includes(compare); // If no value is provided, the field cannot contain it, so it must fail the condition.
|
|
@@ -439,6 +439,78 @@ describe('utils.Condition.meetsCondition', function () {
|
|
|
439
439
|
expect((0, _meetsCondition.default)(CONDITION, FIELD)).toBeFalsy();
|
|
440
440
|
});
|
|
441
441
|
});
|
|
442
|
+
describe('numerical operators', function () {
|
|
443
|
+
it('less than should reject when value is null', function () {
|
|
444
|
+
var CONDITION = {
|
|
445
|
+
op: '<',
|
|
446
|
+
value: '100'
|
|
447
|
+
};
|
|
448
|
+
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
449
|
+
});
|
|
450
|
+
it('less than should reject when condition.value is null', function () {
|
|
451
|
+
var CONDITION = {
|
|
452
|
+
op: '<',
|
|
453
|
+
value: null
|
|
454
|
+
};
|
|
455
|
+
expect((0, _meetsCondition.default)(CONDITION, '100')).toBeFalsy();
|
|
456
|
+
});
|
|
457
|
+
it('less than should reject when condition.value and value are null', function () {
|
|
458
|
+
var CONDITION = {
|
|
459
|
+
op: '<',
|
|
460
|
+
value: null
|
|
461
|
+
};
|
|
462
|
+
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
463
|
+
});
|
|
464
|
+
it('less than should reject when value is greater than condition.value', function () {
|
|
465
|
+
var CONDITION = {
|
|
466
|
+
op: '<',
|
|
467
|
+
value: '100'
|
|
468
|
+
};
|
|
469
|
+
expect((0, _meetsCondition.default)(CONDITION, '101')).toBeFalsy();
|
|
470
|
+
});
|
|
471
|
+
it('less than should accept when value is less than condition.value', function () {
|
|
472
|
+
var CONDITION = {
|
|
473
|
+
op: '<',
|
|
474
|
+
value: '100'
|
|
475
|
+
};
|
|
476
|
+
expect((0, _meetsCondition.default)(CONDITION, '99')).toBeTruthy();
|
|
477
|
+
});
|
|
478
|
+
it('greater than should reject when value is null', function () {
|
|
479
|
+
var CONDITION = {
|
|
480
|
+
op: '>',
|
|
481
|
+
value: '100'
|
|
482
|
+
};
|
|
483
|
+
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
484
|
+
});
|
|
485
|
+
it('greater than should reject when condition.value is null', function () {
|
|
486
|
+
var CONDITION = {
|
|
487
|
+
op: '>',
|
|
488
|
+
value: null
|
|
489
|
+
};
|
|
490
|
+
expect((0, _meetsCondition.default)(CONDITION, '100')).toBeFalsy();
|
|
491
|
+
});
|
|
492
|
+
it('greater than should reject when condition.value and value are null', function () {
|
|
493
|
+
var CONDITION = {
|
|
494
|
+
op: '>',
|
|
495
|
+
value: null
|
|
496
|
+
};
|
|
497
|
+
expect((0, _meetsCondition.default)(CONDITION, null)).toBeFalsy();
|
|
498
|
+
});
|
|
499
|
+
it('greater than should reject when value is less than condition.value', function () {
|
|
500
|
+
var CONDITION = {
|
|
501
|
+
op: '>',
|
|
502
|
+
value: '100'
|
|
503
|
+
};
|
|
504
|
+
expect((0, _meetsCondition.default)(CONDITION, '99')).toBeFalsy();
|
|
505
|
+
});
|
|
506
|
+
it('greater than should accept when value is greater than condition.value', function () {
|
|
507
|
+
var CONDITION = {
|
|
508
|
+
op: '>',
|
|
509
|
+
value: '100'
|
|
510
|
+
};
|
|
511
|
+
expect((0, _meetsCondition.default)(CONDITION, '101')).toBeTruthy();
|
|
512
|
+
});
|
|
513
|
+
});
|
|
442
514
|
describe('unknown operator', function () {
|
|
443
515
|
var op = 'definitely_not_a_real_operator';
|
|
444
516
|
it('should reject anything regardless of the value', function () {
|