@ukhomeoffice/cop-react-form-renderer 6.6.1 → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +11 -5
- package/dist/components/CheckYourAnswers/Answer.test.js +67 -14
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +9 -5
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +156 -64
- package/dist/components/CollectionSummary/CollectionSummary.js +20 -3
- package/dist/components/CollectionSummary/CollectionSummary.test.js +66 -20
- package/dist/components/CollectionSummary/RenderListView.js +2 -2
- package/dist/components/CollectionSummary/SummaryCard.js +17 -6
- package/dist/components/CollectionSummary/SummaryCard.test.js +94 -37
- package/dist/components/CollectionSummary/SummaryCardDetails.js +78 -34
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +9 -0
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +206 -10
- package/dist/components/FormComponent/Container.js +2 -1
- package/dist/components/FormComponent/Container.test.js +69 -0
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +1 -0
- package/dist/components/SummaryList/SummaryList.js +8 -0
- package/dist/components/SummaryList/SummaryList.scss +15 -0
- package/dist/components/SummaryList/SummaryList.test.js +67 -7
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +53 -0
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.scss +38 -0
- package/dist/components/TaskList/TaskList.js +22 -5
- package/dist/components/TaskList/TaskList.scss +24 -0
- package/dist/components/TaskList/TaskList.test.js +160 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +27 -12
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +145 -0
- package/dist/utils/CheckYourAnswers/{getComponentRowForCYA.js → getSummaryListRowForDetails.js} +10 -5
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +56 -0
- package/dist/utils/CollectionPage/getQuickEditPage.js +2 -1
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +8 -0
- package/dist/utils/CollectionPage/mergeCollectionPages.js +10 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +6 -6
- package/dist/utils/Component/elevateNestedComponents.js +2 -1
- package/dist/utils/Component/elevateNestedComponents.test.js +38 -0
- package/dist/utils/Component/optionIsSelected.js +5 -0
- package/dist/utils/Component/optionIsSelected.test.js +26 -0
- package/dist/utils/Operate/getLength.js +50 -0
- package/dist/utils/Operate/getLength.test.js +89 -0
- package/dist/utils/Operate/runPageOperations.js +2 -0
- package/dist/utils/Validate/validateComponent.js +7 -2
- package/dist/utils/Validate/validateComponent.test.js +31 -0
- package/dist/utils/Validate/validateTime.js +8 -0
- package/dist/utils/Validate/validateTime.test.js +46 -0
- package/package.json +1 -1
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +0 -41
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
+
require("@testing-library/jest-dom/extend-expect");
|
|
4
5
|
var _react2 = _interopRequireDefault(require("react"));
|
|
5
6
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
6
7
|
var _testUtils = require("react-dom/test-utils");
|
|
@@ -582,6 +583,62 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
582
583
|
headerActionDiv = _checkSetup18.headerActionDiv;
|
|
583
584
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
584
585
|
});
|
|
586
|
+
it('should focus on the most recently duplicated item', function () {
|
|
587
|
+
var entryData = {
|
|
588
|
+
id: ID,
|
|
589
|
+
isDuplicate: true
|
|
590
|
+
};
|
|
591
|
+
var config = {
|
|
592
|
+
duplicateAction: {
|
|
593
|
+
label: 'Duplicate Label',
|
|
594
|
+
aria_label: 'Duplicate Aria Label'
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
var onDuplicate = jest.fn();
|
|
598
|
+
var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
599
|
+
id: ID,
|
|
600
|
+
entryData: entryData,
|
|
601
|
+
config: config,
|
|
602
|
+
onDuplicate: onDuplicate,
|
|
603
|
+
parentCollectionName: "parent",
|
|
604
|
+
pages: [],
|
|
605
|
+
formData: {},
|
|
606
|
+
hideDetails: true,
|
|
607
|
+
masterPage: {
|
|
608
|
+
childPages: []
|
|
609
|
+
}
|
|
610
|
+
})),
|
|
611
|
+
getByTestId = _renderWithValidation20.getByTestId;
|
|
612
|
+
var updatedConfig = {
|
|
613
|
+
focusOn: true,
|
|
614
|
+
quickEdit: true
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
// Rerender the component with updated config
|
|
618
|
+
var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
619
|
+
id: ID,
|
|
620
|
+
entryData: entryData,
|
|
621
|
+
config: updatedConfig,
|
|
622
|
+
parentCollectionName: "parent",
|
|
623
|
+
pages: [],
|
|
624
|
+
formData: {},
|
|
625
|
+
hideDetails: true,
|
|
626
|
+
masterPage: {
|
|
627
|
+
childPages: []
|
|
628
|
+
}
|
|
629
|
+
})),
|
|
630
|
+
getByTestIdRerender = _renderWithValidation21.getByTestId;
|
|
631
|
+
|
|
632
|
+
// check that focus isn't on the initial component
|
|
633
|
+
var initialComponent = getByTestId('duplicate-button');
|
|
634
|
+
expect(initialComponent).toBeInTheDocument();
|
|
635
|
+
expect(initialComponent).not.toHaveFocus();
|
|
636
|
+
|
|
637
|
+
// check that the focus is on the newly duplicated component
|
|
638
|
+
var DuplicatedComponent = getByTestIdRerender('quickedit-button');
|
|
639
|
+
expect(DuplicatedComponent).toBeInTheDocument();
|
|
640
|
+
expect(DuplicatedComponent).toHaveFocus();
|
|
641
|
+
});
|
|
585
642
|
});
|
|
586
643
|
describe('Quick Edit action button', function () {
|
|
587
644
|
var CONFIG = {
|
|
@@ -611,7 +668,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
611
668
|
}
|
|
612
669
|
}];
|
|
613
670
|
it('should render correctly', function () {
|
|
614
|
-
var
|
|
671
|
+
var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
615
672
|
id: ID,
|
|
616
673
|
entryData: ENTRY,
|
|
617
674
|
config: CONFIG,
|
|
@@ -621,7 +678,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
621
678
|
childPages: PAGES
|
|
622
679
|
}
|
|
623
680
|
})),
|
|
624
|
-
container =
|
|
681
|
+
container = _renderWithValidation22.container;
|
|
625
682
|
var _checkSetup19 = checkSetup(container),
|
|
626
683
|
headerActionDiv = _checkSetup19.headerActionDiv;
|
|
627
684
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
@@ -652,7 +709,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
652
709
|
});
|
|
653
710
|
|
|
654
711
|
it('should not render when no config is provided for it', function () {
|
|
655
|
-
var
|
|
712
|
+
var _renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
656
713
|
id: ID,
|
|
657
714
|
entryData: ENTRY,
|
|
658
715
|
config: {},
|
|
@@ -662,7 +719,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
662
719
|
childPages: PAGES
|
|
663
720
|
}
|
|
664
721
|
})),
|
|
665
|
-
container =
|
|
722
|
+
container = _renderWithValidation23.container;
|
|
666
723
|
var _checkSetup20 = checkSetup(container),
|
|
667
724
|
headerActionDiv = _checkSetup20.headerActionDiv;
|
|
668
725
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
@@ -707,7 +764,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
707
764
|
entryId: '123',
|
|
708
765
|
error: 'top-level error message'
|
|
709
766
|
}];
|
|
710
|
-
var
|
|
767
|
+
var _renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
711
768
|
entryId: CUSTOM_ENTRY.id,
|
|
712
769
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
713
770
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -720,7 +777,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
720
777
|
childPages: PAGES
|
|
721
778
|
}
|
|
722
779
|
}))),
|
|
723
|
-
container =
|
|
780
|
+
container = _renderWithValidation24.container;
|
|
724
781
|
var _checkSetup21 = checkSetup(container),
|
|
725
782
|
headerActionDiv = _checkSetup21.headerActionDiv;
|
|
726
783
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
@@ -742,7 +799,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
742
799
|
expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
|
|
743
800
|
});
|
|
744
801
|
it('should only show errors from validation when it happens, ignoring top-level errors', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
745
|
-
var TOP_LEVEL_ERRORS,
|
|
802
|
+
var TOP_LEVEL_ERRORS, _renderWithValidation25, container, _checkSetup22, headerActionDiv, editButton, quickEdit, errorSummary, component, componentInput, quickEditButtons, saveButton;
|
|
746
803
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
747
804
|
while (1) switch (_context3.prev = _context3.next) {
|
|
748
805
|
case 0:
|
|
@@ -751,7 +808,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
751
808
|
entryId: '123',
|
|
752
809
|
error: 'top-level error message'
|
|
753
810
|
}];
|
|
754
|
-
|
|
811
|
+
_renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
755
812
|
entryId: CUSTOM_ENTRY.id,
|
|
756
813
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
757
814
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -764,7 +821,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
764
821
|
childPages: PAGES
|
|
765
822
|
},
|
|
766
823
|
onQuickEdit: function onQuickEdit() {}
|
|
767
|
-
}))), container =
|
|
824
|
+
}))), container = _renderWithValidation25.container;
|
|
768
825
|
_checkSetup22 = checkSetup(container), headerActionDiv = _checkSetup22.headerActionDiv;
|
|
769
826
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
770
827
|
|
|
@@ -864,7 +921,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
864
921
|
}
|
|
865
922
|
}];
|
|
866
923
|
it('should render correctly', function () {
|
|
867
|
-
var
|
|
924
|
+
var _renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
868
925
|
id: ID,
|
|
869
926
|
entryData: ENTRY,
|
|
870
927
|
config: CONFIG,
|
|
@@ -874,7 +931,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
874
931
|
childPages: PAGES
|
|
875
932
|
}
|
|
876
933
|
})),
|
|
877
|
-
container =
|
|
934
|
+
container = _renderWithValidation26.container;
|
|
878
935
|
var _checkSetup23 = checkSetup(container),
|
|
879
936
|
headerActionDiv = _checkSetup23.headerActionDiv;
|
|
880
937
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
@@ -910,7 +967,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
910
967
|
return ON_SUBMIT_CALLS.push(patch);
|
|
911
968
|
}
|
|
912
969
|
};
|
|
913
|
-
var
|
|
970
|
+
var _renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
914
971
|
id: ID,
|
|
915
972
|
entryData: ENTRY,
|
|
916
973
|
config: CONFIG,
|
|
@@ -922,7 +979,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
922
979
|
}), {
|
|
923
980
|
hooks: hooks
|
|
924
981
|
}),
|
|
925
|
-
container =
|
|
982
|
+
container = _renderWithValidation27.container;
|
|
926
983
|
var _checkSetup24 = checkSetup(container),
|
|
927
984
|
headerActionDiv = _checkSetup24.headerActionDiv;
|
|
928
985
|
|
|
@@ -938,7 +995,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
938
995
|
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
939
996
|
});
|
|
940
997
|
it('should return after local validation if errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
941
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
998
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation28, container, _checkSetup25, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
942
999
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
943
1000
|
while (1) switch (_context6.prev = _context6.next) {
|
|
944
1001
|
case 0:
|
|
@@ -953,7 +1010,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
953
1010
|
var target = _ref5.target;
|
|
954
1011
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
955
1012
|
};
|
|
956
|
-
|
|
1013
|
+
_renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
957
1014
|
id: ID,
|
|
958
1015
|
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
959
1016
|
index: 0
|
|
@@ -971,7 +1028,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
971
1028
|
}
|
|
972
1029
|
}), {
|
|
973
1030
|
hooks: hooks
|
|
974
|
-
}), container =
|
|
1031
|
+
}), container = _renderWithValidation28.container;
|
|
975
1032
|
_checkSetup25 = checkSetup(container), headerActionDiv = _checkSetup25.headerActionDiv;
|
|
976
1033
|
editButton = headerActionDiv.children[0];
|
|
977
1034
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1019,7 +1076,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1019
1076
|
}, _callee6);
|
|
1020
1077
|
})));
|
|
1021
1078
|
it('should run hook validation when local validation is passed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1022
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1079
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation29, container, _checkSetup26, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1023
1080
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1024
1081
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1025
1082
|
case 0:
|
|
@@ -1038,7 +1095,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1038
1095
|
var target = _ref9.target;
|
|
1039
1096
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1040
1097
|
};
|
|
1041
|
-
|
|
1098
|
+
_renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1042
1099
|
id: ID,
|
|
1043
1100
|
entryData: ENTRY,
|
|
1044
1101
|
config: CONFIG,
|
|
@@ -1054,7 +1111,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1054
1111
|
}
|
|
1055
1112
|
}), {
|
|
1056
1113
|
hooks: hooks
|
|
1057
|
-
}), container =
|
|
1114
|
+
}), container = _renderWithValidation29.container;
|
|
1058
1115
|
_checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
|
|
1059
1116
|
editButton = headerActionDiv.children[0];
|
|
1060
1117
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1092,7 +1149,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1092
1149
|
}, _callee8);
|
|
1093
1150
|
})));
|
|
1094
1151
|
it('should apply changes if no errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
1095
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1152
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation30, container, _checkSetup27, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1096
1153
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1097
1154
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1098
1155
|
case 0:
|
|
@@ -1107,7 +1164,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1107
1164
|
var target = _ref12.target;
|
|
1108
1165
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1109
1166
|
};
|
|
1110
|
-
|
|
1167
|
+
_renderWithValidation30 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
1111
1168
|
entryId: "id",
|
|
1112
1169
|
topLevelErrors: [],
|
|
1113
1170
|
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
|
|
@@ -1130,7 +1187,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1130
1187
|
}
|
|
1131
1188
|
})), {
|
|
1132
1189
|
hooks: hooks
|
|
1133
|
-
}), container =
|
|
1190
|
+
}), container = _renderWithValidation30.container;
|
|
1134
1191
|
_checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
|
|
1135
1192
|
editButton = headerActionDiv.children[0];
|
|
1136
1193
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1169,7 +1226,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1169
1226
|
}, _callee10);
|
|
1170
1227
|
})));
|
|
1171
1228
|
it('should remove the isDuplicate flag on a sucessful quick edit', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1172
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1229
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation31, container, _checkSetup28, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1173
1230
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1174
1231
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1175
1232
|
case 0:
|
|
@@ -1184,7 +1241,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1184
1241
|
var target = _ref15.target;
|
|
1185
1242
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1186
1243
|
};
|
|
1187
|
-
|
|
1244
|
+
_renderWithValidation31 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
1188
1245
|
entryId: "id",
|
|
1189
1246
|
topLevelErrors: [],
|
|
1190
1247
|
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
|
|
@@ -1208,7 +1265,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1208
1265
|
}
|
|
1209
1266
|
})), {
|
|
1210
1267
|
hooks: hooks
|
|
1211
|
-
}), container =
|
|
1268
|
+
}), container = _renderWithValidation31.container;
|
|
1212
1269
|
_checkSetup28 = checkSetup(container), headerActionDiv = _checkSetup28.headerActionDiv;
|
|
1213
1270
|
editButton = headerActionDiv.children[0];
|
|
1214
1271
|
_react.fireEvent.click(editButton, {});
|
|
@@ -1255,7 +1312,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1255
1312
|
title: 'Title',
|
|
1256
1313
|
details: DETAILS
|
|
1257
1314
|
};
|
|
1258
|
-
var
|
|
1315
|
+
var _renderWithValidation32 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1259
1316
|
id: ID,
|
|
1260
1317
|
entryData: ENTRY,
|
|
1261
1318
|
config: CONFIG,
|
|
@@ -1266,7 +1323,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1266
1323
|
childPages: []
|
|
1267
1324
|
}
|
|
1268
1325
|
})),
|
|
1269
|
-
container =
|
|
1326
|
+
container = _renderWithValidation32.container;
|
|
1270
1327
|
var _checkSetup29 = checkSetup(container),
|
|
1271
1328
|
headerContentDiv = _checkSetup29.headerContentDiv;
|
|
1272
1329
|
var headerDetails = headerContentDiv.children[1];
|
|
@@ -1293,7 +1350,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1293
1350
|
}]
|
|
1294
1351
|
}]
|
|
1295
1352
|
};
|
|
1296
|
-
var
|
|
1353
|
+
var _renderWithValidation33 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1297
1354
|
id: ID,
|
|
1298
1355
|
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
1299
1356
|
field: true
|
|
@@ -1306,7 +1363,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1306
1363
|
childPages: []
|
|
1307
1364
|
}
|
|
1308
1365
|
})),
|
|
1309
|
-
container =
|
|
1366
|
+
container = _renderWithValidation33.container;
|
|
1310
1367
|
var _checkSetup30 = checkSetup(container),
|
|
1311
1368
|
headerContentDiv = _checkSetup30.headerContentDiv;
|
|
1312
1369
|
var headerDetails = headerContentDiv.children[1];
|
|
@@ -1319,7 +1376,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1319
1376
|
title: 'Title',
|
|
1320
1377
|
details: ''
|
|
1321
1378
|
};
|
|
1322
|
-
var
|
|
1379
|
+
var _renderWithValidation34 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1323
1380
|
id: ID,
|
|
1324
1381
|
entryData: ENTRY,
|
|
1325
1382
|
config: CONFIG,
|
|
@@ -1330,7 +1387,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1330
1387
|
childPages: []
|
|
1331
1388
|
}
|
|
1332
1389
|
})),
|
|
1333
|
-
container =
|
|
1390
|
+
container = _renderWithValidation34.container;
|
|
1334
1391
|
var _checkSetup31 = checkSetup(container),
|
|
1335
1392
|
headerContentDiv = _checkSetup31.headerContentDiv;
|
|
1336
1393
|
// If no details are provided, we expect only the header title to be rendered.
|
|
@@ -1347,7 +1404,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1347
1404
|
title: 'Title',
|
|
1348
1405
|
details: DETAILS
|
|
1349
1406
|
};
|
|
1350
|
-
var
|
|
1407
|
+
var _renderWithValidation35 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1351
1408
|
id: ID,
|
|
1352
1409
|
entryData: INTERPOLATED_ENTRY,
|
|
1353
1410
|
config: CONFIG,
|
|
@@ -1358,7 +1415,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1358
1415
|
childPages: []
|
|
1359
1416
|
}
|
|
1360
1417
|
})),
|
|
1361
|
-
container =
|
|
1418
|
+
container = _renderWithValidation35.container;
|
|
1362
1419
|
var _checkSetup32 = checkSetup(container),
|
|
1363
1420
|
headerContentDiv = _checkSetup32.headerContentDiv;
|
|
1364
1421
|
var headerDetails = headerContentDiv.children[1];
|
|
@@ -1369,7 +1426,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1369
1426
|
var CONFIG = {
|
|
1370
1427
|
title: 'Title'
|
|
1371
1428
|
};
|
|
1372
|
-
var
|
|
1429
|
+
var _renderWithValidation36 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1373
1430
|
id: ID,
|
|
1374
1431
|
entryData: ENTRY,
|
|
1375
1432
|
config: CONFIG,
|
|
@@ -1380,7 +1437,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1380
1437
|
childPages: []
|
|
1381
1438
|
}
|
|
1382
1439
|
})),
|
|
1383
|
-
container =
|
|
1440
|
+
container = _renderWithValidation36.container;
|
|
1384
1441
|
var _checkSetup33 = checkSetup(container),
|
|
1385
1442
|
headerContentDiv = _checkSetup33.headerContentDiv;
|
|
1386
1443
|
var headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
|
|
@@ -1392,7 +1449,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1392
1449
|
title: 'Title',
|
|
1393
1450
|
details: DETAILS
|
|
1394
1451
|
};
|
|
1395
|
-
var
|
|
1452
|
+
var _renderWithValidation37 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1396
1453
|
id: ID,
|
|
1397
1454
|
entryData: ENTRY,
|
|
1398
1455
|
config: CONFIG,
|
|
@@ -1404,7 +1461,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1404
1461
|
childPages: []
|
|
1405
1462
|
}
|
|
1406
1463
|
})),
|
|
1407
|
-
container =
|
|
1464
|
+
container = _renderWithValidation37.container;
|
|
1408
1465
|
var detailsComponent = container.querySelector('.details');
|
|
1409
1466
|
expect(detailsComponent).toBeNull();
|
|
1410
1467
|
});
|
|
@@ -8,9 +8,11 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
10
10
|
var _models = require("../../models");
|
|
11
|
-
var
|
|
11
|
+
var _getSummaryListRowForDetails = _interopRequireDefault(require("../../utils/CheckYourAnswers/getSummaryListRowForDetails"));
|
|
12
|
+
var _getCYARowsForCollection = _interopRequireDefault(require("../../utils/CheckYourAnswers/getCYARowsForCollection"));
|
|
12
13
|
var _getCYARowsForContainer = _interopRequireDefault(require("../../utils/CheckYourAnswers/getCYARowsForContainer"));
|
|
13
14
|
var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
|
|
15
|
+
var _Condition = _interopRequireDefault(require("../../utils/Condition"));
|
|
14
16
|
require("./SummaryCardDetails.scss");
|
|
15
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
16
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -31,7 +33,8 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
31
33
|
formData = _ref.formData,
|
|
32
34
|
entryData = _ref.entryData,
|
|
33
35
|
classModifiers = _ref.classModifiers,
|
|
34
|
-
hideChildSectionTitles = _ref.hideChildSectionTitles
|
|
36
|
+
hideChildSectionTitles = _ref.hideChildSectionTitles,
|
|
37
|
+
optionalFieldPlaceholder = _ref.optionalFieldPlaceholder;
|
|
35
38
|
var classes = _utils.default.classBuilder(DEFAULT_CLASS, classModifiers);
|
|
36
39
|
var childMasterPages = (0, _react.useMemo)(function () {
|
|
37
40
|
return childCollections.map(function (childName) {
|
|
@@ -43,20 +46,72 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
43
46
|
return !!e;
|
|
44
47
|
});
|
|
45
48
|
}, [masterPage, childCollections]);
|
|
46
|
-
var getSectionContent = function getSectionContent(
|
|
49
|
+
var getSectionContent = function getSectionContent(columns, components, childPage) {
|
|
47
50
|
var columnIndex = 0;
|
|
48
|
-
return
|
|
51
|
+
return columns.flatMap(function (column, index) {
|
|
49
52
|
var _column$fields;
|
|
50
53
|
var rowIndex = 0;
|
|
51
54
|
var columnContent = (_column$fields = column.fields) === null || _column$fields === void 0 ? void 0 : _column$fields.flatMap(function (fieldId) {
|
|
52
|
-
var
|
|
55
|
+
var componentMatches = components.filter(function (comp) {
|
|
53
56
|
return comp.fieldId === fieldId;
|
|
54
57
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
return componentMatches.map(function (component) {
|
|
59
|
+
if (!component || !(0, _showComponent.default)(component, _objectSpread(_objectSpread({}, childPage.formData), entryData))) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (component.type === _models.ComponentTypes.CONTAINER) {
|
|
63
|
+
var containerRows = (0, _getCYARowsForContainer.default)(childPage, component, entryData);
|
|
64
|
+
rowIndex += 1;
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
key: fieldId,
|
|
67
|
+
className: classes('field'),
|
|
68
|
+
style: {
|
|
69
|
+
'--column': columnIndex + 1,
|
|
70
|
+
'--row': rowIndex
|
|
71
|
+
}
|
|
72
|
+
}, containerRows.map(function (subComponent) {
|
|
73
|
+
var _entryData$component$;
|
|
74
|
+
// Put value for current subcomponent at top level
|
|
75
|
+
var modEntry = _objectSpread(_objectSpread({}, entryData), _defineProperty({}, subComponent.fieldId, (_entryData$component$ = entryData[component.fieldId]) === null || _entryData$component$ === void 0 ? void 0 : _entryData$component$[subComponent.fieldId]));
|
|
76
|
+
return (0, _getSummaryListRowForDetails.default)(childPage, _objectSpread(_objectSpread({}, subComponent), {
|
|
77
|
+
label: subComponent.key
|
|
78
|
+
}), classes, modEntry, optionalFieldPlaceholder);
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
if (component.type === _models.ComponentTypes.COLLECTION) {
|
|
82
|
+
var collectionRows = (0, _getCYARowsForCollection.default)(_objectSpread(_objectSpread({}, childPage), {}, {
|
|
83
|
+
formData: _objectSpread(_objectSpread({}, childPage.formData), entryData)
|
|
84
|
+
}), component, entryData[component.id]);
|
|
85
|
+
rowIndex += 1;
|
|
86
|
+
var collectionHeadingIndex = 0;
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
88
|
+
key: fieldId,
|
|
89
|
+
className: classes('field'),
|
|
90
|
+
style: {
|
|
91
|
+
'--column': columnIndex + 1,
|
|
92
|
+
'--row': rowIndex
|
|
93
|
+
}
|
|
94
|
+
}, collectionRows.map(function (subComponent) {
|
|
95
|
+
var _entryData$component$2;
|
|
96
|
+
// Put value for current subComponent at the top level
|
|
97
|
+
var modEntry = _objectSpread(_objectSpread({}, entryData), _defineProperty({}, subComponent.fieldId, (_entryData$component$2 = entryData[component.fieldId]) === null || _entryData$component$2 === void 0 ? void 0 : _entryData$component$2[subComponent.fieldId]));
|
|
98
|
+
var rowContent = (0, _getSummaryListRowForDetails.default)(childPage, _objectSpread(_objectSpread({}, subComponent), {
|
|
99
|
+
label: subComponent.key
|
|
100
|
+
}), classes, modEntry, optionalFieldPlaceholder);
|
|
101
|
+
// Because collections are flat, we need to identify the subsequent titles (2, 3, 4... etc) in order to apply appropriate spacing
|
|
102
|
+
if (subComponent.type === 'title') {
|
|
103
|
+
collectionHeadingIndex += 1;
|
|
104
|
+
if (collectionHeadingIndex > 1) {
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
106
|
+
style: {
|
|
107
|
+
marginTop: '40px'
|
|
108
|
+
}
|
|
109
|
+
}, rowContent);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return rowContent;
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
60
115
|
rowIndex += 1;
|
|
61
116
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
62
117
|
key: fieldId,
|
|
@@ -65,24 +120,8 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
65
120
|
'--column': columnIndex + 1,
|
|
66
121
|
'--row': rowIndex
|
|
67
122
|
}
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
// Put value for current subcomponent at top level
|
|
71
|
-
var modEntry = _objectSpread(_objectSpread({}, entryData), _defineProperty({}, subComponent.fieldId, (_entryData$component$ = entryData[component.fieldId]) === null || _entryData$component$ === void 0 ? void 0 : _entryData$component$[subComponent.fieldId]));
|
|
72
|
-
return (0, _getComponentRowForCYA.default)(childPage, _objectSpread(_objectSpread({}, subComponent), {
|
|
73
|
-
label: subComponent.key
|
|
74
|
-
}), classes, modEntry);
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
rowIndex += 1;
|
|
78
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
-
key: fieldId,
|
|
80
|
-
className: classes('field'),
|
|
81
|
-
style: {
|
|
82
|
-
'--column': columnIndex + 1,
|
|
83
|
-
'--row': rowIndex
|
|
84
|
-
}
|
|
85
|
-
}, (0, _getComponentRowForCYA.default)(childPage, component, classes, entryData));
|
|
123
|
+
}, (0, _getSummaryListRowForDetails.default)(childPage, component, classes, entryData, optionalFieldPlaceholder));
|
|
124
|
+
});
|
|
86
125
|
}).filter(function (e) {
|
|
87
126
|
return !!e;
|
|
88
127
|
});
|
|
@@ -90,7 +129,7 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
90
129
|
// then we stick a divider on it's right side. The divider isn't
|
|
91
130
|
// passed rowIndex as it spans all rows. columnIndex is incremented
|
|
92
131
|
// twice to account for the divider column too.
|
|
93
|
-
var lastColumn = index ===
|
|
132
|
+
var lastColumn = index === columns.length - 1;
|
|
94
133
|
if (!lastColumn && columnContent.length !== 0) {
|
|
95
134
|
columnIndex += 2;
|
|
96
135
|
return [].concat(columnContent, [/*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -135,17 +174,20 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
|
|
|
135
174
|
}
|
|
136
175
|
return null;
|
|
137
176
|
}
|
|
177
|
+
var columns = section.columns.filter(function (column) {
|
|
178
|
+
return _Condition.default.meetsAll(column, _objectSpread(_objectSpread({}, childPage.formData), entryData));
|
|
179
|
+
});
|
|
138
180
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
139
181
|
key: section.title,
|
|
140
182
|
className: classes('section')
|
|
141
183
|
}, !hideChildSectionTitles && /*#__PURE__*/_react.default.createElement("h3", {
|
|
142
184
|
className: classes('section-title')
|
|
143
|
-
}, section.title), /*#__PURE__*/_react.default.createElement("div", {
|
|
185
|
+
}, _utils.default.FormPage.getConditionalText(section.title, _objectSpread(_objectSpread({}, childPage.formData), entryData))), /*#__PURE__*/_react.default.createElement("div", {
|
|
144
186
|
className: classes('section-content'),
|
|
145
187
|
style: {
|
|
146
|
-
'--dividers':
|
|
188
|
+
'--dividers': columns.length - 1
|
|
147
189
|
}
|
|
148
|
-
}, getSectionContent(
|
|
190
|
+
}, getSectionContent(columns, allPageComponents, childPage)));
|
|
149
191
|
});
|
|
150
192
|
}).filter(function (e) {
|
|
151
193
|
return !!e;
|
|
@@ -159,11 +201,13 @@ SummaryCardDetails.propTypes = {
|
|
|
159
201
|
formData: _propTypes.default.shape({}).isRequired,
|
|
160
202
|
entryData: _propTypes.default.shape({}).isRequired,
|
|
161
203
|
classModifiers: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
162
|
-
hideChildSectionTitles: _propTypes.default.bool
|
|
204
|
+
hideChildSectionTitles: _propTypes.default.bool,
|
|
205
|
+
optionalFieldPlaceholder: _propTypes.default.string
|
|
163
206
|
};
|
|
164
207
|
SummaryCardDetails.defaultProps = {
|
|
165
208
|
childCollections: [],
|
|
166
209
|
classModifiers: null,
|
|
167
|
-
hideChildSectionTitles: false
|
|
210
|
+
hideChildSectionTitles: false,
|
|
211
|
+
optionalFieldPlaceholder: null
|
|
168
212
|
};
|
|
169
213
|
var _default = exports.default = SummaryCardDetails;
|
|
@@ -15,6 +15,10 @@ $govuk-font-family: 'Roboto', arial, sans-serif;
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
&__field {
|
|
19
|
+
margin-bottom: govuk-spacing(6);
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
&__key {
|
|
19
23
|
font-weight: bold;
|
|
20
24
|
margin: govuk-spacing(2) 0 govuk-spacing(1) 0;
|
|
@@ -153,6 +157,11 @@ $govuk-font-family: 'Roboto', arial, sans-serif;
|
|
|
153
157
|
|
|
154
158
|
@media (max-width: 640px) {
|
|
155
159
|
.hods-form-summary-card-details {
|
|
160
|
+
|
|
161
|
+
&__title {
|
|
162
|
+
margin-top: govuk-spacing(8)
|
|
163
|
+
}
|
|
164
|
+
|
|
156
165
|
&__section {
|
|
157
166
|
&-content {
|
|
158
167
|
display: block;
|