@ukhomeoffice/cop-react-form-renderer 5.81.2 → 5.83.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.
@@ -165,7 +165,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
165
165
  });
166
166
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
167
167
  key: taskIndex
168
- }, /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, filterPages.length > 0 && task.displayName || task.name), filterPages.map(function (page, pageIndex) {
168
+ }, /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, filterPages.length > 0 && (task.displayName || task.name)), filterPages.map(function (page, pageIndex) {
169
169
  var hideActionButtons = isGroup(page.id) || noChangeAction;
170
170
  var showHeading = !hide_page_titles && page.title && !isGroup(page.id);
171
171
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
@@ -527,23 +527,37 @@ describe('components', function () {
527
527
  }
528
528
  }, _callee20);
529
529
  })));
530
- it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
531
- var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
530
+ it('should show task list in CYA style and not show sections without any pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
531
+ var sections, taskHeading1, taskHeading2;
532
532
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
533
533
  while (1) switch (_context22.prev = _context22.next) {
534
534
  case 0:
535
- ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
536
- GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
537
- _context22.next = 4;
535
+ sections = [{
536
+ name: 'These are your tasks',
537
+ tasks: [{
538
+ name: 'Task 1',
539
+ displayName: 'Blue',
540
+ state: 'complete',
541
+ pages: []
542
+ }, {
543
+ name: 'Task 2',
544
+ displayName: 'Red',
545
+ state: 'complete',
546
+ pages: ['grade']
547
+ }]
548
+ }];
549
+ _context22.next = 3;
538
550
  return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
539
551
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
540
552
  while (1) switch (_context21.prev = _context21.next) {
541
553
  case 0:
542
554
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
543
- pages: GROUP_PAGES,
555
+ pages: PAGES,
544
556
  onRowAction: ON_ROW_ACTION,
545
557
  onAction: ON_ACTION,
546
- hide_title: true
558
+ hide_title: true,
559
+ sections: sections,
560
+ type: "task-list-cya"
547
561
  }), container);
548
562
  case 1:
549
563
  case "end":
@@ -551,6 +565,41 @@ describe('components', function () {
551
565
  }
552
566
  }, _callee21);
553
567
  })));
568
+ case 3:
569
+ taskHeading1 = container.childNodes[0].childNodes[0];
570
+ expect(taskHeading1.textContent).toEqual('');
571
+ taskHeading2 = container.childNodes[0].childNodes[1];
572
+ expect(taskHeading2.textContent).toEqual('Red');
573
+ case 7:
574
+ case "end":
575
+ return _context22.stop();
576
+ }
577
+ }, _callee22);
578
+ })));
579
+ it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
580
+ var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
581
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
582
+ while (1) switch (_context24.prev = _context24.next) {
583
+ case 0:
584
+ ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
585
+ GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
586
+ _context24.next = 4;
587
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
588
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
589
+ while (1) switch (_context23.prev = _context23.next) {
590
+ case 0:
591
+ (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
592
+ pages: GROUP_PAGES,
593
+ onRowAction: ON_ROW_ACTION,
594
+ onAction: ON_ACTION,
595
+ hide_title: true
596
+ }), container);
597
+ case 1:
598
+ case "end":
599
+ return _context23.stop();
600
+ }
601
+ }, _callee23);
602
+ })));
554
603
  case 4:
555
604
  cya = checkCYA(container);
556
605
  groupedComponent = cya.childNodes[10];
@@ -571,20 +620,20 @@ describe('components', function () {
571
620
  expect(changeButton.textContent).toEqual('Change address details');
572
621
  case 21:
573
622
  case "end":
574
- return _context22.stop();
623
+ return _context24.stop();
575
624
  }
576
- }, _callee22);
625
+ }, _callee24);
577
626
  })));
578
- it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
627
+ it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
579
628
  var GROUP_PAGES, cya, namesGroup, firstNameRow, surname, changeButtonDiv, changeButton;
580
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
581
- while (1) switch (_context24.prev = _context24.next) {
629
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
630
+ while (1) switch (_context26.prev = _context26.next) {
582
631
  case 0:
583
632
  GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
584
- _context24.next = 3;
585
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
586
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
587
- while (1) switch (_context23.prev = _context23.next) {
633
+ _context26.next = 3;
634
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
635
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
636
+ while (1) switch (_context25.prev = _context25.next) {
588
637
  case 0:
589
638
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
590
639
  pages: GROUP_PAGES,
@@ -594,9 +643,9 @@ describe('components', function () {
594
643
  }), container);
595
644
  case 1:
596
645
  case "end":
597
- return _context23.stop();
646
+ return _context25.stop();
598
647
  }
599
- }, _callee23);
648
+ }, _callee25);
600
649
  })));
601
650
  case 3:
602
651
  cya = checkCYA(container);
@@ -620,14 +669,14 @@ describe('components', function () {
620
669
  expect(changeButton.textContent).toEqual('Change names');
621
670
  case 22:
622
671
  case "end":
623
- return _context24.stop();
672
+ return _context26.stop();
624
673
  }
625
- }, _callee24);
674
+ }, _callee26);
626
675
  })));
627
- it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
676
+ it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
628
677
  var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes7, cyaTitle, cyaChildNode, names, _names$childNodes3, firstName, surname, _firstName$childNodes, label;
629
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
630
- while (1) switch (_context26.prev = _context26.next) {
678
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
679
+ while (1) switch (_context28.prev = _context28.next) {
631
680
  case 0:
632
681
  _PAGES = [].concat(_userProfile.default.pages); // eslint-disable-next-line no-template-curly-in-string
633
682
  _PAGES[0] = _objectSpread(_objectSpread({}, _PAGES[0]), {}, {
@@ -641,10 +690,10 @@ describe('components', function () {
641
690
  cya_label: "Text ${currentUser.familyName}"
642
691
  });
643
692
  T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, DATA);
644
- _context26.next = 7;
645
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
646
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
647
- while (1) switch (_context25.prev = _context25.next) {
693
+ _context28.next = 7;
694
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
695
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
696
+ while (1) switch (_context27.prev = _context27.next) {
648
697
  case 0:
649
698
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
650
699
  pages: T_PAGES,
@@ -653,9 +702,9 @@ describe('components', function () {
653
702
  }), container);
654
703
  case 1:
655
704
  case "end":
656
- return _context25.stop();
705
+ return _context27.stop();
657
706
  }
658
- }, _callee25);
707
+ }, _callee27);
659
708
  })));
660
709
  case 7:
661
710
  cya = checkCYA(container);
@@ -670,14 +719,14 @@ describe('components', function () {
670
719
  checkRow(surname, 'Last name', 'Smith', false);
671
720
  case 17:
672
721
  case "end":
673
- return _context26.stop();
722
+ return _context28.stop();
674
723
  }
675
- }, _callee26);
724
+ }, _callee28);
676
725
  })));
677
- it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
726
+ it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
678
727
  var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes8, cyaChildNode, names, _names$childNodes4, firstName, surname, _firstName$childNodes2, label;
679
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
680
- while (1) switch (_context28.prev = _context28.next) {
728
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
729
+ while (1) switch (_context30.prev = _context30.next) {
681
730
  case 0:
682
731
  _PAGES = [].concat(_userProfile.default.pages);
683
732
  _COMPONENTS = [].concat(_userProfile.default.components);
@@ -687,10 +736,10 @@ describe('components', function () {
687
736
  cya_label: undefined
688
737
  });
689
738
  T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, _objectSpread({}, DATA));
690
- _context28.next = 6;
691
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
692
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
693
- while (1) switch (_context27.prev = _context27.next) {
739
+ _context30.next = 6;
740
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
741
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
742
+ while (1) switch (_context29.prev = _context29.next) {
694
743
  case 0:
695
744
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
696
745
  pages: T_PAGES,
@@ -699,9 +748,9 @@ describe('components', function () {
699
748
  }), container);
700
749
  case 1:
701
750
  case "end":
702
- return _context27.stop();
751
+ return _context29.stop();
703
752
  }
704
- }, _callee27);
753
+ }, _callee29);
705
754
  })));
706
755
  case 6:
707
756
  cya = checkCYA(container);
@@ -715,14 +764,14 @@ describe('components', function () {
715
764
  checkRow(surname, 'Last name', 'Smith', false);
716
765
  case 15:
717
766
  case "end":
718
- return _context28.stop();
767
+ return _context30.stop();
719
768
  }
720
- }, _callee28);
769
+ }, _callee30);
721
770
  })));
722
- it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
771
+ it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
723
772
  var sections, taskHeading1, namesPageHeading;
724
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
725
- while (1) switch (_context30.prev = _context30.next) {
773
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
774
+ while (1) switch (_context32.prev = _context32.next) {
726
775
  case 0:
727
776
  sections = [{
728
777
  name: 'These are your tasks',
@@ -736,10 +785,10 @@ describe('components', function () {
736
785
  pages: ['grade']
737
786
  }]
738
787
  }];
739
- _context30.next = 3;
740
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
741
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
742
- while (1) switch (_context29.prev = _context29.next) {
788
+ _context32.next = 3;
789
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
790
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
791
+ while (1) switch (_context31.prev = _context31.next) {
743
792
  case 0:
744
793
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
745
794
  pages: PAGES,
@@ -751,9 +800,9 @@ describe('components', function () {
751
800
  }), container);
752
801
  case 1:
753
802
  case "end":
754
- return _context29.stop();
803
+ return _context31.stop();
755
804
  }
756
- }, _callee29);
805
+ }, _callee31);
757
806
  })));
758
807
  case 3:
759
808
  taskHeading1 = container.childNodes[0].childNodes[0];
@@ -767,21 +816,21 @@ describe('components', function () {
767
816
  expect(container.childNodes[0].childNodes.length).toEqual(2); // second task skipped so not shown
768
817
  case 12:
769
818
  case "end":
770
- return _context30.stop();
819
+ return _context32.stop();
771
820
  }
772
- }, _callee30);
821
+ }, _callee32);
773
822
  })));
774
- it('Show answers from multiple address fields into in one DL correctly when hideBlankRows is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
823
+ it('Show answers from multiple address fields into in one DL correctly when hideBlankRows is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
775
824
  var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
776
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
777
- while (1) switch (_context32.prev = _context32.next) {
825
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
826
+ while (1) switch (_context34.prev = _context34.next) {
778
827
  case 0:
779
828
  ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
780
829
  GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
781
- _context32.next = 4;
782
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
783
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
784
- while (1) switch (_context31.prev = _context31.next) {
830
+ _context34.next = 4;
831
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
832
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
833
+ while (1) switch (_context33.prev = _context33.next) {
785
834
  case 0:
786
835
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
787
836
  pages: GROUP_PAGES,
@@ -792,9 +841,9 @@ describe('components', function () {
792
841
  }), container);
793
842
  case 1:
794
843
  case "end":
795
- return _context31.stop();
844
+ return _context33.stop();
796
845
  }
797
- }, _callee31);
846
+ }, _callee33);
798
847
  })));
799
848
  case 4:
800
849
  cya = checkCYA(container);
@@ -816,9 +865,9 @@ describe('components', function () {
816
865
  expect(changeButton.textContent).toEqual('Change address details');
817
866
  case 21:
818
867
  case "end":
819
- return _context32.stop();
868
+ return _context34.stop();
820
869
  }
821
- }, _callee32);
870
+ }, _callee34);
822
871
  })));
823
872
  });
824
873
  });
@@ -352,6 +352,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
352
352
  onTaskAction: function onTaskAction(task) {
353
353
  (0, _onTaskAction2.default)(task, pages, setCurrentTask, hubDetails, data, onPageChange);
354
354
  },
355
+ annotations: (hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.taskListAnnotations) || [],
355
356
  formData: data
356
357
  })), formState.page && !formState.cya && !formState.page.collection && /*#__PURE__*/_react.default.createElement(_FormPage.default, {
357
358
  page: formState.page,
@@ -12,7 +12,7 @@ var _models = require("../../models");
12
12
  var _Task = _interopRequireDefault(require("./Task"));
13
13
  var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
14
14
  require("./TaskList.scss");
15
- var _excluded = ["id", "refTitle", "refNumber", "notes", "incompleteTitle", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className", "formData"];
15
+ var _excluded = ["id", "refTitle", "refNumber", "notes", "incompleteTitle", "showCompletionOverview", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className", "formData", "annotations"];
16
16
  /* eslint-disable import/no-duplicates */
17
17
  // Global Imports
18
18
  // Local Imports
@@ -36,6 +36,7 @@ var TaskList = function TaskList(_ref) {
36
36
  refNumber = _ref.refNumber,
37
37
  notes = _ref.notes,
38
38
  incompleteTitle = _ref.incompleteTitle,
39
+ showCompletionOverview = _ref.showCompletionOverview,
39
40
  sections = _ref.sections,
40
41
  fieldId = _ref.fieldId,
41
42
  onTaskAction = _ref.onTaskAction,
@@ -43,6 +44,7 @@ var TaskList = function TaskList(_ref) {
43
44
  classModifiers = _ref.classModifiers,
44
45
  className = _ref.className,
45
46
  formData = _ref.formData,
47
+ annotations = _ref.annotations,
46
48
  attrs = _objectWithoutProperties(_ref, _excluded);
47
49
  var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
48
50
  var cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
@@ -78,11 +80,19 @@ var TaskList = function TaskList(_ref) {
78
80
  className: "tasklist-summary"
79
81
  }, "".concat(refTitle))), /*#__PURE__*/_react.default.createElement("p", {
80
82
  className: "govuk-body govuk-!-font-weight-regular"
81
- }, "".concat(refNumber))), totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
83
+ }, "".concat(refNumber))), annotations.length > 0 && annotations.map(function (annotation) {
84
+ return /*#__PURE__*/_react.default.createElement("div", {
85
+ className: classes('annotation')
86
+ }, /*#__PURE__*/_react.default.createElement("p", {
87
+ className: "".concat(classes('annotation-key'), " govuk-body")
88
+ }, _copReactComponents.Utils.interpolateString(annotation.key, formData)), /*#__PURE__*/_react.default.createElement("p", {
89
+ className: "".concat(classes('annotation-value'), " govuk-body")
90
+ }, _copReactComponents.Utils.interpolateString(annotation.value, formData)));
91
+ }), showCompletionOverview && totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
82
92
  className: "govuk-body govuk-!-margin-bottom-0"
83
93
  }, /*#__PURE__*/_react.default.createElement("strong", {
84
94
  className: "tasklist-summary"
85
- }, incompleteTitle)), /*#__PURE__*/_react.default.createElement("p", {
95
+ }, incompleteTitle)), showCompletionOverview && /*#__PURE__*/_react.default.createElement("p", {
86
96
  className: "govuk-body govuk-!-margin-bottom-7"
87
97
  }, "You have completed ".concat(completeSections, " of ").concat(totalSections, " sections")), notesTitle && notesText && (0, _showComponent.default)(notes, formData) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
88
98
  className: "govuk-body govuk-!-margin-bottom-0"
@@ -121,6 +131,7 @@ TaskList.propTypes = {
121
131
  formData: _propTypes.default.shape({}),
122
132
  id: _propTypes.default.string,
123
133
  incompleteTitle: _propTypes.default.string,
134
+ showCompletionOverview: _propTypes.default.bool,
124
135
  notes: _propTypes.default.shape({
125
136
  title: _propTypes.default.string,
126
137
  text: _propTypes.default.string
@@ -139,7 +150,11 @@ TaskList.propTypes = {
139
150
  firstPage: _propTypes.default.string,
140
151
  alwaysShowFirstPage: _propTypes.default.bool
141
152
  })).isRequired
142
- })).isRequired
153
+ })).isRequired,
154
+ annotations: _propTypes.default.arrayOf(_propTypes.default.shape({
155
+ key: _propTypes.default.string,
156
+ value: _propTypes.default.string
157
+ }))
143
158
  };
144
159
  TaskList.defaultProps = {
145
160
  classBlock: DEFAULT_CLASS,
@@ -149,9 +164,11 @@ TaskList.defaultProps = {
149
164
  formData: {},
150
165
  id: '',
151
166
  incompleteTitle: DEFAULT_INCOMPLETE_TITLE,
167
+ showCompletionOverview: true,
152
168
  notes: {},
153
169
  onTaskAction: undefined,
154
170
  refNumber: undefined,
155
- refTitle: undefined
171
+ refTitle: undefined,
172
+ annotations: []
156
173
  };
157
174
  var _default = exports.default = TaskList;
@@ -58,6 +58,26 @@
58
58
  }
59
59
  }
60
60
 
61
+ .hods-task-list__annotation {
62
+ display: flex;
63
+ flex-flow: row wrap;
64
+ margin-bottom: govuk-spacing(2);
65
+
66
+ .hods-task-list__annotation-key {
67
+ font-weight: bold;
68
+ margin-top: 0;
69
+ margin-bottom: 0;
70
+ margin-right: govuk-spacing(1)
71
+ }
72
+
73
+ .hods-task-list__annotation-value {
74
+ font-weight: normal;
75
+ margin-top: 0;
76
+ margin-bottom: 0;
77
+ }
78
+
79
+ }
80
+
61
81
  .hods-task-list__task-name {
62
82
  display: block;
63
83
  cursor: auto;
@@ -101,6 +101,150 @@ describe('components', function () {
101
101
  expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
102
102
  expect(subSectionTwoList.childNodes.length).toEqual(3);
103
103
  });
104
+ it('should not render the incomplete title and message when showCompletionOverview is false', function () {
105
+ var COP_REF = '123';
106
+ var REF_TITLE = 'COP reference number';
107
+ var sections = [{
108
+ name: 'These are your tasks',
109
+ label: 'This is the label for your first tasks',
110
+ tasks: [{
111
+ name: 'Nice task',
112
+ state: 'complete',
113
+ pages: ['pageOne']
114
+ }, {
115
+ name: 'Ok task',
116
+ state: 'inProgress',
117
+ pages: ['pageTwo']
118
+ }, {
119
+ name: 'Terrible task',
120
+ state: 'notStarted',
121
+ pages: ['pageThree']
122
+ }]
123
+ }, {
124
+ name: 'These are your extra bonus tasks',
125
+ label: 'This is the label for your extra tasks',
126
+ tasks: [{
127
+ name: 'Nice task',
128
+ state: 'complete',
129
+ pages: ['pageFour']
130
+ }, {
131
+ name: 'Ok task',
132
+ state: 'cannotStartYet',
133
+ pages: ['pageFive']
134
+ }, {
135
+ name: 'Terrible task',
136
+ state: 'cannotStartYet',
137
+ pages: ['pageSix']
138
+ }]
139
+ }];
140
+ var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
141
+ refNumber: COP_REF,
142
+ refTitle: REF_TITLE,
143
+ sections: sections,
144
+ showCompletionOverview: false
145
+ })),
146
+ container = _render2.container;
147
+ var childNodes = container.childNodes;
148
+ expect(childNodes.length).toEqual(1);
149
+ expect(childNodes[0].childNodes.length).toEqual(8); // Without incomplete heading and message.
150
+
151
+ var _childNodes$0$childNo2 = _slicedToArray(childNodes[0].childNodes, 8),
152
+ referenceHeading = _childNodes$0$childNo2[0],
153
+ referenceNumber = _childNodes$0$childNo2[1],
154
+ subSectionOneHeading = _childNodes$0$childNo2[2],
155
+ subSectionOneLabel = _childNodes$0$childNo2[3],
156
+ subSectionOneList = _childNodes$0$childNo2[4],
157
+ subSectionTwoHeading = _childNodes$0$childNo2[5],
158
+ subSectionTwoLabel = _childNodes$0$childNo2[6],
159
+ subSectionTwoList = _childNodes$0$childNo2[7];
160
+ expect(referenceHeading).toMatchObject({
161
+ tagName: 'P',
162
+ textContent: 'COP reference number'
163
+ });
164
+ expect(referenceNumber).toMatchObject({
165
+ tagName: 'P',
166
+ textContent: '123'
167
+ });
168
+ expect(subSectionOneHeading).toMatchObject({
169
+ tagName: 'H2',
170
+ textContent: '1. These are your tasks'
171
+ });
172
+ expect(subSectionOneLabel.textContent).toEqual('This is the label for your first tasks');
173
+ expect(subSectionOneList.childNodes.length).toEqual(3);
174
+ expect(subSectionTwoHeading).toMatchObject({
175
+ tagName: 'H2',
176
+ textContent: '2. These are your extra bonus tasks'
177
+ });
178
+ expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
179
+ expect(subSectionTwoList.childNodes.length).toEqual(3);
180
+ });
181
+ it('should render any provided annotations', function () {
182
+ var COP_REF = '123';
183
+ var REF_TITLE = 'COP reference number';
184
+ var sections = [{
185
+ name: 'These are your tasks',
186
+ label: 'This is the label for your first tasks',
187
+ tasks: [{
188
+ name: 'Nice task',
189
+ state: 'complete',
190
+ pages: ['pageOne']
191
+ }, {
192
+ name: 'Ok task',
193
+ state: 'inProgress',
194
+ pages: ['pageTwo']
195
+ }, {
196
+ name: 'Terrible task',
197
+ state: 'notStarted',
198
+ pages: ['pageThree']
199
+ }]
200
+ }, {
201
+ name: 'These are your extra bonus tasks',
202
+ label: 'This is the label for your extra tasks',
203
+ tasks: [{
204
+ name: 'Nice task',
205
+ state: 'complete',
206
+ pages: ['pageFour']
207
+ }, {
208
+ name: 'Ok task',
209
+ state: 'cannotStartYet',
210
+ pages: ['pageFive']
211
+ }, {
212
+ name: 'Terrible task',
213
+ state: 'cannotStartYet',
214
+ pages: ['pageSix']
215
+ }]
216
+ }];
217
+ var FORM_DATA = {
218
+ port: {
219
+ name: 'Heathrow Airport'
220
+ }
221
+ };
222
+ var ANNOTATIONS = [{
223
+ key: 'Port',
224
+ // eslint-disable-next-line no-template-curly-in-string
225
+ value: '${port.name}'
226
+ }];
227
+ var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
228
+ refNumber: COP_REF,
229
+ refTitle: REF_TITLE,
230
+ sections: sections,
231
+ annotations: ANNOTATIONS,
232
+ formData: FORM_DATA
233
+ })),
234
+ container = _render3.container;
235
+ var childNodes = container.childNodes;
236
+ expect(childNodes.length).toEqual(1);
237
+ expect(childNodes[0].childNodes.length).toEqual(11);
238
+ var annotation = childNodes[0].childNodes[2];
239
+ expect(annotation.children[0]).toMatchObject({
240
+ tagName: 'P',
241
+ textContent: 'Port'
242
+ });
243
+ expect(annotation.childNodes[1]).toMatchObject({
244
+ tagName: 'P',
245
+ textContent: 'Heathrow Airport'
246
+ });
247
+ });
104
248
  it('should not show incomplete title if form is complete', function () {
105
249
  var COP_REF = '123';
106
250
  var REF_TITLE = 'COP reference number';
@@ -135,18 +279,18 @@ describe('components', function () {
135
279
  pages: ['pageSix']
136
280
  }]
137
281
  }];
138
- var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
282
+ var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
139
283
  refNumber: COP_REF,
140
284
  refTitle: REF_TITLE,
141
285
  sections: sections
142
286
  })),
143
- container = _render2.container;
287
+ container = _render4.container;
144
288
  var childNodes = container.childNodes;
145
289
  expect(childNodes[0].childNodes.length).toEqual(7);
146
- var _childNodes$0$childNo2 = _slicedToArray(childNodes[0].childNodes, 3),
147
- referenceHeading = _childNodes$0$childNo2[0],
148
- referenceNumber = _childNodes$0$childNo2[1],
149
- numComplete = _childNodes$0$childNo2[2];
290
+ var _childNodes$0$childNo3 = _slicedToArray(childNodes[0].childNodes, 3),
291
+ referenceHeading = _childNodes$0$childNo3[0],
292
+ referenceNumber = _childNodes$0$childNo3[1],
293
+ numComplete = _childNodes$0$childNo3[2];
150
294
  expect(referenceHeading).toMatchObject({
151
295
  tagName: 'P',
152
296
  textContent: 'COP reference number'
@@ -179,12 +323,12 @@ describe('components', function () {
179
323
  pages: ['pageThree']
180
324
  }]
181
325
  }];
182
- var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
326
+ var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
183
327
  refNumber: COP_REF,
184
328
  refTitle: REF_TITLE,
185
329
  sections: sections
186
330
  })),
187
- container = _render3.container;
331
+ container = _render5.container;
188
332
  var childNodes = container.childNodes;
189
333
  var subSectionOne = childNodes[0].childNodes[4];
190
334
  expect(subSectionOne.childNodes[0].textContent).toEqual('');
@@ -223,11 +367,11 @@ describe('components', function () {
223
367
  pages: ['pageSix']
224
368
  }]
225
369
  }];
226
- var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
370
+ var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
227
371
  refNumber: COP_REF,
228
372
  sections: sections
229
373
  })),
230
- container = _render4.container;
374
+ container = _render6.container;
231
375
  var childNodes = container.childNodes;
232
376
  expect(childNodes.length).toEqual(1);
233
377
  expect(childNodes[0].childNodes.length).toEqual(6);
@@ -273,12 +417,12 @@ describe('components', function () {
273
417
  pages: ['pageSix']
274
418
  }]
275
419
  }];
276
- var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
420
+ var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
277
421
  refNumber: COP_REF,
278
422
  sections: sections,
279
423
  incompleteTitle: INCOMPLETE_TITLE
280
424
  })),
281
- container = _render5.container;
425
+ container = _render7.container;
282
426
  var childNodes = container.childNodes;
283
427
  // The first child is now the incomplete text.
284
428
  var incompleteForm = childNodes[0].childNodes[0];
@@ -319,12 +463,12 @@ describe('components', function () {
319
463
  pages: ['pageSix']
320
464
  }]
321
465
  }];
322
- var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
466
+ var _render8 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
323
467
  refNumber: COP_REF,
324
468
  sections: sections,
325
469
  incompleteTitle: INCOMPLETE_TITLE
326
470
  })),
327
- container = _render6.container;
471
+ container = _render8.container;
328
472
  var childNodes = container.childNodes;
329
473
  expect(childNodes.length).toEqual(1);
330
474
  var children = childNodes[0].childNodes;
@@ -357,13 +501,13 @@ describe('components', function () {
357
501
  pages: ['pageThree']
358
502
  }]
359
503
  }];
360
- var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
504
+ var _render9 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
361
505
  refNumber: COP_REF,
362
506
  refTitle: REF_TITLE,
363
507
  sections: sections,
364
508
  onTaskAction: ON_CLICK
365
509
  })),
366
- container = _render7.container;
510
+ container = _render9.container;
367
511
  var taskList = container.childNodes[0].childNodes[5].childNodes;
368
512
  var firstTask = taskList[0].childNodes[0].childNodes[0];
369
513
  var secondTask = taskList[1].childNodes[0].childNodes[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.81.2",
3
+ "version": "5.83.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",