@ukhomeoffice/cop-react-form-renderer 4.51.1 → 4.53.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.
@@ -103,7 +103,7 @@ var DEFAULT_CLASS = 'hods-form';
103
103
  exports.DEFAULT_CLASS = DEFAULT_CLASS;
104
104
 
105
105
  var InternalFormRenderer = function InternalFormRenderer(_ref2) {
106
- var _formState$page5;
106
+ var _formState$page5, _formState$page$actio;
107
107
 
108
108
  var title = _ref2.title,
109
109
  type = _ref2.type,
@@ -605,7 +605,9 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
605
605
  }, title && !hide_title && pageId === _models.FormPages.HUB && /*#__PURE__*/_react.default.createElement(_copReactComponents.LargeHeading, null, title), formState.cya && /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, _extends({
606
606
  pages: _helpers.default.getRelevantPages(formState, pages, currentTask.fullPages)
607
607
  }, cya, ((_formState$page5 = formState.page) === null || _formState$page5 === void 0 ? void 0 : _formState$page5.type) === _models.FormPages.PARTIAL_CYA && {
608
- actions: formState.page.actions
608
+ actions: (_formState$page$actio = formState.page.actions) === null || _formState$page$actio === void 0 ? void 0 : _formState$page$actio.filter(function (action) {
609
+ return _utils.default.Component.show(action, data);
610
+ })
609
611
  }, formState.cya, {
610
612
  onAction: onCYAAction,
611
613
  onRowAction: onCYARowAction,
@@ -592,7 +592,7 @@ describe('components', function () {
592
592
  }, _callee18);
593
593
  })));
594
594
  it('should load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
595
- var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList, notesText;
595
+ var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
596
596
  return regeneratorRuntime.wrap(function _callee20$(_context20) {
597
597
  while (1) {
598
598
  switch (_context20.prev = _context20.next) {
@@ -610,7 +610,12 @@ describe('components', function () {
610
610
  TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
611
611
  TASK_LIST_WITH_NOTES.hub.notes = {
612
612
  title: "test title",
613
- text: "test text"
613
+ text: "test text",
614
+ show_when: [{
615
+ "op": "=",
616
+ "field": "areYouACivilServant",
617
+ "value": "yes"
618
+ }]
614
619
  };
615
620
  _context20.next = 7;
616
621
  return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() {
@@ -619,6 +624,7 @@ describe('components', function () {
619
624
  switch (_context19.prev = _context19.next) {
620
625
  case 0:
621
626
  (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
627
+ data: _userProfileData.default,
622
628
  hooks: HOOKS
623
629
  })), container);
624
630
 
@@ -632,8 +638,8 @@ describe('components', function () {
632
638
 
633
639
  case 7:
634
640
  taskList = container.childNodes[0].childNodes[1];
635
- notesText = taskList.childNodes[3];
636
- expect(notesText.textContent).toEqual("test text");
641
+ expect(taskList.childNodes[5].textContent).toEqual("test text");
642
+ expect(taskList.childNodes[5].classList).toContain('govuk-textarea');
637
643
 
638
644
  case 10:
639
645
  case "end":
@@ -642,8 +648,8 @@ describe('components', function () {
642
648
  }
643
649
  }, _callee20);
644
650
  })));
645
- it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
646
- var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
651
+ it('should not load tasklist with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22() {
652
+ var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
647
653
  return regeneratorRuntime.wrap(function _callee22$(_context22) {
648
654
  while (1) {
649
655
  switch (_context22.prev = _context22.next) {
@@ -658,13 +664,24 @@ describe('components', function () {
658
664
  HOOKS = {
659
665
  onSubmit: ON_SUBMIT
660
666
  };
661
- _context22.next = 5;
667
+ TASK_LIST_WITH_NOTES = JSON.parse(JSON.stringify(_taskList.default));
668
+ TASK_LIST_WITH_NOTES.hub.notes = {
669
+ title: "test title",
670
+ text: "test text",
671
+ show_when: [{
672
+ "op": "!=",
673
+ "field": "changeSummary",
674
+ "value": undefined
675
+ }]
676
+ };
677
+ _context22.next = 7;
662
678
  return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21() {
663
679
  return regeneratorRuntime.wrap(function _callee21$(_context21) {
664
680
  while (1) {
665
681
  switch (_context21.prev = _context21.next) {
666
682
  case 0:
667
- (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
683
+ (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NOTES, {
684
+ data: _userProfileData.default,
668
685
  hooks: HOOKS
669
686
  })), container);
670
687
 
@@ -676,6 +693,55 @@ describe('components', function () {
676
693
  }, _callee21);
677
694
  })));
678
695
 
696
+ case 7:
697
+ taskList = container.childNodes[0].childNodes[1];
698
+ taskList.childNodes.forEach(function (child) {
699
+ console.log("taskList, child = ".concat(JSON.stringify(child.textContent)));
700
+ });
701
+ expect(taskList.childNodes[5].textContent).not.toEqual("test text");
702
+ expect(taskList.childNodes[5].classList).not.toContain('govuk-textarea');
703
+
704
+ case 11:
705
+ case "end":
706
+ return _context22.stop();
707
+ }
708
+ }
709
+ }, _callee22);
710
+ })));
711
+ it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24() {
712
+ var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
713
+ return regeneratorRuntime.wrap(function _callee24$(_context24) {
714
+ while (1) {
715
+ switch (_context24.prev = _context24.next) {
716
+ case 0:
717
+ ON_SUBMIT_CALLS = [];
718
+
719
+ ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
720
+ ON_SUBMIT_CALLS.push(payload);
721
+ onSuccess();
722
+ };
723
+
724
+ HOOKS = {
725
+ onSubmit: ON_SUBMIT
726
+ };
727
+ _context24.next = 5;
728
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23() {
729
+ return regeneratorRuntime.wrap(function _callee23$(_context23) {
730
+ while (1) {
731
+ switch (_context23.prev = _context23.next) {
732
+ case 0:
733
+ (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
734
+ hooks: HOOKS
735
+ })), container);
736
+
737
+ case 1:
738
+ case "end":
739
+ return _context23.stop();
740
+ }
741
+ }
742
+ }, _callee23);
743
+ })));
744
+
679
745
  case 5:
680
746
  taskList = container.childNodes[0].childNodes[1]; //Check statuses are correct
681
747
 
@@ -775,16 +841,16 @@ describe('components', function () {
775
841
 
776
842
  case 54:
777
843
  case "end":
778
- return _context22.stop();
844
+ return _context24.stop();
779
845
  }
780
846
  }
781
- }, _callee22);
847
+ }, _callee24);
782
848
  })));
783
- it('should go straight to CYA page if a complete task is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24() {
849
+ it('should go straight to CYA page if a complete task is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26() {
784
850
  var ON_SUBMIT, HOOKS, taskList, newPage;
785
- return regeneratorRuntime.wrap(function _callee24$(_context24) {
851
+ return regeneratorRuntime.wrap(function _callee26$(_context26) {
786
852
  while (1) {
787
- switch (_context24.prev = _context24.next) {
853
+ switch (_context26.prev = _context26.next) {
788
854
  case 0:
789
855
  ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
790
856
  onSuccess();
@@ -793,11 +859,11 @@ describe('components', function () {
793
859
  HOOKS = {
794
860
  onSubmit: ON_SUBMIT
795
861
  };
796
- _context24.next = 4;
797
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23() {
798
- return regeneratorRuntime.wrap(function _callee23$(_context23) {
862
+ _context26.next = 4;
863
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25() {
864
+ return regeneratorRuntime.wrap(function _callee25$(_context25) {
799
865
  while (1) {
800
- switch (_context23.prev = _context23.next) {
866
+ switch (_context25.prev = _context25.next) {
801
867
  case 0:
802
868
  (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _taskList.default, {
803
869
  hooks: HOOKS
@@ -805,10 +871,10 @@ describe('components', function () {
805
871
 
806
872
  case 1:
807
873
  case "end":
808
- return _context23.stop();
874
+ return _context25.stop();
809
875
  }
810
876
  }
811
- }, _callee23);
877
+ }, _callee25);
812
878
  })));
813
879
 
814
880
  case 4:
@@ -860,16 +926,16 @@ describe('components', function () {
860
926
 
861
927
  case 17:
862
928
  case "end":
863
- return _context24.stop();
929
+ return _context26.stop();
864
930
  }
865
931
  }
866
- }, _callee24);
932
+ }, _callee26);
867
933
  })));
868
- it('should go to the last page of a complete task if noTaskCYAs specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26() {
934
+ it('should go to the last page of a complete task if noTaskCYAs specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28() {
869
935
  var ON_SUBMIT, HOOKS, TASK_LIST_WITH_NO_TASK_CYAS, taskList, newPage;
870
- return regeneratorRuntime.wrap(function _callee26$(_context26) {
936
+ return regeneratorRuntime.wrap(function _callee28$(_context28) {
871
937
  while (1) {
872
- switch (_context26.prev = _context26.next) {
938
+ switch (_context28.prev = _context28.next) {
873
939
  case 0:
874
940
  ON_SUBMIT = function ON_SUBMIT(type, payload, onSuccess, onError) {
875
941
  onSuccess();
@@ -884,11 +950,11 @@ describe('components', function () {
884
950
  type: 'save',
885
951
  complete: true
886
952
  };
887
- _context26.next = 7;
888
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25() {
889
- return regeneratorRuntime.wrap(function _callee25$(_context25) {
953
+ _context28.next = 7;
954
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27() {
955
+ return regeneratorRuntime.wrap(function _callee27$(_context27) {
890
956
  while (1) {
891
- switch (_context25.prev = _context25.next) {
957
+ switch (_context27.prev = _context27.next) {
892
958
  case 0:
893
959
  (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_WITH_NO_TASK_CYAS, {
894
960
  hooks: HOOKS
@@ -896,10 +962,10 @@ describe('components', function () {
896
962
 
897
963
  case 1:
898
964
  case "end":
899
- return _context25.stop();
965
+ return _context27.stop();
900
966
  }
901
967
  }
902
- }, _callee25);
968
+ }, _callee27);
903
969
  })));
904
970
 
905
971
  case 7:
@@ -948,17 +1014,17 @@ describe('components', function () {
948
1014
 
949
1015
  case 19:
950
1016
  case "end":
951
- return _context26.stop();
1017
+ return _context28.stop();
952
1018
  }
953
1019
  }
954
- }, _callee26);
1020
+ }, _callee28);
955
1021
  })));
956
- it('should handle cancellation from a page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28() {
1022
+ it('should handle cancellation from a page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee30() {
957
1023
  var ON_CANCEL_CALLS, ON_CANCEL, HOOKS, form, hub, _hub$childNodes5, civilServantList, link, page, cancel;
958
1024
 
959
- return regeneratorRuntime.wrap(function _callee28$(_context28) {
1025
+ return regeneratorRuntime.wrap(function _callee30$(_context30) {
960
1026
  while (1) {
961
- switch (_context28.prev = _context28.next) {
1027
+ switch (_context30.prev = _context30.next) {
962
1028
  case 0:
963
1029
  ON_CANCEL_CALLS = [];
964
1030
 
@@ -969,11 +1035,11 @@ describe('components', function () {
969
1035
  HOOKS = {
970
1036
  onCancel: ON_CANCEL
971
1037
  };
972
- _context28.next = 5;
973
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27() {
974
- return regeneratorRuntime.wrap(function _callee27$(_context27) {
1038
+ _context30.next = 5;
1039
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29() {
1040
+ return regeneratorRuntime.wrap(function _callee29$(_context29) {
975
1041
  while (1) {
976
- switch (_context27.prev = _context27.next) {
1042
+ switch (_context29.prev = _context29.next) {
977
1043
  case 0:
978
1044
  (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, _userProfile.default, {
979
1045
  data: _userProfileData.default,
@@ -982,10 +1048,10 @@ describe('components', function () {
982
1048
 
983
1049
  case 1:
984
1050
  case "end":
985
- return _context27.stop();
1051
+ return _context29.stop();
986
1052
  }
987
1053
  }
988
- }, _callee27);
1054
+ }, _callee29);
989
1055
  })));
990
1056
 
991
1057
  case 5:
@@ -1009,16 +1075,16 @@ describe('components', function () {
1009
1075
 
1010
1076
  case 15:
1011
1077
  case "end":
1012
- return _context28.stop();
1078
+ return _context30.stop();
1013
1079
  }
1014
1080
  }
1015
- }, _callee28);
1081
+ }, _callee30);
1016
1082
  })));
1017
- it('should navigate to a specific page at the beginning of a task if it is set as the firstPage of a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee30() {
1083
+ it('should navigate to a specific page at the beginning of a task if it is set as the firstPage of a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee32() {
1018
1084
  var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_NON_SEQUENTIAL, taskList, firstTask, newPage;
1019
- return regeneratorRuntime.wrap(function _callee30$(_context30) {
1085
+ return regeneratorRuntime.wrap(function _callee32$(_context32) {
1020
1086
  while (1) {
1021
- switch (_context30.prev = _context30.next) {
1087
+ switch (_context32.prev = _context32.next) {
1022
1088
  case 0:
1023
1089
  ON_SUBMIT_CALLS = [];
1024
1090
 
@@ -1032,11 +1098,11 @@ describe('components', function () {
1032
1098
  };
1033
1099
  TASK_LIST_NON_SEQUENTIAL = JSON.parse(JSON.stringify(_taskList.default));
1034
1100
  TASK_LIST_NON_SEQUENTIAL.hub.nonSequential = true;
1035
- _context30.next = 7;
1036
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29() {
1037
- return regeneratorRuntime.wrap(function _callee29$(_context29) {
1101
+ _context32.next = 7;
1102
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee31() {
1103
+ return regeneratorRuntime.wrap(function _callee31$(_context31) {
1038
1104
  while (1) {
1039
- switch (_context29.prev = _context29.next) {
1105
+ switch (_context31.prev = _context31.next) {
1040
1106
  case 0:
1041
1107
  (0, _reactDom.render)( /*#__PURE__*/_react2.default.createElement(_FormRenderer.default, _extends({}, TASK_LIST_NON_SEQUENTIAL, {
1042
1108
  hooks: HOOKS
@@ -1044,10 +1110,10 @@ describe('components', function () {
1044
1110
 
1045
1111
  case 1:
1046
1112
  case "end":
1047
- return _context29.stop();
1113
+ return _context31.stop();
1048
1114
  }
1049
1115
  }
1050
- }, _callee29);
1116
+ }, _callee31);
1051
1117
  })));
1052
1118
 
1053
1119
  case 7:
@@ -1064,10 +1130,10 @@ describe('components', function () {
1064
1130
 
1065
1131
  case 13:
1066
1132
  case "end":
1067
- return _context30.stop();
1133
+ return _context32.stop();
1068
1134
  }
1069
1135
  }
1070
- }, _callee30);
1136
+ }, _callee32);
1071
1137
  })));
1072
1138
  });
1073
1139
  });
@@ -19,6 +19,8 @@ var _models = require("../../models");
19
19
 
20
20
  var _Task = _interopRequireDefault(require("./Task"));
21
21
 
22
+ var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
23
+
22
24
  require("./TaskList.scss");
23
25
 
24
26
  var _excluded = ["refTitle", "refNumber", "notes", "incompleteTitle", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className"];
@@ -105,7 +107,7 @@ var TaskList = function TaskList(_ref) {
105
107
  className: "tasklist-summary"
106
108
  }, incompleteTitle)), /*#__PURE__*/_react.default.createElement("p", {
107
109
  className: "govuk-body govuk-!-margin-bottom-7"
108
- }, "You have completed ".concat(completeSections, " of ").concat(totalSections, " sections")), notesTitle && notesText && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
110
+ }, "You have completed ".concat(completeSections, " of ").concat(totalSections, " sections")), notesTitle && notesText && (0, _showComponent.default)(notes, attrs.formData) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
109
111
  className: "govuk-body govuk-!-margin-bottom-0"
110
112
  }, /*#__PURE__*/_react.default.createElement("strong", {
111
113
  className: "tasklist-summary"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.51.1",
3
+ "version": "4.53.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",