@ukhomeoffice/cop-react-form-renderer 3.16.0 → 3.17.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.
@@ -437,7 +437,7 @@ FormRenderer.propTypes = InternalFormRenderer.propTypes = {
437
437
  title: _propTypes.default.string,
438
438
 
439
439
  /** See <a href="/?path=/docs/f-json--page#formtypes">FormTypes</a>. */
440
- type: _propTypes.default.oneOf([_models.FormTypes.CYA, _models.FormTypes.FORM, _models.FormTypes.HUB, _models.FormTypes.TASK, _models.FormTypes.WIZARD, _models.FormTypes.TASKCYA]).isRequired,
440
+ type: _propTypes.default.oneOf([_models.FormTypes.CYA, _models.FormTypes.FORM, _models.FormTypes.HUB, _models.FormTypes.TASK, _models.FormTypes.WIZARD, _models.FormTypes.TASK_CYA, _models.FormTypes.FORM_WITH_TASK]).isRequired,
441
441
  components: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
442
442
  pages: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
443
443
  hub: _propTypes.default.object,
@@ -12,7 +12,7 @@ var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
14
  var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentPageId, action, formData, currentTask, isCompleted) {
15
- if (formType === _models.FormTypes.TASK) {
15
+ if (formType === _models.FormTypes.TASK || formType === _models.FormTypes.FORM_WITH_TASK) {
16
16
  var formStatus = formData.formStatus || {};
17
17
  formStatus.tasks = formStatus.tasks || {};
18
18
  formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
@@ -103,7 +103,7 @@ describe('components', function () {
103
103
  });
104
104
  describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), function () {
105
105
  Object.values(_models.FormTypes).forEach(function (formType) {
106
- if (formType !== _models.FormTypes.TASK) {
106
+ if (formType !== _models.FormTypes.TASK && formType !== _models.FormTypes.FORM_WITH_TASK) {
107
107
  it("should return the current page if the form type is '".concat(formType, "'"), function () {
108
108
  var ACTION = _models.PageAction.DEFAULTS.saveAndReturn;
109
109
  expect((0, _getSubmissionStatus.default)(formType, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
@@ -81,7 +81,7 @@ Task.propTypes = {
81
81
  task: _propTypes.default.shape({
82
82
  name: _propTypes.default.string.isRequired,
83
83
  pages: _propTypes.default.array.isRequired,
84
- state: _propTypes.default.string.isRequired
84
+ state: _propTypes.default.string
85
85
  }).isRequired,
86
86
  onClick: _propTypes.default.func.isRequired
87
87
  };
@@ -100,7 +100,7 @@ TaskList.propTypes = {
100
100
  tasks: _propTypes.default.arrayOf(_propTypes.default.shape({
101
101
  name: _propTypes.default.string.isRequired,
102
102
  pages: _propTypes.default.array.isRequired,
103
- state: _propTypes.default.string.isRequired
103
+ state: _propTypes.default.string
104
104
  })).isRequired
105
105
  })).isRequired,
106
106
  classBlock: _propTypes.default.string,
@@ -25,18 +25,18 @@ var TaskState = function TaskState(_ref) {
25
25
 
26
26
  var classes = _copReactComponents.Utils.classBuilder(DEFAULT_CLASS, undefined, undefined);
27
27
 
28
- if (!_models.TaskStates.DETAILS[state]) {
29
- return null;
30
- }
31
-
28
+ var details = _models.TaskStates.DETAILS[state] || _models.TaskStates.DETAILS.cannotStartYet;
32
29
  return /*#__PURE__*/_react.default.createElement(_copReactComponents.Tag, {
33
- classModifiers: [_models.TaskStates.DETAILS[state].colour],
30
+ classModifiers: details.colour,
34
31
  className: classes('tag')
35
- }, _models.TaskStates.DETAILS[state].label);
32
+ }, details.label);
36
33
  };
37
34
 
38
35
  TaskState.propTypes = {
39
- state: _propTypes.default.string.isRequired
36
+ state: _propTypes.default.string
37
+ };
38
+ TaskState.defaultProps = {
39
+ state: _models.TaskStates.TYPES.CANNOT_START_YET
40
40
  };
41
41
  var _default = TaskState;
42
42
  exports.default = _default;
@@ -14,6 +14,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  // Local imports
15
15
  describe('components', function () {
16
16
  describe('TaskList.TaskState', function () {
17
+ var checkIsCannotStartYet = function checkIsCannotStartYet(container) {
18
+ expect(container.childNodes.length).toEqual(1);
19
+ expect(container.childNodes[0].classList).toContain('hods-tag');
20
+ expect(container.childNodes[0].classList).toContain("hods-tag--".concat(_models.TaskStates.DETAILS.cannotStartYet.colour));
21
+ expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.cannotStartYet.label);
22
+ return true;
23
+ };
24
+
17
25
  it('should render a complete state icon', function () {
18
26
  var STATE = _models.TaskStates.TYPES.COMPLETE;
19
27
 
@@ -60,12 +68,9 @@ describe('components', function () {
60
68
  })),
61
69
  container = _render4.container;
62
70
 
63
- expect(container.childNodes.length).toEqual(1);
64
- expect(container.childNodes[0].classList).toContain('hods-tag');
65
- expect(container.childNodes[0].classList).toContain("hods-tag--".concat(_models.TaskStates.DETAILS.cannotStartYet.colour));
66
- expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.cannotStartYet.label);
71
+ expect(checkIsCannotStartYet(container)).toBeTruthy();
67
72
  });
68
- it('should not render a state if given an unknown value', function () {
73
+ it('should render the "Cannot start yet" state if given an unknown value', function () {
69
74
  var STATE = 'spellingError';
70
75
 
71
76
  var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
@@ -73,9 +78,9 @@ describe('components', function () {
73
78
  })),
74
79
  container = _render5.container;
75
80
 
76
- expect(container.childNodes.length).toEqual(0);
81
+ expect(checkIsCannotStartYet(container)).toBeTruthy();
77
82
  });
78
- it('should not render a state if given null', function () {
83
+ it('should render the "Cannot start yet" state if given null', function () {
79
84
  var STATE = null;
80
85
 
81
86
  var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
@@ -83,9 +88,9 @@ describe('components', function () {
83
88
  })),
84
89
  container = _render6.container;
85
90
 
86
- expect(container.childNodes.length).toEqual(0);
91
+ expect(checkIsCannotStartYet(container)).toBeTruthy();
87
92
  });
88
- it('should not render a state if given undefined', function () {
93
+ it('should render the "Cannot start yet" state if given undefined', function () {
89
94
  var STATE = undefined;
90
95
 
91
96
  var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
@@ -93,7 +98,7 @@ describe('components', function () {
93
98
  })),
94
99
  container = _render7.container;
95
100
 
96
- expect(container.childNodes.length).toEqual(0);
101
+ expect(checkIsCannotStartYet(container)).toBeTruthy();
97
102
  });
98
103
  });
99
104
  });
@@ -4,19 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var TYPE_FORM = 'form';
8
7
  var TYPE_CHECK_YOUR_ANSWERS = 'cya';
8
+ var TYPE_FORM = 'form';
9
+ var TYPE_FORM_WITH_TASK_LIST = 'form-with-task-list';
9
10
  var TYPE_HUB_AND_SPOKE = 'hub-and-spoke';
10
11
  var TYPE_TASK_LIST = 'task-list';
11
- var TYPE_WIZARD = 'wizard';
12
12
  var TYPE_TASK_LIST_CYA = 'task-list-cya';
13
+ var TYPE_WIZARD = 'wizard';
13
14
  var FormTypes = {
14
- FORM: TYPE_FORM,
15
15
  CYA: TYPE_CHECK_YOUR_ANSWERS,
16
+ FORM: TYPE_FORM,
17
+ FORM_WITH_TASK: TYPE_FORM_WITH_TASK_LIST,
16
18
  HUB: TYPE_HUB_AND_SPOKE,
17
19
  TASK: TYPE_TASK_LIST,
18
- WIZARD: TYPE_WIZARD,
19
- TASKCYA: TYPE_TASK_LIST_CYA
20
+ TASK_CYA: TYPE_TASK_LIST_CYA,
21
+ WIZARD: TYPE_WIZARD
20
22
  };
21
23
  var _default = FormTypes;
22
24
  exports.default = _default;
@@ -37,7 +37,7 @@ var getFormHub = function getFormHub(type, hub, components, formData) {
37
37
  }
38
38
  }
39
39
 
40
- if (type === _models.FormTypes.TASK) {
40
+ if (type === _models.FormTypes.TASK || type === _models.FormTypes.FORM_WITH_TASK) {
41
41
  return _models.HubFormats.TASK;
42
42
  }
43
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "3.16.0",
3
+ "version": "3.17.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",