@ukhomeoffice/cop-react-form-renderer 4.52.0 → 4.54.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.js +4 -0
- package/dist/components/FormRenderer/FormRenderer.js +3 -2
- package/dist/components/FormRenderer/FormRenderer.test.js +120 -54
- package/dist/components/FormRenderer/helpers/getCYA.js +9 -1
- package/dist/components/SummaryList/SummaryList.js +6 -3
- package/dist/components/SummaryList/SummaryList.test.js +94 -8
- package/dist/components/TaskList/TaskList.js +3 -1
- package/dist/utils/FormPage/applyConditionalProperties.js +42 -0
- package/dist/utils/FormPage/applyConditionalProperties.test.js +63 -0
- package/dist/utils/FormPage/index.js +3 -0
- package/package.json +1 -1
|
@@ -67,6 +67,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
67
67
|
hide_title = _ref.hide_title,
|
|
68
68
|
summaryListClassModifiers = _ref.summaryListClassModifiers,
|
|
69
69
|
noChangeAction = _ref.noChangeAction,
|
|
70
|
+
noGroupAction = _ref.noGroupAction,
|
|
70
71
|
groups = _ref.groups,
|
|
71
72
|
sections = _ref.sections,
|
|
72
73
|
type = _ref.type;
|
|
@@ -170,6 +171,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
170
171
|
rows: page.rows,
|
|
171
172
|
classModifiers: summaryListClassModifiers,
|
|
172
173
|
noChangeAction: hideActionButtons,
|
|
174
|
+
noGroupAction: noGroupAction,
|
|
173
175
|
isGroup: isGroup(page.id)
|
|
174
176
|
}));
|
|
175
177
|
}));
|
|
@@ -190,6 +192,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
190
192
|
rows: page.rows,
|
|
191
193
|
classModifiers: summaryListClassModifiers,
|
|
192
194
|
noChangeAction: hideActionButtons,
|
|
195
|
+
noGroupAction: noGroupAction,
|
|
193
196
|
isGroup: isGroup(page.id)
|
|
194
197
|
}));
|
|
195
198
|
}), !hide_actions && /*#__PURE__*/_react.default.createElement(_PageActions.default, {
|
|
@@ -211,6 +214,7 @@ CheckYourAnswers.propTypes = {
|
|
|
211
214
|
hide_title: _propTypes.default.bool,
|
|
212
215
|
summaryListClassModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
213
216
|
noChangeAction: _propTypes.default.bool,
|
|
217
|
+
noGroupAction: _propTypes.default.bool,
|
|
214
218
|
sections: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
215
219
|
name: _propTypes.default.string.isRequired,
|
|
216
220
|
tasks: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -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, _formState$page$actio;
|
|
106
|
+
var _formState$page5, _formState$page$actio, _formState$cya$hideCh, _formState$cya$hideGr;
|
|
107
107
|
|
|
108
108
|
var title = _ref2.title,
|
|
109
109
|
type = _ref2.type,
|
|
@@ -613,7 +613,8 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
613
613
|
onRowAction: onCYARowAction,
|
|
614
614
|
summaryListClassModifiers: summaryListClassModifiers,
|
|
615
615
|
hide_title: hide_title,
|
|
616
|
-
noChangeAction: noChangeAction,
|
|
616
|
+
noChangeAction: (_formState$cya$hideCh = formState.cya.hideChangeActions) !== null && _formState$cya$hideCh !== void 0 ? _formState$cya$hideCh : noChangeAction,
|
|
617
|
+
noGroupAction: (_formState$cya$hideGr = formState.cya.hideGroupActions) !== null && _formState$cya$hideGr !== void 0 ? _formState$cya$hideGr : false,
|
|
617
618
|
sections: typeof hubDetails !== 'undefined' ? hubDetails.sections : [],
|
|
618
619
|
type: type
|
|
619
620
|
})), hub === _models.HubFormats.TASK && formState.pageId === _models.FormPages.HUB && /*#__PURE__*/_react.default.createElement(_TaskList.default, _extends({}, hubDetails, {
|
|
@@ -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
|
|
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
|
-
|
|
636
|
-
expect(
|
|
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
|
|
646
|
-
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS,
|
|
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
|
-
|
|
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({},
|
|
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
|
|
844
|
+
return _context24.stop();
|
|
779
845
|
}
|
|
780
846
|
}
|
|
781
|
-
},
|
|
847
|
+
}, _callee24);
|
|
782
848
|
})));
|
|
783
|
-
it('should go straight to CYA page if a complete task is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
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
|
|
851
|
+
return regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
786
852
|
while (1) {
|
|
787
|
-
switch (
|
|
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
|
-
|
|
797
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
798
|
-
return regeneratorRuntime.wrap(function
|
|
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 (
|
|
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
|
|
874
|
+
return _context25.stop();
|
|
809
875
|
}
|
|
810
876
|
}
|
|
811
|
-
},
|
|
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
|
|
929
|
+
return _context26.stop();
|
|
864
930
|
}
|
|
865
931
|
}
|
|
866
|
-
},
|
|
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
|
|
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
|
|
936
|
+
return regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
871
937
|
while (1) {
|
|
872
|
-
switch (
|
|
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
|
-
|
|
888
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
889
|
-
return regeneratorRuntime.wrap(function
|
|
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 (
|
|
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
|
|
965
|
+
return _context27.stop();
|
|
900
966
|
}
|
|
901
967
|
}
|
|
902
|
-
},
|
|
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
|
|
1017
|
+
return _context28.stop();
|
|
952
1018
|
}
|
|
953
1019
|
}
|
|
954
|
-
},
|
|
1020
|
+
}, _callee28);
|
|
955
1021
|
})));
|
|
956
|
-
it('should handle cancellation from a page', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
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
|
|
1025
|
+
return regeneratorRuntime.wrap(function _callee30$(_context30) {
|
|
960
1026
|
while (1) {
|
|
961
|
-
switch (
|
|
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
|
-
|
|
973
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
974
|
-
return regeneratorRuntime.wrap(function
|
|
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 (
|
|
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
|
|
1051
|
+
return _context29.stop();
|
|
986
1052
|
}
|
|
987
1053
|
}
|
|
988
|
-
},
|
|
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
|
|
1078
|
+
return _context30.stop();
|
|
1013
1079
|
}
|
|
1014
1080
|
}
|
|
1015
|
-
},
|
|
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
|
|
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
|
|
1085
|
+
return regeneratorRuntime.wrap(function _callee32$(_context32) {
|
|
1020
1086
|
while (1) {
|
|
1021
|
-
switch (
|
|
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
|
-
|
|
1036
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
1037
|
-
return regeneratorRuntime.wrap(function
|
|
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 (
|
|
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
|
|
1113
|
+
return _context31.stop();
|
|
1048
1114
|
}
|
|
1049
1115
|
}
|
|
1050
|
-
},
|
|
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
|
|
1133
|
+
return _context32.stop();
|
|
1068
1134
|
}
|
|
1069
1135
|
}
|
|
1070
|
-
},
|
|
1136
|
+
}, _callee32);
|
|
1071
1137
|
})));
|
|
1072
1138
|
});
|
|
1073
1139
|
});
|
|
@@ -7,6 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _models = require("../../../models");
|
|
9
9
|
|
|
10
|
+
var _utils = _interopRequireDefault(require("../../../utils"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
10
14
|
// Local imports
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -29,8 +33,12 @@ var getCYA = function getCYA(pageId, pages, hub) {
|
|
|
29
33
|
});
|
|
30
34
|
|
|
31
35
|
if ((currentPage === null || currentPage === void 0 ? void 0 : currentPage.type) === _models.FormPages.PARTIAL_CYA) {
|
|
36
|
+
var pageWithConditionals = _utils.default.FormPage.applyConditionalProperties(currentPage);
|
|
37
|
+
|
|
32
38
|
return {
|
|
33
|
-
title:
|
|
39
|
+
title: pageWithConditionals.title,
|
|
40
|
+
hideChangeActions: pageWithConditionals.hideChangeActions,
|
|
41
|
+
hideGroupActions: pageWithConditionals.hideGroupActions
|
|
34
42
|
};
|
|
35
43
|
}
|
|
36
44
|
|
|
@@ -21,7 +21,7 @@ var _SummaryListTitleRow = _interopRequireDefault(require("./SummaryListTitleRow
|
|
|
21
21
|
|
|
22
22
|
require("./SummaryList.scss");
|
|
23
23
|
|
|
24
|
-
var _excluded = ["rows", "noChangeAction", "isGroup", "classBlock", "classModifiers", "className"];
|
|
24
|
+
var _excluded = ["rows", "noChangeAction", "noGroupAction", "isGroup", "classBlock", "classModifiers", "className"];
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
|
|
@@ -37,6 +37,7 @@ exports.DEFAULT_CLASS = DEFAULT_CLASS;
|
|
|
37
37
|
var SummaryList = function SummaryList(_ref) {
|
|
38
38
|
var rows = _ref.rows,
|
|
39
39
|
noChangeAction = _ref.noChangeAction,
|
|
40
|
+
noGroupAction = _ref.noGroupAction,
|
|
40
41
|
isGroup = _ref.isGroup,
|
|
41
42
|
classBlock = _ref.classBlock,
|
|
42
43
|
classModifiers = _ref.classModifiers,
|
|
@@ -79,7 +80,7 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
if (row.type === 'action') {
|
|
82
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
+
return noChangeAction ? null : /*#__PURE__*/_react.default.createElement("div", {
|
|
83
84
|
key: "".concat(key, "-actions")
|
|
84
85
|
}, /*#__PURE__*/_react.default.createElement(_GroupAction.default, {
|
|
85
86
|
group: row
|
|
@@ -92,7 +93,9 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
92
93
|
classes: classes,
|
|
93
94
|
showAction: !noChangeAction
|
|
94
95
|
});
|
|
95
|
-
})
|
|
96
|
+
}).filter(function (r) {
|
|
97
|
+
return !!r;
|
|
98
|
+
}), isGroup && !noGroupAction && /*#__PURE__*/_react.default.createElement("div", {
|
|
96
99
|
className: "change-group-button"
|
|
97
100
|
}, /*#__PURE__*/_react.default.createElement(_GroupAction.default, {
|
|
98
101
|
group: groupActionRow
|
|
@@ -49,6 +49,14 @@ describe('components', function () {
|
|
|
49
49
|
return heading;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
var checkActionRow = function checkActionRow(summaryList, index) {
|
|
53
|
+
var row = summaryList.childNodes[index];
|
|
54
|
+
expect(row.tagName).toEqual('DIV');
|
|
55
|
+
expect(row.childNodes.length).toEqual(1);
|
|
56
|
+
var link = row.childNodes[0];
|
|
57
|
+
return link;
|
|
58
|
+
};
|
|
59
|
+
|
|
52
60
|
var checkRow = function checkRow(summaryList, index) {
|
|
53
61
|
var row = summaryList.childNodes[index];
|
|
54
62
|
expect(row.tagName).toEqual('DIV');
|
|
@@ -185,6 +193,84 @@ describe('components', function () {
|
|
|
185
193
|
}
|
|
186
194
|
});
|
|
187
195
|
});
|
|
196
|
+
it('should handle action rows', function () {
|
|
197
|
+
var ID = 'test-id';
|
|
198
|
+
var ROWS = [{
|
|
199
|
+
pageId: 'p1',
|
|
200
|
+
fieldId: 'a',
|
|
201
|
+
type: 'action',
|
|
202
|
+
action: {
|
|
203
|
+
label: 'Do action'
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
pageId: 'p2',
|
|
207
|
+
fieldId: 'b',
|
|
208
|
+
type: 'action',
|
|
209
|
+
action: {
|
|
210
|
+
label: 'Do action'
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
pageId: 'p3',
|
|
214
|
+
fieldId: 'c',
|
|
215
|
+
type: 'action',
|
|
216
|
+
action: {
|
|
217
|
+
label: 'Do action'
|
|
218
|
+
}
|
|
219
|
+
}];
|
|
220
|
+
|
|
221
|
+
var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
222
|
+
"data-testid": ID,
|
|
223
|
+
rows: ROWS
|
|
224
|
+
})),
|
|
225
|
+
container = _render4.container;
|
|
226
|
+
|
|
227
|
+
var summaryList = checkSummaryList(container, ID);
|
|
228
|
+
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
229
|
+
|
|
230
|
+
var assessActionRow = function assessActionRow(row, index) {
|
|
231
|
+
var link = checkActionRow(summaryList, index);
|
|
232
|
+
expect(link.textContent).toEqual(row.action.label);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
ROWS.forEach(function (row, index) {
|
|
236
|
+
assessActionRow(row, index);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
it('should hide actions rows if flag is given', function () {
|
|
240
|
+
var ID = 'test-id';
|
|
241
|
+
var ROWS = [{
|
|
242
|
+
pageId: 'p1',
|
|
243
|
+
fieldId: 'a',
|
|
244
|
+
type: 'action',
|
|
245
|
+
action: {
|
|
246
|
+
label: 'Do action'
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
pageId: 'p2',
|
|
250
|
+
fieldId: 'b',
|
|
251
|
+
type: 'action',
|
|
252
|
+
action: {
|
|
253
|
+
label: 'Do action'
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
pageId: 'p3',
|
|
257
|
+
fieldId: 'c',
|
|
258
|
+
type: 'action',
|
|
259
|
+
action: {
|
|
260
|
+
label: 'Do action'
|
|
261
|
+
}
|
|
262
|
+
}];
|
|
263
|
+
|
|
264
|
+
var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
265
|
+
"data-testid": ID,
|
|
266
|
+
rows: ROWS,
|
|
267
|
+
noChangeAction: true
|
|
268
|
+
})),
|
|
269
|
+
container = _render5.container;
|
|
270
|
+
|
|
271
|
+
var summaryList = checkSummaryList(container, ID);
|
|
272
|
+
expect(summaryList.childNodes.length).toEqual(0);
|
|
273
|
+
});
|
|
188
274
|
it('should handle rows with no actions and component values', function () {
|
|
189
275
|
var ID = 'test-id';
|
|
190
276
|
var VALUES = ['Alpha component value', 'Bravo component value'];
|
|
@@ -200,11 +286,11 @@ describe('components', function () {
|
|
|
200
286
|
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
|
|
201
287
|
}];
|
|
202
288
|
|
|
203
|
-
var
|
|
289
|
+
var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
204
290
|
"data-testid": ID,
|
|
205
291
|
rows: ROWS
|
|
206
292
|
})),
|
|
207
|
-
container =
|
|
293
|
+
container = _render6.container;
|
|
208
294
|
|
|
209
295
|
var summaryList = checkSummaryList(container, ID);
|
|
210
296
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
@@ -251,11 +337,11 @@ describe('components', function () {
|
|
|
251
337
|
}
|
|
252
338
|
}];
|
|
253
339
|
|
|
254
|
-
var
|
|
340
|
+
var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
255
341
|
"data-testid": ID,
|
|
256
342
|
rows: ROWS
|
|
257
343
|
})),
|
|
258
|
-
container =
|
|
344
|
+
container = _render7.container;
|
|
259
345
|
|
|
260
346
|
var summaryList = checkSummaryList(container, ID);
|
|
261
347
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
@@ -292,12 +378,12 @@ describe('components', function () {
|
|
|
292
378
|
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
|
|
293
379
|
}];
|
|
294
380
|
|
|
295
|
-
var
|
|
381
|
+
var _render8 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
296
382
|
"data-testid": ID,
|
|
297
383
|
rows: ROWS,
|
|
298
384
|
noChangeAction: true
|
|
299
385
|
})),
|
|
300
|
-
container =
|
|
386
|
+
container = _render8.container;
|
|
301
387
|
|
|
302
388
|
var summaryList = checkSummaryList(container, ID);
|
|
303
389
|
expect(summaryList.childNodes.length).toEqual(ROWS.length);
|
|
@@ -335,12 +421,12 @@ describe('components', function () {
|
|
|
335
421
|
value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[2])
|
|
336
422
|
}];
|
|
337
423
|
|
|
338
|
-
var
|
|
424
|
+
var _render9 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
|
|
339
425
|
"data-testid": ID,
|
|
340
426
|
rows: ROWS,
|
|
341
427
|
isGroup: ISGROUP
|
|
342
428
|
})),
|
|
343
|
-
container =
|
|
429
|
+
container = _render9.container;
|
|
344
430
|
|
|
345
431
|
var summaryList = checkSummaryList(container, ID);
|
|
346
432
|
expect(summaryList.childNodes.length).toEqual(ROWS.length + 1);
|
|
@@ -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"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _ = _interopRequireDefault(require(".."));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
|
|
16
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Apply properties to a page based on whether certain conditions are met.
|
|
20
|
+
* @param {object} page The page object.
|
|
21
|
+
* @returns A copy of the page object with any passing conditional
|
|
22
|
+
* properties applied.
|
|
23
|
+
*/
|
|
24
|
+
var applyConditionalProperties = function applyConditionalProperties(page) {
|
|
25
|
+
if (!page.conditionalProperties) {
|
|
26
|
+
return page;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var pageWithProperties = _objectSpread({}, page);
|
|
30
|
+
|
|
31
|
+
page.conditionalProperties.forEach(function (entry) {
|
|
32
|
+
if (_.default.Condition.met(entry.condition, page.formData[entry.condition.field])) {
|
|
33
|
+
pageWithProperties = Object.assign(pageWithProperties, entry.properties);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
;
|
|
37
|
+
});
|
|
38
|
+
return pageWithProperties;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var _default = applyConditionalProperties;
|
|
42
|
+
exports.default = _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _applyConditionalProperties = _interopRequireDefault(require("./applyConditionalProperties"));
|
|
4
|
+
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
+
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
|
|
11
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
|
|
13
|
+
describe('utils.FormPage.applyConditionalProperties', function () {
|
|
14
|
+
it('should not change the page if there are no conditional properties', function () {
|
|
15
|
+
var PAGE = {
|
|
16
|
+
id: 'testPage'
|
|
17
|
+
};
|
|
18
|
+
var result = (0, _applyConditionalProperties.default)(PAGE);
|
|
19
|
+
expect(result).toEqual(PAGE);
|
|
20
|
+
});
|
|
21
|
+
it('should not apply properties with conditions that have not been met', function () {
|
|
22
|
+
var PAGE = {
|
|
23
|
+
id: 'testPage',
|
|
24
|
+
conditionalProperties: [{
|
|
25
|
+
condition: {
|
|
26
|
+
field: 'alpha',
|
|
27
|
+
op: '=',
|
|
28
|
+
value: '123'
|
|
29
|
+
},
|
|
30
|
+
properties: {
|
|
31
|
+
beta: '456'
|
|
32
|
+
}
|
|
33
|
+
}],
|
|
34
|
+
formData: {
|
|
35
|
+
alpha: '012'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var result = (0, _applyConditionalProperties.default)(PAGE);
|
|
39
|
+
expect(result).toEqual(PAGE);
|
|
40
|
+
});
|
|
41
|
+
it('should apply properties with conditions that have been met', function () {
|
|
42
|
+
var PAGE = {
|
|
43
|
+
id: 'testPage',
|
|
44
|
+
conditionalProperties: [{
|
|
45
|
+
condition: {
|
|
46
|
+
field: 'alpha',
|
|
47
|
+
op: '=',
|
|
48
|
+
value: '123'
|
|
49
|
+
},
|
|
50
|
+
properties: {
|
|
51
|
+
beta: '456'
|
|
52
|
+
}
|
|
53
|
+
}],
|
|
54
|
+
formData: {
|
|
55
|
+
alpha: '123'
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var result = (0, _applyConditionalProperties.default)(PAGE);
|
|
59
|
+
expect(result).toEqual(_objectSpread(_objectSpread({}, PAGE), {}, {
|
|
60
|
+
beta: '456'
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _applyConditionalProperties = _interopRequireDefault(require("./applyConditionalProperties"));
|
|
9
|
+
|
|
8
10
|
var _getFormPage = _interopRequireDefault(require("./getFormPage"));
|
|
9
11
|
|
|
10
12
|
var _getFormPages = _interopRequireDefault(require("./getFormPages"));
|
|
@@ -16,6 +18,7 @@ var _showFormPageCYA = _interopRequireDefault(require("./showFormPageCYA"));
|
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
20
|
var FormPage = {
|
|
21
|
+
applyConditionalProperties: _applyConditionalProperties.default,
|
|
19
22
|
get: _getFormPage.default,
|
|
20
23
|
getAll: _getFormPages.default,
|
|
21
24
|
show: _showFormPage.default,
|