@ukhomeoffice/cop-react-form-renderer 6.15.7 → 6.15.8-charlie

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.
@@ -144,10 +144,21 @@ const InternalFormRenderer = _ref2 => {
144
144
  setGoingBack(true);
145
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;
147
148
  const submissionData = _utils.default.Format.form({
148
149
  pages,
149
150
  components
150
151
  }, _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
+ }
151
162
  setData(submissionData);
152
163
  }
153
164
  };
@@ -30,6 +30,12 @@ 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
+ }
33
39
  return defaultState;
34
40
  };
35
41
 
@@ -115,6 +115,26 @@ 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
+ });
118
138
  it("should set the status of any tasks in a section with a failed show_when to '".concat(_models.TaskStates.TYPES.SKIPPED, "'"), () => {
119
139
  const SECTIONS = [{
120
140
  name: 'Add event details',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "6.15.7",
3
+ "version": "6.15.8-charlie",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",