@ukhomeoffice/cop-react-form-renderer 3.13.0 → 3.15.0
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.stories.mdx +87 -69
- package/dist/components/FormComponent/FormComponent.stories.mdx +21 -4
- package/dist/components/FormPage/FormPage.stories.mdx +16 -3
- package/dist/components/FormRenderer/FormRenderer.js +8 -3
- package/dist/components/FormRenderer/FormRenderer.test.js +99 -11
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +4 -6
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +15 -0
- package/package.json +2 -2
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
<!-- Global imports -->
|
|
2
2
|
|
|
3
3
|
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
4
|
-
import {
|
|
5
|
-
Details,
|
|
6
|
-
Heading,
|
|
7
|
-
Link,
|
|
8
|
-
Tag,
|
|
9
|
-
} from '@ukhomeoffice/cop-react-components';
|
|
4
|
+
import { Details, Heading, Link, Tag } from '@ukhomeoffice/cop-react-components';
|
|
10
5
|
import withMock from 'storybook-addon-mock';
|
|
11
6
|
|
|
12
7
|
<!-- Local imports -->
|
|
13
|
-
|
|
8
|
+
import { HooksContextProvider, ValidationContextProvider } from '../../context';
|
|
14
9
|
import Utils from '../../utils';
|
|
15
10
|
import CheckYourAnswers from './CheckYourAnswers';
|
|
16
11
|
|
|
17
12
|
<!-- JSON documents -->
|
|
18
|
-
|
|
19
13
|
import CIVIL_SERVANT from '../../json/areYouACivilServant.json';
|
|
20
14
|
import GRADE from '../../json/grade.json';
|
|
21
15
|
import TEAMS from '../../json/team.json';
|
|
@@ -84,11 +78,15 @@ Renders the **Check your answers** screen for a form.
|
|
|
84
78
|
console.log('row action invoked', page);
|
|
85
79
|
};
|
|
86
80
|
return (
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
<HooksContextProvider>
|
|
82
|
+
<ValidationContextProvider>
|
|
83
|
+
<CheckYourAnswers
|
|
84
|
+
pages={PAGES}
|
|
85
|
+
onAction={ON_ACTION}
|
|
86
|
+
onRowAction={ON_ROW_ACTION}
|
|
87
|
+
/>
|
|
88
|
+
</ValidationContextProvider>
|
|
89
|
+
</HooksContextProvider>
|
|
92
90
|
);
|
|
93
91
|
}}
|
|
94
92
|
</Story>
|
|
@@ -146,12 +144,16 @@ Renders the **Check your answers** screen for a form.
|
|
|
146
144
|
console.log('row action invoked', page);
|
|
147
145
|
};
|
|
148
146
|
return (
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
<HooksContextProvider>
|
|
148
|
+
<ValidationContextProvider>
|
|
149
|
+
<CheckYourAnswers
|
|
150
|
+
pages={PAGES}
|
|
151
|
+
hide_page_titles={true}
|
|
152
|
+
onAction={ON_ACTION}
|
|
153
|
+
onRowAction={ON_ROW_ACTION}
|
|
154
|
+
/>
|
|
155
|
+
</ValidationContextProvider>
|
|
156
|
+
</HooksContextProvider>
|
|
155
157
|
);
|
|
156
158
|
}}
|
|
157
159
|
</Story>
|
|
@@ -200,13 +202,17 @@ Renders the **Check your answers** screen for a form.
|
|
|
200
202
|
console.log('row action invoked', page);
|
|
201
203
|
};
|
|
202
204
|
return (
|
|
203
|
-
<
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
<HooksContextProvider>
|
|
206
|
+
<ValidationContextProvider>
|
|
207
|
+
<CheckYourAnswers
|
|
208
|
+
pages={PAGES}
|
|
209
|
+
hide_page_titles={true}
|
|
210
|
+
actions={ACTIONS}
|
|
211
|
+
onAction={ON_ACTION}
|
|
212
|
+
onRowAction={ON_ROW_ACTION}
|
|
213
|
+
/>
|
|
214
|
+
</ValidationContextProvider>
|
|
215
|
+
</HooksContextProvider>
|
|
210
216
|
);
|
|
211
217
|
}}
|
|
212
218
|
</Story>
|
|
@@ -258,15 +264,19 @@ Renders the **Check your answers** screen for a form.
|
|
|
258
264
|
console.log('row action invoked', page);
|
|
259
265
|
};
|
|
260
266
|
return (
|
|
261
|
-
<
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
<HooksContextProvider>
|
|
268
|
+
<ValidationContextProvider>
|
|
269
|
+
<CheckYourAnswers
|
|
270
|
+
pages={PAGES}
|
|
271
|
+
hide_page_titles={true}
|
|
272
|
+
onAction={ON_ACTION}
|
|
273
|
+
onRowAction={ON_ROW_ACTION}
|
|
274
|
+
hide_title={true}
|
|
275
|
+
summaryListClassModifiers='no-border'
|
|
276
|
+
noChangeAction={true}
|
|
277
|
+
/>
|
|
278
|
+
</ValidationContextProvider>
|
|
279
|
+
</HooksContextProvider>
|
|
270
280
|
);
|
|
271
281
|
}}
|
|
272
282
|
</Story>
|
|
@@ -320,13 +330,17 @@ Renders the **Check your answers** screen for a form.
|
|
|
320
330
|
console.log('row action invoked', page);
|
|
321
331
|
};
|
|
322
332
|
return (
|
|
323
|
-
<
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
333
|
+
<HooksContextProvider>
|
|
334
|
+
<ValidationContextProvider>
|
|
335
|
+
<CheckYourAnswers
|
|
336
|
+
pages={PAGES}
|
|
337
|
+
hide_page_titles={false}
|
|
338
|
+
onAction={ON_ACTION}
|
|
339
|
+
onRowAction={ON_ROW_ACTION}
|
|
340
|
+
groups={CYA.groups}
|
|
341
|
+
/>
|
|
342
|
+
</ValidationContextProvider>
|
|
343
|
+
</HooksContextProvider>
|
|
330
344
|
);
|
|
331
345
|
}}
|
|
332
346
|
</Story>
|
|
@@ -359,33 +373,37 @@ Renders the **Check your answers** screen for a form.
|
|
|
359
373
|
],
|
|
360
374
|
}}>
|
|
361
375
|
{() => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
376
|
+
const DATA = Utils.Data.setupForm(
|
|
377
|
+
GROUP.pages,
|
|
378
|
+
GROUP.components,
|
|
379
|
+
GROUP_DATA
|
|
380
|
+
);
|
|
381
|
+
const PAGES = Utils.FormPage.getAll(
|
|
382
|
+
GROUP.pages,
|
|
383
|
+
GROUP.components,
|
|
384
|
+
{ ...DATA }
|
|
385
|
+
);
|
|
386
|
+
const ACTIONS = GROUP.cya.actions;
|
|
387
|
+
const ON_ACTION = (action, patch, onError) => {
|
|
388
|
+
console.log('action invoked', action, patch);
|
|
389
|
+
};
|
|
390
|
+
const ON_ROW_ACTION = (page) => {
|
|
391
|
+
console.log('row action invoked', page);
|
|
392
|
+
};
|
|
393
|
+
return (
|
|
394
|
+
<HooksContextProvider>
|
|
395
|
+
<ValidationContextProvider>
|
|
396
|
+
<CheckYourAnswers
|
|
397
|
+
pages={PAGES}
|
|
398
|
+
hide_page_titles={true}
|
|
399
|
+
actions={ACTIONS}
|
|
400
|
+
onAction={ON_ACTION}
|
|
401
|
+
onRowAction={ON_ROW_ACTION}
|
|
402
|
+
/>
|
|
403
|
+
</ValidationContextProvider>
|
|
404
|
+
</HooksContextProvider>
|
|
405
|
+
);
|
|
406
|
+
}}
|
|
389
407
|
</Story>
|
|
390
408
|
</Canvas>
|
|
391
409
|
|
|
@@ -4,6 +4,7 @@ import { Details, Heading, Link } from '@ukhomeoffice/cop-react-components';
|
|
|
4
4
|
import withMock from 'storybook-addon-mock';
|
|
5
5
|
|
|
6
6
|
<!-- Local imports -->
|
|
7
|
+
import { HooksContextProvider, ValidationContextProvider } from '../../context';
|
|
7
8
|
import FormComponent from './FormComponent';
|
|
8
9
|
|
|
9
10
|
<!-- JSON documents -->
|
|
@@ -54,7 +55,11 @@ on the basis of a <Link href="/?path=/docs/f-json-component">JSON</Link> configu
|
|
|
54
55
|
// Do something with the target here.
|
|
55
56
|
};
|
|
56
57
|
return (
|
|
57
|
-
<
|
|
58
|
+
<HooksContextProvider>
|
|
59
|
+
<ValidationContextProvider>
|
|
60
|
+
<FormComponent component={COMPONENT} value={''} onChange={ON_CHANGE} />
|
|
61
|
+
</ValidationContextProvider>
|
|
62
|
+
</HooksContextProvider>
|
|
58
63
|
);
|
|
59
64
|
}}
|
|
60
65
|
</Story>
|
|
@@ -101,7 +106,11 @@ on the basis of a <Link href="/?path=/docs/f-json-component">JSON</Link> configu
|
|
|
101
106
|
// Do something with the target here.
|
|
102
107
|
};
|
|
103
108
|
return (
|
|
104
|
-
<
|
|
109
|
+
<HooksContextProvider>
|
|
110
|
+
<ValidationContextProvider>
|
|
111
|
+
<FormComponent component={COMPONENT} value={''} onChange={ON_CHANGE} />
|
|
112
|
+
</ValidationContextProvider>
|
|
113
|
+
</HooksContextProvider>
|
|
105
114
|
);
|
|
106
115
|
}}
|
|
107
116
|
</Story>
|
|
@@ -117,7 +126,11 @@ on the basis of a <Link href="/?path=/docs/f-json-component">JSON</Link> configu
|
|
|
117
126
|
// Do something with the target here.
|
|
118
127
|
};
|
|
119
128
|
return (
|
|
120
|
-
<
|
|
129
|
+
<HooksContextProvider>
|
|
130
|
+
<ValidationContextProvider>
|
|
131
|
+
<FormComponent component={COMPONENT} value={''} onChange={ON_CHANGE} />
|
|
132
|
+
</ValidationContextProvider>
|
|
133
|
+
</HooksContextProvider>
|
|
121
134
|
);
|
|
122
135
|
}}
|
|
123
136
|
</Story>
|
|
@@ -160,7 +173,11 @@ on the basis of a <Link href="/?path=/docs/f-json-component">JSON</Link> configu
|
|
|
160
173
|
// Do something with the target here.
|
|
161
174
|
};
|
|
162
175
|
return (
|
|
163
|
-
<
|
|
176
|
+
<HooksContextProvider>
|
|
177
|
+
<ValidationContextProvider>
|
|
178
|
+
<FormComponent component={COMPONENT} value={''} wrap={false} onChange={ON_CHANGE} />
|
|
179
|
+
</ValidationContextProvider>
|
|
180
|
+
</HooksContextProvider>
|
|
164
181
|
);
|
|
165
182
|
}}
|
|
166
183
|
</Story>
|
|
@@ -4,6 +4,7 @@ import { Details, Heading, Link } from '@ukhomeoffice/cop-react-components';
|
|
|
4
4
|
import withMock from 'storybook-addon-mock';
|
|
5
5
|
|
|
6
6
|
<!-- Local imports -->
|
|
7
|
+
import { HooksContextProvider, ValidationContextProvider } from '../../context';
|
|
7
8
|
import Utils from '../../utils';
|
|
8
9
|
import FormPage from './FormPage';
|
|
9
10
|
|
|
@@ -51,7 +52,11 @@ on the basis of a <Link href="/?path=/docs/f-json-page">JSON</Link> configuratio
|
|
|
51
52
|
console.log('action invoked', action, patch);
|
|
52
53
|
};
|
|
53
54
|
return (
|
|
54
|
-
<
|
|
55
|
+
<HooksContextProvider>
|
|
56
|
+
<ValidationContextProvider>
|
|
57
|
+
<FormPage page={PAGE} onAction={ON_ACTION} />
|
|
58
|
+
</ValidationContextProvider>
|
|
59
|
+
</HooksContextProvider>
|
|
55
60
|
);
|
|
56
61
|
}}
|
|
57
62
|
</Story>
|
|
@@ -94,7 +99,11 @@ on the basis of a <Link href="/?path=/docs/f-json-page">JSON</Link> configuratio
|
|
|
94
99
|
console.log('action invoked', action, patch);
|
|
95
100
|
};
|
|
96
101
|
return (
|
|
97
|
-
<
|
|
102
|
+
<HooksContextProvider>
|
|
103
|
+
<ValidationContextProvider>
|
|
104
|
+
<FormPage page={PAGE} onAction={ON_ACTION} />
|
|
105
|
+
</ValidationContextProvider>
|
|
106
|
+
</HooksContextProvider>
|
|
98
107
|
);
|
|
99
108
|
}}
|
|
100
109
|
</Story>
|
|
@@ -111,7 +120,11 @@ on the basis of a <Link href="/?path=/docs/f-json-page">JSON</Link> configuratio
|
|
|
111
120
|
console.log('action invoked', action, patch);
|
|
112
121
|
};
|
|
113
122
|
return (
|
|
114
|
-
<
|
|
123
|
+
<HooksContextProvider>
|
|
124
|
+
<ValidationContextProvider>
|
|
125
|
+
<FormPage page={PAGE} onAction={ON_ACTION} />
|
|
126
|
+
</ValidationContextProvider>
|
|
127
|
+
</HooksContextProvider>
|
|
115
128
|
);
|
|
116
129
|
}}
|
|
117
130
|
</Story>
|
|
@@ -323,10 +323,15 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
323
323
|
setCurrentTask(currentTask);
|
|
324
324
|
|
|
325
325
|
if (currentTask.state === _models.TaskStates.TYPES.COMPLETE) {
|
|
326
|
-
|
|
326
|
+
if (hubDetails !== null && hubDetails !== void 0 && hubDetails.noTaskCYAs) {
|
|
327
|
+
var currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
328
|
+
onPageChange(currentPage || currentTask.pages[0]);
|
|
329
|
+
} else {
|
|
330
|
+
onPageChange(_models.FormPages.CYA);
|
|
331
|
+
}
|
|
327
332
|
} else if (currentTask.state === _models.TaskStates.TYPES.IN_PROGRESS) {
|
|
328
|
-
var
|
|
329
|
-
onPageChange(
|
|
333
|
+
var _currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
334
|
+
onPageChange(_currentPage || currentTask.pages[0]);
|
|
330
335
|
} else {
|
|
331
336
|
onPageChange(currentTask.pages[0]);
|
|
332
337
|
}
|
|
@@ -747,12 +747,100 @@ describe('components', function () {
|
|
|
747
747
|
}
|
|
748
748
|
}, _callee20);
|
|
749
749
|
})));
|
|
750
|
-
it('should
|
|
751
|
-
var
|
|
752
|
-
|
|
750
|
+
it('should go to the last page of a complete task if noTaskCYAs specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
|
|
751
|
+
var ON_SUBMIT, HOOKS, TASK_LIST_WITH_NO_TASK_CYAS, taskList, newPage;
|
|
753
752
|
return regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
754
753
|
while (1) {
|
|
755
754
|
switch (_context22.prev = _context22.next) {
|
|
755
|
+
case 0:
|
|
756
|
+
ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
|
|
757
|
+
onSuccess();
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
HOOKS = {
|
|
761
|
+
onSubmit: ON_SUBMIT
|
|
762
|
+
};
|
|
763
|
+
TASK_LIST_WITH_NO_TASK_CYAS = JSON.parse(JSON.stringify(_taskList.default));
|
|
764
|
+
TASK_LIST_WITH_NO_TASK_CYAS.hub.noTaskCYAs = true;
|
|
765
|
+
TASK_LIST_WITH_NO_TASK_CYAS.pages[1].actions[0] = {
|
|
766
|
+
type: 'save',
|
|
767
|
+
complete: true
|
|
768
|
+
};
|
|
769
|
+
_context22.next = 7;
|
|
770
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {
|
|
771
|
+
return regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
772
|
+
while (1) {
|
|
773
|
+
switch (_context21.prev = _context21.next) {
|
|
774
|
+
case 0:
|
|
775
|
+
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NO_TASK_CYAS, {
|
|
776
|
+
hooks: HOOKS
|
|
777
|
+
})), container);
|
|
778
|
+
|
|
779
|
+
case 1:
|
|
780
|
+
case "end":
|
|
781
|
+
return _context21.stop();
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}, _callee21);
|
|
785
|
+
})));
|
|
786
|
+
|
|
787
|
+
case 7:
|
|
788
|
+
taskList = container.childNodes[0].childNodes[1]; // Launch first task
|
|
789
|
+
|
|
790
|
+
_react.fireEvent.click(taskList.childNodes[3].childNodes[0].childNodes[0].childNodes[0], {}); // Fill first page and navigate
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
794
|
+
|
|
795
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[1], {
|
|
796
|
+
target: {
|
|
797
|
+
name: 'date-day',
|
|
798
|
+
value: '7'
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[1].childNodes[1], {
|
|
803
|
+
target: {
|
|
804
|
+
name: 'date-month',
|
|
805
|
+
value: '7'
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[2].childNodes[1], {
|
|
810
|
+
target: {
|
|
811
|
+
name: 'date-year',
|
|
812
|
+
value: '2022'
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {}); // Fill second page
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
newPage = container.childNodes[0].childNodes[0];
|
|
820
|
+
|
|
821
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[0], {});
|
|
822
|
+
|
|
823
|
+
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {}); // Launch same task again
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
_react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[0].childNodes[0].childNodes[0], {}); // Should be on the second page
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Mode');
|
|
830
|
+
|
|
831
|
+
case 19:
|
|
832
|
+
case "end":
|
|
833
|
+
return _context22.stop();
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}, _callee22);
|
|
837
|
+
})));
|
|
838
|
+
it('should handle cancellation from a page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24() {
|
|
839
|
+
var ON_CANCEL_CALLS, ON_CANCEL, HOOKS, form, hub, _hub$childNodes5, civilServantList, link, page, cancel;
|
|
840
|
+
|
|
841
|
+
return regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
842
|
+
while (1) {
|
|
843
|
+
switch (_context24.prev = _context24.next) {
|
|
756
844
|
case 0:
|
|
757
845
|
ON_CANCEL_CALLS = [];
|
|
758
846
|
|
|
@@ -763,11 +851,11 @@ describe('components', function () {
|
|
|
763
851
|
HOOKS = {
|
|
764
852
|
onCancel: ON_CANCEL
|
|
765
853
|
};
|
|
766
|
-
|
|
767
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
768
|
-
return regeneratorRuntime.wrap(function
|
|
854
|
+
_context24.next = 5;
|
|
855
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23() {
|
|
856
|
+
return regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
769
857
|
while (1) {
|
|
770
|
-
switch (
|
|
858
|
+
switch (_context23.prev = _context23.next) {
|
|
771
859
|
case 0:
|
|
772
860
|
(0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
|
|
773
861
|
data: _userProfileData.default,
|
|
@@ -776,10 +864,10 @@ describe('components', function () {
|
|
|
776
864
|
|
|
777
865
|
case 1:
|
|
778
866
|
case "end":
|
|
779
|
-
return
|
|
867
|
+
return _context23.stop();
|
|
780
868
|
}
|
|
781
869
|
}
|
|
782
|
-
},
|
|
870
|
+
}, _callee23);
|
|
783
871
|
})));
|
|
784
872
|
|
|
785
873
|
case 5:
|
|
@@ -803,10 +891,10 @@ describe('components', function () {
|
|
|
803
891
|
|
|
804
892
|
case 15:
|
|
805
893
|
case "end":
|
|
806
|
-
return
|
|
894
|
+
return _context24.stop();
|
|
807
895
|
}
|
|
808
896
|
}
|
|
809
|
-
},
|
|
897
|
+
}, _callee24);
|
|
810
898
|
})));
|
|
811
899
|
});
|
|
812
900
|
});
|
|
@@ -13,22 +13,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
13
|
|
|
14
14
|
var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentPageId, action, formData, currentTask, isCompleted) {
|
|
15
15
|
if (formType === _models.FormTypes.TASK) {
|
|
16
|
-
var formStatus = formData.formStatus
|
|
17
|
-
formStatus.tasks = formStatus.tasks
|
|
18
|
-
formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name]
|
|
16
|
+
var formStatus = formData.formStatus || {};
|
|
17
|
+
formStatus.tasks = formStatus.tasks || {};
|
|
18
|
+
formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
|
|
19
19
|
|
|
20
20
|
if (currentPageId === (_models.FormPages.CYA || 'submitForm') && isCompleted) {
|
|
21
21
|
formStatus.tasks[currentTask.name].complete = true;
|
|
22
22
|
} else if ((action === null || action === void 0 ? void 0 : action.type) === _models.PageAction.TYPES.SAVE_AND_NAVIGATE) {
|
|
23
|
-
console.log('pg action sc');
|
|
24
23
|
formStatus.tasks[currentTask.name] = {
|
|
25
24
|
complete: false,
|
|
26
25
|
currentPage: (0, _getNextPageId.default)(formType, pages, currentPageId, action, formData)
|
|
27
26
|
};
|
|
28
27
|
} else {
|
|
29
|
-
console.log('got to else stmt');
|
|
30
28
|
formStatus.tasks[currentTask.name] = {
|
|
31
|
-
complete:
|
|
29
|
+
complete: !!(action !== null && action !== void 0 && action.complete),
|
|
32
30
|
currentPage: currentPageId
|
|
33
31
|
};
|
|
34
32
|
}
|
|
@@ -240,6 +240,21 @@ describe('components', function () {
|
|
|
240
240
|
})
|
|
241
241
|
});
|
|
242
242
|
});
|
|
243
|
+
it("should mark the current task as complete if the action indicates as much", function () {
|
|
244
|
+
var CURRENT_PAGE_ID = PAGES[0].id;
|
|
245
|
+
var TASK_NAME = 'taskName';
|
|
246
|
+
var CURRENT_TASK = {
|
|
247
|
+
name: TASK_NAME
|
|
248
|
+
};
|
|
249
|
+
var ACTION = {
|
|
250
|
+
complete: true
|
|
251
|
+
};
|
|
252
|
+
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true)).toMatchObject({
|
|
253
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
254
|
+
complete: true
|
|
255
|
+
})
|
|
256
|
+
});
|
|
257
|
+
});
|
|
243
258
|
});
|
|
244
259
|
});
|
|
245
260
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"post-compile": "rimraf dist/*.test.* dist/**/*.test.* dist/**/*.stories.* dist/docs dist/assets"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ukhomeoffice/cop-react-components": "1.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "1.12.0",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^3.13.0",
|