@ukhomeoffice/cop-react-form-renderer 5.88.8 → 5.90.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 +6 -2
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +131 -50
- package/dist/components/FormComponent/Collection.scss +1 -1
- package/dist/components/FormComponent/Container.js +2 -0
- package/dist/components/FormComponent/Container.scss +15 -0
- package/dist/json/actions.json +17 -0
- package/dist/json/actionsNoSave.json +17 -0
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +25 -0
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +33 -0
- package/dist/utils/Validate/additional/index.js +2 -0
- package/package.json +1 -1
|
@@ -207,7 +207,9 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
207
207
|
isGroup: isGroup(page.id)
|
|
208
208
|
}));
|
|
209
209
|
}), !hide_actions && /*#__PURE__*/_react.default.createElement(_PageActions.default, {
|
|
210
|
-
actions: actions
|
|
210
|
+
actions: actions === null || actions === void 0 ? void 0 : actions.filter(function (action) {
|
|
211
|
+
return _utils.default.Component.show(action, _pages[_pages.length - 1].formData);
|
|
212
|
+
}),
|
|
211
213
|
onAction: function onAction(action) {
|
|
212
214
|
return _onAction(action);
|
|
213
215
|
}
|
|
@@ -223,7 +225,9 @@ CheckYourAnswers.propTypes = {
|
|
|
223
225
|
noGroupAction: _propTypes.default.bool,
|
|
224
226
|
onAction: _propTypes.default.func.isRequired,
|
|
225
227
|
onRowAction: _propTypes.default.func.isRequired,
|
|
226
|
-
pages: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
228
|
+
pages: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
229
|
+
formData: _propTypes.default.shape({}).isRequired
|
|
230
|
+
})).isRequired,
|
|
227
231
|
sections: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
228
232
|
name: _propTypes.default.string.isRequired,
|
|
229
233
|
tasks: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
@@ -13,6 +13,8 @@ var _userProfile = _interopRequireDefault(require("../../json/userProfile.json")
|
|
|
13
13
|
var _groupData = _interopRequireDefault(require("../../json/group.data.json"));
|
|
14
14
|
var _group = _interopRequireDefault(require("../../json/group.json"));
|
|
15
15
|
var _groupOfRow = _interopRequireDefault(require("../../json/groupOfRow.json"));
|
|
16
|
+
var _actions = _interopRequireDefault(require("../../json/actions.json"));
|
|
17
|
+
var _actionsNoSave = _interopRequireDefault(require("../../json/actionsNoSave.json"));
|
|
16
18
|
var _models = require("../../models");
|
|
17
19
|
var _setupTests = require("../../setupTests");
|
|
18
20
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
@@ -673,12 +675,12 @@ describe('components', function () {
|
|
|
673
675
|
}
|
|
674
676
|
}, _callee26);
|
|
675
677
|
})));
|
|
676
|
-
it('should
|
|
677
|
-
var GROUP_PAGES, cya,
|
|
678
|
+
it('should show a conditional button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
679
|
+
var GROUP_PAGES, cya, hodsButtonDiv, submitButton, saveButton;
|
|
678
680
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
679
681
|
while (1) switch (_context28.prev = _context28.next) {
|
|
680
682
|
case 0:
|
|
681
|
-
GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, {});
|
|
683
|
+
GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
|
|
682
684
|
_context28.next = 3;
|
|
683
685
|
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
684
686
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
@@ -686,8 +688,10 @@ describe('components', function () {
|
|
|
686
688
|
case 0:
|
|
687
689
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
688
690
|
pages: GROUP_PAGES,
|
|
691
|
+
onRowAction: ON_ROW_ACTION,
|
|
692
|
+
onAction: ON_ACTION,
|
|
689
693
|
groups: _groupOfRow.default.cya.groups,
|
|
690
|
-
|
|
694
|
+
actions: _actions.default
|
|
691
695
|
}), container);
|
|
692
696
|
case 1:
|
|
693
697
|
case "end":
|
|
@@ -695,6 +699,83 @@ describe('components', function () {
|
|
|
695
699
|
}
|
|
696
700
|
}, _callee27);
|
|
697
701
|
})));
|
|
702
|
+
case 3:
|
|
703
|
+
cya = checkCYA(container);
|
|
704
|
+
hodsButtonDiv = cya.childNodes[7];
|
|
705
|
+
expect(hodsButtonDiv.classList).toContain('hods-button-group');
|
|
706
|
+
submitButton = hodsButtonDiv.childNodes[0];
|
|
707
|
+
expect(submitButton.tagName).toEqual('BUTTON');
|
|
708
|
+
expect(submitButton.textContent).toEqual('Submit');
|
|
709
|
+
saveButton = hodsButtonDiv.childNodes[1];
|
|
710
|
+
expect(saveButton.tagName).toEqual('BUTTON');
|
|
711
|
+
expect(saveButton.textContent).toEqual('Save and return later');
|
|
712
|
+
case 12:
|
|
713
|
+
case "end":
|
|
714
|
+
return _context28.stop();
|
|
715
|
+
}
|
|
716
|
+
}, _callee28);
|
|
717
|
+
})));
|
|
718
|
+
it('should not show a conditional button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
719
|
+
var GROUP_PAGES, cya, hodsButtonDiv, submitButton, saveButton;
|
|
720
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
721
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
722
|
+
case 0:
|
|
723
|
+
GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
|
|
724
|
+
_context30.next = 3;
|
|
725
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
726
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
727
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
728
|
+
case 0:
|
|
729
|
+
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
730
|
+
pages: GROUP_PAGES,
|
|
731
|
+
onRowAction: ON_ROW_ACTION,
|
|
732
|
+
onAction: ON_ACTION,
|
|
733
|
+
groups: _groupOfRow.default.cya.groups,
|
|
734
|
+
actions: _actionsNoSave.default
|
|
735
|
+
}), container);
|
|
736
|
+
case 1:
|
|
737
|
+
case "end":
|
|
738
|
+
return _context29.stop();
|
|
739
|
+
}
|
|
740
|
+
}, _callee29);
|
|
741
|
+
})));
|
|
742
|
+
case 3:
|
|
743
|
+
cya = checkCYA(container);
|
|
744
|
+
hodsButtonDiv = cya.childNodes[7];
|
|
745
|
+
expect(hodsButtonDiv.classList).toContain('hods-button-group');
|
|
746
|
+
submitButton = hodsButtonDiv.childNodes[0];
|
|
747
|
+
expect(submitButton.tagName).toEqual('BUTTON');
|
|
748
|
+
expect(submitButton.textContent).toEqual('Submit');
|
|
749
|
+
saveButton = hodsButtonDiv.childNodes[1];
|
|
750
|
+
expect(saveButton).toEqual(undefined);
|
|
751
|
+
case 11:
|
|
752
|
+
case "end":
|
|
753
|
+
return _context30.stop();
|
|
754
|
+
}
|
|
755
|
+
}, _callee30);
|
|
756
|
+
})));
|
|
757
|
+
it('should render empty optional fields with a placeholder value when provided', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
758
|
+
var GROUP_PAGES, cya, namesGroup, firstNameRow, surname;
|
|
759
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
760
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
761
|
+
case 0:
|
|
762
|
+
GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, {});
|
|
763
|
+
_context32.next = 3;
|
|
764
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
765
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
766
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
767
|
+
case 0:
|
|
768
|
+
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
769
|
+
pages: GROUP_PAGES,
|
|
770
|
+
groups: _groupOfRow.default.cya.groups,
|
|
771
|
+
optionalFieldPlaceholder: "Not entered"
|
|
772
|
+
}), container);
|
|
773
|
+
case 1:
|
|
774
|
+
case "end":
|
|
775
|
+
return _context31.stop();
|
|
776
|
+
}
|
|
777
|
+
}, _callee31);
|
|
778
|
+
})));
|
|
698
779
|
case 3:
|
|
699
780
|
cya = checkCYA(container);
|
|
700
781
|
namesGroup = cya.childNodes[2];
|
|
@@ -712,14 +793,14 @@ describe('components', function () {
|
|
|
712
793
|
expect(surname.childNodes[1].tagName).toEqual('DD');
|
|
713
794
|
case 17:
|
|
714
795
|
case "end":
|
|
715
|
-
return
|
|
796
|
+
return _context32.stop();
|
|
716
797
|
}
|
|
717
|
-
},
|
|
798
|
+
}, _callee32);
|
|
718
799
|
})));
|
|
719
|
-
it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
800
|
+
it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
720
801
|
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes7, cyaTitle, cyaChildNode, names, _names$childNodes3, firstName, surname, _firstName$childNodes, label;
|
|
721
|
-
return _regeneratorRuntime().wrap(function
|
|
722
|
-
while (1) switch (
|
|
802
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
803
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
723
804
|
case 0:
|
|
724
805
|
_PAGES = [].concat(_userProfile.default.pages); // eslint-disable-next-line no-template-curly-in-string
|
|
725
806
|
_PAGES[0] = _objectSpread(_objectSpread({}, _PAGES[0]), {}, {
|
|
@@ -733,10 +814,10 @@ describe('components', function () {
|
|
|
733
814
|
cya_label: "Text ${currentUser.familyName}"
|
|
734
815
|
});
|
|
735
816
|
T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, DATA);
|
|
736
|
-
|
|
737
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
738
|
-
return _regeneratorRuntime().wrap(function
|
|
739
|
-
while (1) switch (
|
|
817
|
+
_context34.next = 7;
|
|
818
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
819
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
820
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
740
821
|
case 0:
|
|
741
822
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
742
823
|
pages: T_PAGES,
|
|
@@ -745,9 +826,9 @@ describe('components', function () {
|
|
|
745
826
|
}), container);
|
|
746
827
|
case 1:
|
|
747
828
|
case "end":
|
|
748
|
-
return
|
|
829
|
+
return _context33.stop();
|
|
749
830
|
}
|
|
750
|
-
},
|
|
831
|
+
}, _callee33);
|
|
751
832
|
})));
|
|
752
833
|
case 7:
|
|
753
834
|
cya = checkCYA(container);
|
|
@@ -762,14 +843,14 @@ describe('components', function () {
|
|
|
762
843
|
checkRow(surname, 'Last name', 'Smith', false);
|
|
763
844
|
case 17:
|
|
764
845
|
case "end":
|
|
765
|
-
return
|
|
846
|
+
return _context34.stop();
|
|
766
847
|
}
|
|
767
|
-
},
|
|
848
|
+
}, _callee34);
|
|
768
849
|
})));
|
|
769
|
-
it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
850
|
+
it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
770
851
|
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes8, cyaChildNode, names, _names$childNodes4, firstName, surname, _firstName$childNodes2, label;
|
|
771
|
-
return _regeneratorRuntime().wrap(function
|
|
772
|
-
while (1) switch (
|
|
852
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
853
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
773
854
|
case 0:
|
|
774
855
|
_PAGES = [].concat(_userProfile.default.pages);
|
|
775
856
|
_COMPONENTS = [].concat(_userProfile.default.components);
|
|
@@ -779,10 +860,10 @@ describe('components', function () {
|
|
|
779
860
|
cya_label: undefined
|
|
780
861
|
});
|
|
781
862
|
T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, _objectSpread({}, DATA));
|
|
782
|
-
|
|
783
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
784
|
-
return _regeneratorRuntime().wrap(function
|
|
785
|
-
while (1) switch (
|
|
863
|
+
_context36.next = 6;
|
|
864
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
865
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
866
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
786
867
|
case 0:
|
|
787
868
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
788
869
|
pages: T_PAGES,
|
|
@@ -791,9 +872,9 @@ describe('components', function () {
|
|
|
791
872
|
}), container);
|
|
792
873
|
case 1:
|
|
793
874
|
case "end":
|
|
794
|
-
return
|
|
875
|
+
return _context35.stop();
|
|
795
876
|
}
|
|
796
|
-
},
|
|
877
|
+
}, _callee35);
|
|
797
878
|
})));
|
|
798
879
|
case 6:
|
|
799
880
|
cya = checkCYA(container);
|
|
@@ -807,14 +888,14 @@ describe('components', function () {
|
|
|
807
888
|
checkRow(surname, 'Last name', 'Smith', false);
|
|
808
889
|
case 15:
|
|
809
890
|
case "end":
|
|
810
|
-
return
|
|
891
|
+
return _context36.stop();
|
|
811
892
|
}
|
|
812
|
-
},
|
|
893
|
+
}, _callee36);
|
|
813
894
|
})));
|
|
814
|
-
it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
895
|
+
it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
815
896
|
var sections, taskHeading1, namesPageHeading;
|
|
816
|
-
return _regeneratorRuntime().wrap(function
|
|
817
|
-
while (1) switch (
|
|
897
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
898
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
818
899
|
case 0:
|
|
819
900
|
sections = [{
|
|
820
901
|
name: 'These are your tasks',
|
|
@@ -828,10 +909,10 @@ describe('components', function () {
|
|
|
828
909
|
pages: ['grade']
|
|
829
910
|
}]
|
|
830
911
|
}];
|
|
831
|
-
|
|
832
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
833
|
-
return _regeneratorRuntime().wrap(function
|
|
834
|
-
while (1) switch (
|
|
912
|
+
_context38.next = 3;
|
|
913
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
|
|
914
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
915
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
835
916
|
case 0:
|
|
836
917
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
837
918
|
pages: PAGES,
|
|
@@ -843,9 +924,9 @@ describe('components', function () {
|
|
|
843
924
|
}), container);
|
|
844
925
|
case 1:
|
|
845
926
|
case "end":
|
|
846
|
-
return
|
|
927
|
+
return _context37.stop();
|
|
847
928
|
}
|
|
848
|
-
},
|
|
929
|
+
}, _callee37);
|
|
849
930
|
})));
|
|
850
931
|
case 3:
|
|
851
932
|
taskHeading1 = container.childNodes[0].childNodes[0];
|
|
@@ -859,21 +940,21 @@ describe('components', function () {
|
|
|
859
940
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // second task skipped so not shown
|
|
860
941
|
case 12:
|
|
861
942
|
case "end":
|
|
862
|
-
return
|
|
943
|
+
return _context38.stop();
|
|
863
944
|
}
|
|
864
|
-
},
|
|
945
|
+
}, _callee38);
|
|
865
946
|
})));
|
|
866
|
-
it('Show answers from multiple address fields into in one DL correctly when hideBlankRows is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
947
|
+
it('Show answers from multiple address fields into in one DL correctly when hideBlankRows is true', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
867
948
|
var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
|
|
868
|
-
return _regeneratorRuntime().wrap(function
|
|
869
|
-
while (1) switch (
|
|
949
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
950
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
870
951
|
case 0:
|
|
871
952
|
ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
|
|
872
953
|
GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
|
|
873
|
-
|
|
874
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
875
|
-
return _regeneratorRuntime().wrap(function
|
|
876
|
-
while (1) switch (
|
|
954
|
+
_context40.next = 4;
|
|
955
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
956
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
957
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
877
958
|
case 0:
|
|
878
959
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
879
960
|
pages: GROUP_PAGES,
|
|
@@ -884,9 +965,9 @@ describe('components', function () {
|
|
|
884
965
|
}), container);
|
|
885
966
|
case 1:
|
|
886
967
|
case "end":
|
|
887
|
-
return
|
|
968
|
+
return _context39.stop();
|
|
888
969
|
}
|
|
889
|
-
},
|
|
970
|
+
}, _callee39);
|
|
890
971
|
})));
|
|
891
972
|
case 4:
|
|
892
973
|
cya = checkCYA(container);
|
|
@@ -908,9 +989,9 @@ describe('components', function () {
|
|
|
908
989
|
expect(changeButton.textContent).toEqual('Change address details');
|
|
909
990
|
case 21:
|
|
910
991
|
case "end":
|
|
911
|
-
return
|
|
992
|
+
return _context40.stop();
|
|
912
993
|
}
|
|
913
|
-
},
|
|
994
|
+
}, _callee40);
|
|
914
995
|
})));
|
|
915
996
|
});
|
|
916
997
|
});
|
|
@@ -12,8 +12,10 @@ var _models = require("../../models");
|
|
|
12
12
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
13
13
|
var _FormComponent = _interopRequireDefault(require("./FormComponent"));
|
|
14
14
|
var _getSourceData = _interopRequireDefault(require("../../utils/Data/getSourceData"));
|
|
15
|
+
require("./Container.scss");
|
|
15
16
|
var _excluded = ["container", "value", "formData", "onChange", "wrap", "onTopLevelChange"]; // Global imports
|
|
16
17
|
// Local imports
|
|
18
|
+
// Styles
|
|
17
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.horizonal {
|
|
2
|
+
flex-direction: row;
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
gap: 2rem;
|
|
6
|
+
.horizonal{
|
|
7
|
+
justify-content: space-around;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
@media screen and (max-width: 640px) {
|
|
11
|
+
.horizonal {
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap:0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Additional validator to not permit a value change if a specified item exists in formData.
|
|
9
|
+
* @param {object} data the changed value
|
|
10
|
+
* @param {object} config the config for the validation must contain
|
|
11
|
+
* a property 'base' holding the value for checking
|
|
12
|
+
* a property 'check' holding the formData item name to check if exists
|
|
13
|
+
* @param {object} formData the form data
|
|
14
|
+
* @returns false if:
|
|
15
|
+
* the 'base' value is not the same as the changed value AND
|
|
16
|
+
* the 'check' value exists in formData as an item
|
|
17
|
+
* otherwise returns true
|
|
18
|
+
*/
|
|
19
|
+
var conditionallyPermittedChange = function conditionallyPermittedChange(data, config, _, formData) {
|
|
20
|
+
if (data !== config.base && formData[config.check]) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = conditionallyPermittedChange;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _conditionallyPermittedChange = _interopRequireDefault(require("./conditionallyPermittedChange"));
|
|
4
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
+
describe('utils', function () {
|
|
6
|
+
describe('Validate', function () {
|
|
7
|
+
describe('additional', function () {
|
|
8
|
+
describe('conditionallyPermittedChange', function () {
|
|
9
|
+
var CONFIG = {
|
|
10
|
+
base: 'Value1',
|
|
11
|
+
check: 'Item1'
|
|
12
|
+
};
|
|
13
|
+
test('should pass if the base value has same value as data parameter', function () {
|
|
14
|
+
var DATA = 'Value1';
|
|
15
|
+
var FORMDATA = {};
|
|
16
|
+
expect((0, _conditionallyPermittedChange.default)(DATA, CONFIG, null, FORMDATA)).toEqual(true);
|
|
17
|
+
});
|
|
18
|
+
test('should fail if the base value is different to data parameter and check item exists in form data', function () {
|
|
19
|
+
var DATA = 'Value2';
|
|
20
|
+
var FORMDATA = {
|
|
21
|
+
Item1: "any"
|
|
22
|
+
};
|
|
23
|
+
expect((0, _conditionallyPermittedChange.default)(DATA, CONFIG, null, FORMDATA)).toEqual(false);
|
|
24
|
+
});
|
|
25
|
+
test('should pass if the base value is different to data parameter and check item not exists in form data', function () {
|
|
26
|
+
var DATA = 'Value2';
|
|
27
|
+
var FORMDATA = {};
|
|
28
|
+
expect((0, _conditionallyPermittedChange.default)(DATA, CONFIG, null, FORMDATA)).toEqual(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _conditionallyPermittedChange = _interopRequireDefault(require("./conditionallyPermittedChange"));
|
|
7
8
|
var _conditionallyRequired = _interopRequireDefault(require("./conditionallyRequired"));
|
|
8
9
|
var _mustBeAfter = _interopRequireDefault(require("./mustBeAfter"));
|
|
9
10
|
var _mustBeBefore = _interopRequireDefault(require("./mustBeBefore"));
|
|
@@ -25,6 +26,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
26
|
// Local imports
|
|
26
27
|
|
|
27
28
|
var functions = {
|
|
29
|
+
conditionallyPermittedChange: _conditionallyPermittedChange.default,
|
|
28
30
|
conditionallyRequired: _conditionallyRequired.default,
|
|
29
31
|
mustBeAfter: _mustBeAfter.default,
|
|
30
32
|
mustBeBefore: _mustBeBefore.default,
|