@ukhomeoffice/cop-react-form-renderer 5.16.0 → 5.16.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.
|
@@ -9,6 +9,7 @@ var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
|
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentPageId, action, formData, currentTask, isCompleted, sections) {
|
|
11
11
|
if (formType === _models.FormTypes.TASK || formType === _models.FormTypes.FORM_WITH_TASK) {
|
|
12
|
+
var _currentTask$pages;
|
|
12
13
|
var formStatus = formData.formStatus || {};
|
|
13
14
|
formStatus.tasks = formStatus.tasks || {};
|
|
14
15
|
formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
|
|
@@ -42,7 +43,7 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
|
|
|
42
43
|
complete: false,
|
|
43
44
|
currentPage: (0, _getNextPageId.default)(formType, pages, currentPageId, action, formData)
|
|
44
45
|
};
|
|
45
|
-
} else {
|
|
46
|
+
} else if ((_currentTask$pages = currentTask.pages) !== null && _currentTask$pages !== void 0 && _currentTask$pages.includes(currentPageId)) {
|
|
46
47
|
formStatus.tasks[currentTask.name] = {
|
|
47
48
|
complete: !!(action !== null && action !== void 0 && action.complete),
|
|
48
49
|
currentPage: currentPageId
|
|
@@ -241,7 +241,8 @@ describe('components', function () {
|
|
|
241
241
|
var CURRENT_PAGE_ID = PAGES[0].id;
|
|
242
242
|
var TASK_NAME = 'taskName';
|
|
243
243
|
var CURRENT_TASK = {
|
|
244
|
-
name: TASK_NAME
|
|
244
|
+
name: TASK_NAME,
|
|
245
|
+
pages: [CURRENT_PAGE_ID]
|
|
245
246
|
};
|
|
246
247
|
var ACTION = {
|
|
247
248
|
complete: true
|
|
@@ -274,6 +275,26 @@ describe('components', function () {
|
|
|
274
275
|
})
|
|
275
276
|
});
|
|
276
277
|
});
|
|
278
|
+
it('should not update the current task state if the current page does not belong in the task', function () {
|
|
279
|
+
var CUSTOM_FORM_TYPE = _models.FormTypes.FORM_WITH_TASK;
|
|
280
|
+
var ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
281
|
+
var CURRENT_TASK = {
|
|
282
|
+
name: 'test-task',
|
|
283
|
+
pages: ['page-a']
|
|
284
|
+
};
|
|
285
|
+
var CURRENT_PAGE_ID = 'page-b';
|
|
286
|
+
var CUSTOM_FORM_DATA = {
|
|
287
|
+
formStatus: {
|
|
288
|
+
tasks: {
|
|
289
|
+
'test-task': {
|
|
290
|
+
complete: false,
|
|
291
|
+
currentPage: 'page-a'
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
expect((0, _getSubmissionStatus.default)(CUSTOM_FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, CUSTOM_FORM_DATA, CURRENT_TASK, true, [])).toMatchObject(CUSTOM_FORM_DATA.formStatus);
|
|
297
|
+
});
|
|
277
298
|
});
|
|
278
299
|
});
|
|
279
300
|
});
|