@ukhomeoffice/cop-react-form-renderer 4.66.1 → 4.68.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 +6 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +104 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +26 -64
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +428 -555
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +13 -42
- package/dist/components/CollectionPage/CollectionPage.test.js +160 -206
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +35 -79
- package/dist/components/FormComponent/Collection.test.js +340 -391
- package/dist/components/FormComponent/Container.js +10 -31
- package/dist/components/FormComponent/Container.test.js +304 -357
- package/dist/components/FormComponent/FormComponent.js +17 -60
- package/dist/components/FormComponent/FormComponent.test.js +190 -228
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +21 -53
- package/dist/components/FormPage/FormPage.test.js +122 -160
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -296
- package/dist/components/FormRenderer/FormRenderer.test.js +820 -1058
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +4 -12
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +4 -7
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +32 -41
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/FormRenderer/onCYAAction.js +8 -30
- package/dist/components/FormRenderer/onCYAAction.test.js +54 -79
- package/dist/components/FormRenderer/onPageAction.js +123 -0
- package/dist/components/FormRenderer/onPageAction.test.js +632 -0
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/ActionButton.test.js +58 -81
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/PageActions.test.js +95 -120
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +5 -26
- package/dist/components/SummaryList/GroupAction.test.js +14 -28
- package/dist/components/SummaryList/RowAction.js +5 -25
- package/dist/components/SummaryList/RowAction.test.js +14 -28
- package/dist/components/SummaryList/SummaryList.js +7 -31
- package/dist/components/SummaryList/SummaryList.test.js +69 -126
- package/dist/components/SummaryList/SummaryListHeadingRow.js +3 -8
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +9 -31
- package/dist/components/TaskList/Task.test.js +32 -59
- package/dist/components/TaskList/TaskList.js +32 -59
- package/dist/components/TaskList/TaskList.test.js +52 -90
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/TaskState.test.js +23 -41
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -7
- package/dist/context/HooksContext/HooksContext.js +21 -39
- package/dist/context/HooksContext/HooksContext.test.js +18 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +26 -56
- package/dist/context/ValidationContext/ValidationContext.test.js +43 -64
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +17 -36
- package/dist/hooks/useGetRequest.js +57 -93
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +14 -41
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -9
- package/dist/models/PageAction.js +4 -4
- package/dist/models/TaskStates.js +4 -4
- package/dist/models/index.js +1 -10
- package/dist/setupTests.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +1 -19
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +4 -11
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +4 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +8 -23
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +6 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +2 -9
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +4 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +7 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +4 -32
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +4 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +4 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +4 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +7 -25
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +9 -12
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +41 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +4 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +5 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +1 -2
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +5 -11
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +1 -2
- package/dist/utils/Component/addShowWhen.js +4 -10
- package/dist/utils/Component/addShowWhen.test.js +1 -2
- package/dist/utils/Component/applyToComponentTree.js +4 -18
- package/dist/utils/Component/applyToComponentTree.test.js +4 -8
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/cleanAttributes.test.js +15 -16
- package/dist/utils/Component/elevateNestedComponents.js +0 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -2
- package/dist/utils/Component/getComponent.js +7 -86
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +33 -51
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +12 -29
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +6 -24
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +5 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +10 -34
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +12 -31
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +4 -8
- package/dist/utils/Component/getDefaultValue.test.js +0 -3
- package/dist/utils/Component/index.js +0 -10
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/isEditable.test.js +1 -5
- package/dist/utils/Component/setupContainerComponentsPath.js +4 -9
- package/dist/utils/Component/setupContainerComponentsPath.test.js +0 -3
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/showComponent.test.js +1 -2
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +1 -2
- package/dist/utils/Condition/meetsCondition.js +9 -34
- package/dist/utils/Condition/meetsCondition.test.js +21 -14
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/meetsOneCondition.test.js +1 -2
- package/dist/utils/Condition/setupConditions.js +4 -13
- package/dist/utils/Condition/setupConditions.test.js +0 -2
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/getEditableComponents.test.js +1 -12
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +4 -12
- package/dist/utils/Container/setupNesting.test.js +4 -10
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Container/showContainer.test.js +1 -2
- package/dist/utils/Data/applyFormula.js +6 -29
- package/dist/utils/Data/applyFormula.test.js +1 -2
- package/dist/utils/Data/getAutocompleteSource.js +1 -5
- package/dist/utils/Data/getAutocompleteSource.test.js +1 -2
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getDataPath.test.js +0 -4
- package/dist/utils/Data/getOptions.js +4 -14
- package/dist/utils/Data/getOptions.test.js +1 -2
- package/dist/utils/Data/getSourceData.js +6 -21
- package/dist/utils/Data/getSourceData.test.js +4 -6
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +5 -13
- package/dist/utils/Data/refDataToOptions.test.js +1 -2
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setDataItem.test.js +0 -2
- package/dist/utils/Data/setupFormData.js +6 -25
- package/dist/utils/Data/setupFormData.test.js +8 -11
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -15
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +1 -3
- package/dist/utils/FormPage/applyConditionalProperties.js +4 -11
- package/dist/utils/FormPage/applyConditionalProperties.test.js +4 -6
- package/dist/utils/FormPage/getFormPage.js +4 -16
- package/dist/utils/FormPage/getFormPage.test.js +10 -9
- package/dist/utils/FormPage/getFormPages.js +4 -9
- package/dist/utils/FormPage/getFormPages.test.js +6 -7
- package/dist/utils/FormPage/getPageActions.js +6 -19
- package/dist/utils/FormPage/getPageActions.test.js +1 -3
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/getParagraphFromText.test.js +1 -3
- package/dist/utils/FormPage/index.js +0 -7
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPage.test.js +0 -2
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -2
- package/dist/utils/FormPage/useComponent.js +7 -19
- package/dist/utils/FormPage/useComponent.test.js +4 -7
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatData.test.js +1 -2
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForComponent.test.js +28 -47
- package/dist/utils/Format/formatDataForForm.js +4 -9
- package/dist/utils/Format/formatDataForForm.test.js +14 -11
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/formatDataForPage.test.js +15 -12
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/getFormHub.test.js +6 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +4 -10
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentsForField.js +4 -11
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +4 -16
- package/dist/utils/Meta/index.js +1 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -2
- package/dist/utils/Operate/getFirstOf.js +2 -9
- package/dist/utils/Operate/getFirstOf.test.js +0 -2
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +6 -2
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -4
- package/dist/utils/Operate/runPageOperations.js +3 -19
- package/dist/utils/Operate/runPageOperations.test.js +4 -6
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/setValueInFormData.test.js +0 -2
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Operate/shouldRun.test.js +5 -8
- package/dist/utils/Validate/additional/conditionallyRequired.js +0 -3
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +0 -2
- package/dist/utils/Validate/additional/index.js +1 -22
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +4 -8
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -3
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -5
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +0 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +0 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +0 -6
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +4 -7
- package/dist/utils/Validate/additional/utils.js +10 -26
- package/dist/utils/Validate/index.js +1 -11
- package/dist/utils/Validate/validateCollection.js +4 -10
- package/dist/utils/Validate/validateCollection.test.js +4 -6
- package/dist/utils/Validate/validateComponent.js +2 -39
- package/dist/utils/Validate/validateComponent.test.js +4 -22
- package/dist/utils/Validate/validateContainer.js +4 -14
- package/dist/utils/Validate/validateContainer.test.js +4 -10
- package/dist/utils/Validate/validateDate.js +6 -38
- package/dist/utils/Validate/validateDate.test.js +0 -4
- package/dist/utils/Validate/validateEmail.js +1 -8
- package/dist/utils/Validate/validateEmail.test.js +5 -4
- package/dist/utils/Validate/validateMultifile.js +0 -7
- package/dist/utils/Validate/validateMultifile.test.js +5 -6
- package/dist/utils/Validate/validatePage.js +4 -16
- package/dist/utils/Validate/validatePage.test.js +30 -25
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRegex.test.js +5 -4
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateRequired.test.js +5 -4
- package/dist/utils/Validate/validateTextArea.js +0 -8
- package/dist/utils/Validate/validateTextArea.test.js +0 -2
- package/dist/utils/Validate/validateTime.js +5 -22
- package/dist/utils/Validate/validateTime.test.js +0 -2
- package/dist/utils/index.js +4 -20
- package/package.json +2 -2
|
@@ -4,30 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _models = require("../../models");
|
|
11
|
-
|
|
12
9
|
var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
|
|
13
|
-
|
|
14
10
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
15
|
-
|
|
16
11
|
var _setupContainerComponentsPath = _interopRequireDefault(require("../Component/setupContainerComponentsPath"));
|
|
17
|
-
|
|
18
12
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
14
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
22
15
|
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; }
|
|
23
|
-
|
|
24
16
|
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; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
20
|
var getEntryToCollectionRow = function getEntryToCollectionRow(page, onAction) {
|
|
29
21
|
var _page$components$0$la;
|
|
30
|
-
|
|
31
22
|
return [{
|
|
32
23
|
pageId: page.id,
|
|
33
24
|
key: ((_page$components$0$la = page.components[0].labels) === null || _page$components$0$la === void 0 ? void 0 : _page$components$0$la.empty) || 'Nothing entered',
|
|
@@ -35,7 +26,6 @@ var getEntryToCollectionRow = function getEntryToCollectionRow(page, onAction) {
|
|
|
35
26
|
action: (0, _getCYAAction.default)(false, page, onAction)
|
|
36
27
|
}];
|
|
37
28
|
};
|
|
38
|
-
|
|
39
29
|
var getContainerForItem = function getContainerForItem(collection, item, labelCount, full_path) {
|
|
40
30
|
return {
|
|
41
31
|
id: item.id,
|
|
@@ -53,10 +43,8 @@ var getContainerForItem = function getContainerForItem(collection, item, labelCo
|
|
|
53
43
|
})
|
|
54
44
|
};
|
|
55
45
|
};
|
|
56
|
-
|
|
57
46
|
var getTitleRowForItem = function getTitleRowForItem(collection, item, pageId, labelCount, full_path) {
|
|
58
47
|
var labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), collection.labels);
|
|
59
|
-
|
|
60
48
|
if (labels.item) {
|
|
61
49
|
return {
|
|
62
50
|
pageId: pageId,
|
|
@@ -69,10 +57,8 @@ var getTitleRowForItem = function getTitleRowForItem(collection, item, pageId, l
|
|
|
69
57
|
action: null
|
|
70
58
|
};
|
|
71
59
|
}
|
|
72
|
-
|
|
73
60
|
return null;
|
|
74
61
|
};
|
|
75
|
-
|
|
76
62
|
var getCYARowsForCollection = function getCYARowsForCollection(page, collection, items, onAction) {
|
|
77
63
|
if (Array.isArray(items) && items.length && (0, _showComponentCYA.default)(collection, page.formData)) {
|
|
78
64
|
return items.flatMap(function (item, index) {
|
|
@@ -85,9 +71,7 @@ var getCYARowsForCollection = function getCYARowsForCollection(page, collection,
|
|
|
85
71
|
return !!r;
|
|
86
72
|
});
|
|
87
73
|
}
|
|
88
|
-
|
|
89
74
|
return getEntryToCollectionRow(page, onAction);
|
|
90
75
|
};
|
|
91
|
-
|
|
92
76
|
var _default = getCYARowsForCollection;
|
|
93
77
|
exports.default = _default;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
|
-
|
|
5
4
|
var _setupTests = require("../../setupTests");
|
|
6
|
-
|
|
7
5
|
var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
|
|
8
|
-
|
|
9
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
11
8
|
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; }
|
|
12
|
-
|
|
13
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; }
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
13
|
describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
18
14
|
it('should get a single entry point row when there are no items', function () {
|
|
19
15
|
var FORM_DATA = undefined;
|
|
@@ -40,9 +36,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
40
36
|
type: _models.ComponentTypes.COLLECTION,
|
|
41
37
|
item: [COMPONENT]
|
|
42
38
|
};
|
|
43
|
-
|
|
44
39
|
var ON_ACTION = function ON_ACTION() {};
|
|
45
|
-
|
|
46
40
|
var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, undefined, ON_ACTION);
|
|
47
41
|
expect(ROWS.length).toEqual(1);
|
|
48
42
|
});
|
|
@@ -73,12 +67,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
73
67
|
value: FORM_DATA.collection,
|
|
74
68
|
formData: FORM_DATA
|
|
75
69
|
};
|
|
76
|
-
|
|
77
70
|
var ON_ACTION = function ON_ACTION() {};
|
|
78
|
-
|
|
79
71
|
var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
|
|
80
72
|
expect(ROWS.length).toEqual(2); // Item title row + component row
|
|
81
|
-
|
|
82
73
|
(0, _setupTests.expectObjectLike)(ROWS[0], {
|
|
83
74
|
pageId: PAGE.id,
|
|
84
75
|
fieldId: COLLECTION.fieldId,
|
|
@@ -130,12 +121,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
130
121
|
value: FORM_DATA.collection,
|
|
131
122
|
formData: FORM_DATA
|
|
132
123
|
};
|
|
133
|
-
|
|
134
124
|
var ON_ACTION = function ON_ACTION() {};
|
|
135
|
-
|
|
136
125
|
var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
|
|
137
126
|
expect(ROWS.length).toEqual(1); // Just the component row, no title row
|
|
138
|
-
|
|
139
127
|
(0, _setupTests.expectObjectLike)(ROWS[0], {
|
|
140
128
|
pageId: PAGE.id,
|
|
141
129
|
fieldId: COMPONENT.fieldId,
|
|
@@ -158,8 +146,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
158
146
|
id: 'page',
|
|
159
147
|
formData: FORM_DATA,
|
|
160
148
|
cya_link: {}
|
|
161
|
-
};
|
|
162
|
-
|
|
149
|
+
};
|
|
150
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
163
151
|
var COMPONENT = {
|
|
164
152
|
type: 'text',
|
|
165
153
|
readonly: true,
|
|
@@ -175,12 +163,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
175
163
|
value: FORM_DATA.collection,
|
|
176
164
|
formData: FORM_DATA
|
|
177
165
|
};
|
|
178
|
-
|
|
179
166
|
var ON_ACTION = function ON_ACTION() {};
|
|
180
|
-
|
|
181
167
|
var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
|
|
182
168
|
expect(ROWS.length).toEqual(2); // Title and item row.
|
|
183
|
-
|
|
184
169
|
(0, _setupTests.expectObjectLike)(ROWS[1], {
|
|
185
170
|
pageId: PAGE.id,
|
|
186
171
|
fieldId: COMPONENT.fieldId,
|
|
@@ -191,8 +176,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
191
176
|
component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
|
|
192
177
|
full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
|
|
193
178
|
label: 'Alpha 1' // no countOffset
|
|
194
|
-
|
|
195
179
|
}),
|
|
180
|
+
|
|
196
181
|
value: 'Bravo'
|
|
197
182
|
});
|
|
198
183
|
});
|
|
@@ -4,29 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
|
-
|
|
10
8
|
var _models = require("../../models");
|
|
11
|
-
|
|
12
9
|
var _addShowWhen = _interopRequireDefault(require("../Component/addShowWhen"));
|
|
13
|
-
|
|
14
10
|
var _showFormPageCYA = _interopRequireDefault(require("../FormPage/showFormPageCYA"));
|
|
15
|
-
|
|
16
11
|
var _getCYACollectionDeleteAction = _interopRequireDefault(require("./getCYACollectionDeleteAction"));
|
|
17
|
-
|
|
18
12
|
var _getCYACollectionChangeAction = _interopRequireDefault(require("./getCYACollectionChangeAction"));
|
|
19
|
-
|
|
20
13
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
15
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
24
16
|
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; }
|
|
25
|
-
|
|
26
17
|
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; }
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
18
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
21
|
var getContainerForPage = function getContainerForPage(page, item, labelCount, full_path) {
|
|
31
22
|
return {
|
|
32
23
|
id: item.id,
|
|
@@ -44,10 +35,8 @@ var getContainerForPage = function getContainerForPage(page, item, labelCount, f
|
|
|
44
35
|
})
|
|
45
36
|
};
|
|
46
37
|
};
|
|
47
|
-
|
|
48
38
|
var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCount, full_path) {
|
|
49
39
|
var labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), page.collection.labels);
|
|
50
|
-
|
|
51
40
|
return {
|
|
52
41
|
pageId: pageId,
|
|
53
42
|
fieldId: 'Title',
|
|
@@ -59,12 +48,10 @@ var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCo
|
|
|
59
48
|
size: page.collection.titleSize || 's'
|
|
60
49
|
};
|
|
61
50
|
};
|
|
62
|
-
|
|
63
51
|
var getHeadingRow = function getHeadingRow(config, pageId, labelCount) {
|
|
64
52
|
if (config.text === '') {
|
|
65
53
|
return null;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
return {
|
|
69
56
|
pageId: pageId,
|
|
70
57
|
fieldId: "heading".concat(labelCount),
|
|
@@ -74,10 +61,8 @@ var getHeadingRow = function getHeadingRow(config, pageId, labelCount) {
|
|
|
74
61
|
size: config.size || 's'
|
|
75
62
|
};
|
|
76
63
|
};
|
|
77
|
-
|
|
78
64
|
var getActionRows = function getActionRows(page, item, onAction, labelCount) {
|
|
79
65
|
var _page$collection, _page$collection$acti;
|
|
80
|
-
|
|
81
66
|
var actions = (_page$collection = page.collection) === null || _page$collection === void 0 ? void 0 : (_page$collection$acti = _page$collection.actions) === null || _page$collection$acti === void 0 ? void 0 : _page$collection$acti.map(function (action) {
|
|
82
67
|
if (action.type === 'remove') {
|
|
83
68
|
return (0, _getCYACollectionDeleteAction.default)(page, item, onAction, labelCount, action);
|
|
@@ -91,25 +76,20 @@ var getActionRows = function getActionRows(page, item, onAction, labelCount) {
|
|
|
91
76
|
});
|
|
92
77
|
return actions;
|
|
93
78
|
};
|
|
94
|
-
|
|
95
79
|
var getChangeActionForPage = function getChangeActionForPage(page, item, onAction) {
|
|
96
80
|
return function () {
|
|
97
81
|
var changeCallback = function changeCallback(data) {
|
|
98
82
|
data["".concat(page.collection.name, "ActiveId")] = item.id;
|
|
99
83
|
return data;
|
|
100
84
|
};
|
|
101
|
-
|
|
102
85
|
onAction({
|
|
103
86
|
pageId: page.id
|
|
104
87
|
}, changeCallback);
|
|
105
88
|
};
|
|
106
89
|
};
|
|
107
|
-
|
|
108
90
|
var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onAction) {
|
|
109
91
|
var _page$formData, _page$formData$page$c;
|
|
110
|
-
|
|
111
92
|
var rows = [];
|
|
112
|
-
|
|
113
93
|
if (!page.collection.hideNameFromCYA) {
|
|
114
94
|
rows.push({
|
|
115
95
|
pageId: page.id,
|
|
@@ -120,40 +100,33 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
|
|
|
120
100
|
size: 'm'
|
|
121
101
|
});
|
|
122
102
|
}
|
|
123
|
-
|
|
124
103
|
(_page$formData = page.formData) === null || _page$formData === void 0 ? void 0 : (_page$formData$page$c = _page$formData[page.collection.name]) === null || _page$formData$page$c === void 0 ? void 0 : _page$formData$page$c.forEach(function (item, index) {
|
|
125
104
|
var _page$collection2;
|
|
126
|
-
|
|
127
105
|
var labelCount = index + 1;
|
|
128
106
|
var actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
|
|
129
107
|
var full_path = "".concat(page.collection.name, "[").concat(index, "]");
|
|
130
108
|
var titleRow = getTitleRowForItem(page, item, page.id, labelCount, full_path);
|
|
131
109
|
var actionRows = getActionRows(page, item, onAction, labelCount);
|
|
132
110
|
rows = rows.concat(titleRow);
|
|
133
|
-
|
|
134
111
|
if (actionPosition === 'top') {
|
|
135
112
|
rows = rows.concat(actionRows);
|
|
136
113
|
}
|
|
137
|
-
|
|
138
114
|
page.collectionPages.forEach(function (p) {
|
|
139
115
|
if (p.collection.route) {
|
|
140
116
|
var pageWithRoute = (0, _addShowWhen.default)(p, p.collection.route);
|
|
141
117
|
p = pageWithRoute || p;
|
|
142
118
|
}
|
|
143
|
-
|
|
144
119
|
if ((0, _showFormPageCYA.default)(p, _objectSpread(_objectSpread({}, p.formData), item))) {
|
|
145
120
|
if (p.collection.heading) {
|
|
146
121
|
var headingRow = getHeadingRow(p.collection.heading, p.id, labelCount);
|
|
147
122
|
rows = rows.concat(headingRow);
|
|
148
123
|
}
|
|
149
|
-
|
|
150
124
|
var container = getContainerForPage(p, item, labelCount, full_path);
|
|
151
125
|
var rowChangeAction = getChangeActionForPage(p, item, onAction);
|
|
152
126
|
var containerRows = (0, _getCYARowsForContainer.default)(p, container, item, rowChangeAction);
|
|
153
127
|
rows = rows.concat(containerRows);
|
|
154
128
|
}
|
|
155
129
|
});
|
|
156
|
-
|
|
157
130
|
if (actionPosition === 'bottom') {
|
|
158
131
|
rows = rows.concat(actionRows);
|
|
159
132
|
}
|
|
@@ -162,6 +135,5 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
|
|
|
162
135
|
return !!row;
|
|
163
136
|
});
|
|
164
137
|
};
|
|
165
|
-
|
|
166
138
|
var _default = getCYARowsForCollectionPage;
|
|
167
139
|
exports.default = _default;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
5
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
7
6
|
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
7
|
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
|
|
12
|
-
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
11
|
describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
14
12
|
var TEXT_COMP = {
|
|
15
13
|
id: 'testText',
|
|
@@ -59,25 +57,21 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
59
57
|
};
|
|
60
58
|
it('should return just a heading for the collection if it has no entries', function () {
|
|
61
59
|
var FORM_DATA = {};
|
|
62
|
-
|
|
63
60
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
64
61
|
formData: FORM_DATA
|
|
65
62
|
});
|
|
66
|
-
|
|
67
63
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
68
64
|
expect(ROWS.length).toEqual(1);
|
|
69
65
|
expect(ROWS[0].key).toEqual('Collection');
|
|
70
66
|
});
|
|
71
67
|
it('should accept the hideNameFromCYA collection flag', function () {
|
|
72
68
|
var FORM_DATA = {};
|
|
73
|
-
|
|
74
69
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
75
70
|
formData: FORM_DATA,
|
|
76
71
|
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
77
72
|
hideNameFromCYA: true
|
|
78
73
|
})
|
|
79
74
|
});
|
|
80
|
-
|
|
81
75
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
82
76
|
expect(ROWS.length).toEqual(0);
|
|
83
77
|
});
|
|
@@ -88,14 +82,11 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
88
82
|
testText: 'value'
|
|
89
83
|
}]
|
|
90
84
|
};
|
|
91
|
-
|
|
92
85
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
93
86
|
formData: FORM_DATA
|
|
94
87
|
});
|
|
95
|
-
|
|
96
88
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
97
89
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
98
|
-
|
|
99
90
|
expect(ROWS[1].key).toEqual('Collection entry 1');
|
|
100
91
|
});
|
|
101
92
|
it('should provide default titles if collection.labels.item is not specified', function () {
|
|
@@ -105,17 +96,14 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
105
96
|
testText: 'value'
|
|
106
97
|
}]
|
|
107
98
|
};
|
|
108
|
-
|
|
109
99
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
110
100
|
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
111
101
|
labels: {}
|
|
112
102
|
}),
|
|
113
103
|
formData: FORM_DATA
|
|
114
104
|
});
|
|
115
|
-
|
|
116
105
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
117
106
|
expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
|
|
118
|
-
|
|
119
107
|
expect(ROWS[1].key).toEqual('Item 1');
|
|
120
108
|
});
|
|
121
109
|
it('should return correctly formatted rows for mutliple entries', function () {
|
|
@@ -128,14 +116,11 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
128
116
|
testText: 'value'
|
|
129
117
|
}]
|
|
130
118
|
};
|
|
131
|
-
|
|
132
119
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
133
120
|
formData: FORM_DATA
|
|
134
121
|
});
|
|
135
|
-
|
|
136
122
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
137
123
|
expect(ROWS.length).toEqual(13); // Title row + component row for each item
|
|
138
|
-
|
|
139
124
|
expect(ROWS[0]).toMatchObject({
|
|
140
125
|
type: 'heading',
|
|
141
126
|
key: 'Collection'
|
|
@@ -183,7 +168,6 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
183
168
|
testText: 'testing'
|
|
184
169
|
}]
|
|
185
170
|
};
|
|
186
|
-
|
|
187
171
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
188
172
|
collection: {
|
|
189
173
|
name: 'collection'
|
|
@@ -203,7 +187,6 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
203
187
|
}]
|
|
204
188
|
})]
|
|
205
189
|
});
|
|
206
|
-
|
|
207
190
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
208
191
|
expect(ROWS.length).toEqual(4);
|
|
209
192
|
expect(ROWS[0]).toMatchObject({
|
|
@@ -231,7 +214,6 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
231
214
|
testText: 'testing'
|
|
232
215
|
}]
|
|
233
216
|
};
|
|
234
|
-
|
|
235
217
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
236
218
|
collection: {
|
|
237
219
|
name: 'collection'
|
|
@@ -245,10 +227,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
245
227
|
}
|
|
246
228
|
}), PAGES[1]]
|
|
247
229
|
});
|
|
248
|
-
|
|
249
230
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
250
231
|
expect(ROWS.length).toEqual(3); // Missing the page with the text component on.
|
|
251
|
-
|
|
252
232
|
expect(ROWS[0]).toMatchObject({
|
|
253
233
|
type: 'heading',
|
|
254
234
|
key: 'Collection'
|
|
@@ -269,7 +249,6 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
269
249
|
testText: 'value'
|
|
270
250
|
}]
|
|
271
251
|
};
|
|
272
|
-
|
|
273
252
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
274
253
|
formData: FORM_DATA,
|
|
275
254
|
collectionPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
@@ -281,7 +260,6 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
281
260
|
})
|
|
282
261
|
})]
|
|
283
262
|
});
|
|
284
|
-
|
|
285
263
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
286
264
|
expect(ROWS.length).toEqual(7);
|
|
287
265
|
expect(ROWS[0]).toMatchObject({
|
|
@@ -312,7 +290,6 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
312
290
|
testText: 'value'
|
|
313
291
|
}]
|
|
314
292
|
};
|
|
315
|
-
|
|
316
293
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
317
294
|
formData: FORM_DATA,
|
|
318
295
|
collectionPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
|
|
@@ -323,7 +300,6 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
323
300
|
})
|
|
324
301
|
})]
|
|
325
302
|
});
|
|
326
|
-
|
|
327
303
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
328
304
|
expect(ROWS[5]).toMatchObject({
|
|
329
305
|
type: 'heading',
|
|
@@ -338,11 +314,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
338
314
|
testText: 'value'
|
|
339
315
|
}]
|
|
340
316
|
};
|
|
341
|
-
|
|
342
317
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
343
318
|
formData: FORM_DATA
|
|
344
319
|
});
|
|
345
|
-
|
|
346
320
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
347
321
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
348
322
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
@@ -355,14 +329,12 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
355
329
|
testText: 'value'
|
|
356
330
|
}]
|
|
357
331
|
};
|
|
358
|
-
|
|
359
332
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
360
333
|
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
361
334
|
actionPosition: 'top'
|
|
362
335
|
}),
|
|
363
336
|
formData: FORM_DATA
|
|
364
337
|
});
|
|
365
|
-
|
|
366
338
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
367
339
|
expect(ROWS[2].action.label).toEqual('Change');
|
|
368
340
|
expect(ROWS[3].action.label).toEqual('custom remove label');
|
|
@@ -375,14 +347,12 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
|
|
|
375
347
|
testText: 'value'
|
|
376
348
|
}]
|
|
377
349
|
};
|
|
378
|
-
|
|
379
350
|
var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
|
|
380
351
|
collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
|
|
381
352
|
actionPosition: 'bottom'
|
|
382
353
|
}),
|
|
383
354
|
formData: FORM_DATA
|
|
384
355
|
});
|
|
385
|
-
|
|
386
356
|
var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null);
|
|
387
357
|
expect(ROWS[ROWS.length - 3].action.label).toEqual('Change');
|
|
388
358
|
expect(ROWS[ROWS.length - 2].action.label).toEqual('custom remove label');
|
|
@@ -4,25 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../models");
|
|
9
|
-
|
|
10
8
|
var _elevateNestedComponents = _interopRequireDefault(require("../Component/elevateNestedComponents"));
|
|
11
|
-
|
|
12
9
|
var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
13
|
-
|
|
14
10
|
var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
|
|
15
|
-
|
|
16
11
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
13
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
20
14
|
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; }
|
|
21
|
-
|
|
22
15
|
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; }
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
26
19
|
var getCYARowsForContainer = function getCYARowsForContainer(page, container, formData, onAction) {
|
|
27
20
|
if ((0, _showComponentCYA.default)(container, _objectSpread(_objectSpread({}, page.formData), formData))) {
|
|
28
21
|
var allComponents = (0, _elevateNestedComponents.default)(container.components, formData);
|
|
@@ -30,21 +23,17 @@ var getCYARowsForContainer = function getCYARowsForContainer(page, container, fo
|
|
|
30
23
|
return (0, _showComponentCYA.default)(c, _objectSpread(_objectSpread({}, page.formData), formData));
|
|
31
24
|
}).flatMap(function (component) {
|
|
32
25
|
var fd = formData ? formData[component.fieldId] : undefined;
|
|
33
|
-
|
|
34
26
|
if (component.type === _models.ComponentTypes.CONTAINER) {
|
|
35
27
|
return getCYARowsForContainer(page, component, _objectSpread(_objectSpread({}, fd), formData), onAction);
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
if (component.type === _models.ComponentTypes.COLLECTION) {
|
|
39
30
|
return (0, _getCYARowsForCollection.default)(page, component, fd, onAction);
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
return (0, _getCYARow.default)(_objectSpread(_objectSpread({}, page), {}, {
|
|
43
33
|
formData: formData
|
|
44
34
|
}), component, onAction);
|
|
45
35
|
});
|
|
46
36
|
}
|
|
47
37
|
};
|
|
48
|
-
|
|
49
38
|
var _default = getCYARowsForContainer;
|
|
50
39
|
exports.default = _default;
|