@ukhomeoffice/cop-react-form-renderer 6.15.9-gamma → 6.15.12-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.
|
@@ -142,23 +142,12 @@ const InternalFormRenderer = _ref2 => {
|
|
|
142
142
|
}
|
|
143
143
|
clearErrors();
|
|
144
144
|
setGoingBack(true);
|
|
145
|
-
hooks.onGoingBack(e.state ? e.state : null
|
|
145
|
+
hooks.onGoingBack(e.state ? e.state : null);
|
|
146
146
|
if (components && pages && data && (_formState$page = formState.page) !== null && _formState$page !== void 0 && _formState$page.formData && pagePoint === undefined) {
|
|
147
|
-
var _submissionData$formS;
|
|
148
147
|
const submissionData = _utils.default.Format.form({
|
|
149
148
|
pages,
|
|
150
149
|
components
|
|
151
150
|
}, _objectSpread(_objectSpread({}, data), formState.page.formData), _models.EventTypes.SUBMIT);
|
|
152
|
-
if (submissionData !== null && submissionData !== void 0 && (_submissionData$formS = submissionData.formStatus) !== null && _submissionData$formS !== void 0 && _submissionData$formS.taskPage) {
|
|
153
|
-
const object = submissionData.formStatus.tasks;
|
|
154
|
-
Object.keys(object).forEach(key => {
|
|
155
|
-
const value = object[key];
|
|
156
|
-
if (value.currentPage && !value.complete) {
|
|
157
|
-
delete object[key].currentPage;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
delete submissionData.formStatus.taskPage;
|
|
161
|
-
}
|
|
162
151
|
setData(submissionData);
|
|
163
152
|
}
|
|
164
153
|
};
|
|
@@ -200,6 +189,17 @@ const InternalFormRenderer = _ref2 => {
|
|
|
200
189
|
setFormState(_helpers.default.getFormState(pageId, pages, hub));
|
|
201
190
|
}, [pages, hub, pageId, setFormState, type, goingBack, data, formState.page]);
|
|
202
191
|
|
|
192
|
+
// page rendered page
|
|
193
|
+
(0, _react.useEffect)(() => {
|
|
194
|
+
if (document) {
|
|
195
|
+
const element = document.getElementsByTagName("h1")[0];
|
|
196
|
+
if (element) {
|
|
197
|
+
element.setAttribute("tabIndex", "-1");
|
|
198
|
+
element.focus();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}, [formState.page]);
|
|
202
|
+
|
|
203
203
|
// Call the onFormLoad hook just when this component first renders.
|
|
204
204
|
(0, _react.useEffect)(() => {
|
|
205
205
|
setPagePoint(undefined);
|
|
@@ -30,12 +30,6 @@ const getCurrentTaskState = function (_ref) {
|
|
|
30
30
|
if (currentPage) {
|
|
31
31
|
return _models.TaskStates.TYPES.IN_PROGRESS;
|
|
32
32
|
}
|
|
33
|
-
// If the user has clicked on the back link (see FormRenderer.jsx window.onpopstate event handler)
|
|
34
|
-
// the task will be incomplete and the currentPage deleted
|
|
35
|
-
// and the task state should be recognised as 'In progress'.
|
|
36
|
-
if (complete !== undefined && !complete && currentPage === undefined) {
|
|
37
|
-
return _models.TaskStates.TYPES.IN_PROGRESS;
|
|
38
|
-
}
|
|
39
33
|
return defaultState;
|
|
40
34
|
};
|
|
41
35
|
|
|
@@ -115,26 +115,6 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
115
115
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.IN_PROGRESS);
|
|
116
116
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
117
117
|
});
|
|
118
|
-
it("should set tasks to '".concat(_models.TaskStates.TYPES.IN_PROGRESS, "' if they have no current page and are not complete"), () => {
|
|
119
|
-
const SECTIONS = [{
|
|
120
|
-
name: 'Add event details',
|
|
121
|
-
tasks: [{
|
|
122
|
-
name: 'Date, location and mode details',
|
|
123
|
-
pages: ['eventDate', 'eventMode']
|
|
124
|
-
}, {
|
|
125
|
-
name: 'Officer and agency details',
|
|
126
|
-
pages: ['officeDetails']
|
|
127
|
-
}]
|
|
128
|
-
}];
|
|
129
|
-
const TASKS = {
|
|
130
|
-
'Date, location and mode details': {
|
|
131
|
-
complete: false
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
const updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS);
|
|
135
|
-
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.IN_PROGRESS);
|
|
136
|
-
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
137
|
-
});
|
|
138
118
|
it("should set the status of any tasks in a section with a failed show_when to '".concat(_models.TaskStates.TYPES.SKIPPED, "'"), () => {
|
|
139
119
|
const SECTIONS = [{
|
|
140
120
|
name: 'Add event details',
|