@ukhomeoffice/cop-react-form-renderer 4.67.0 → 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 +2 -15
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +1 -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
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
|
-
|
|
5
4
|
var _setupTests = require("../../setupTests");
|
|
6
|
-
|
|
7
5
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
8
|
-
|
|
9
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
|
|
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); }
|
|
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.getCYARowsForContainer', function () {
|
|
14
12
|
var OUTER_ID = 'a';
|
|
15
13
|
var INNER_ID = 'b';
|
|
@@ -39,9 +37,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
39
37
|
value: FORM_DATA.container,
|
|
40
38
|
formData: FORM_DATA
|
|
41
39
|
};
|
|
42
|
-
|
|
43
40
|
var ON_ACTION = function ON_ACTION() {};
|
|
44
|
-
|
|
45
41
|
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
46
42
|
expect(ROWS.length).toEqual(1);
|
|
47
43
|
ROWS.forEach(function (row, index) {
|
|
@@ -87,9 +83,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
87
83
|
value: FORM_DATA.container,
|
|
88
84
|
formData: FORM_DATA
|
|
89
85
|
};
|
|
90
|
-
|
|
91
86
|
var ON_ACTION = function ON_ACTION() {};
|
|
92
|
-
|
|
93
87
|
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
94
88
|
expect(ROWS.length).toEqual(2);
|
|
95
89
|
ROWS.forEach(function (row, index) {
|
|
@@ -141,9 +135,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
141
135
|
value: FORM_DATA.container,
|
|
142
136
|
formData: FORM_DATA
|
|
143
137
|
};
|
|
144
|
-
|
|
145
138
|
var ON_ACTION = function ON_ACTION() {};
|
|
146
|
-
|
|
147
139
|
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
148
140
|
expect(ROWS.length).toEqual(2);
|
|
149
141
|
ROWS.forEach(function (row, index) {
|
|
@@ -195,9 +187,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
195
187
|
value: FORM_DATA.container,
|
|
196
188
|
formData: FORM_DATA
|
|
197
189
|
};
|
|
198
|
-
|
|
199
190
|
var ON_ACTION = function ON_ACTION() {};
|
|
200
|
-
|
|
201
191
|
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
202
192
|
expect(ROWS.length).toEqual(1);
|
|
203
193
|
ROWS.forEach(function (row, index) {
|
|
@@ -237,9 +227,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
237
227
|
type: _models.ComponentTypes.CONTAINER,
|
|
238
228
|
components: [NESTED_CONTAINER]
|
|
239
229
|
};
|
|
240
|
-
|
|
241
230
|
var ON_ACTION = function ON_ACTION() {};
|
|
242
|
-
|
|
243
231
|
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, undefined, ON_ACTION);
|
|
244
232
|
expect(ROWS.length).toEqual(1);
|
|
245
233
|
ROWS.forEach(function (row, index) {
|
|
@@ -255,7 +243,6 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
255
243
|
});
|
|
256
244
|
it('should get an appropriate row for a collection with a single text component inside a container', function () {
|
|
257
245
|
var FORM_DATA = _defineProperty({}, OUTER_ID, [_defineProperty({}, INNER_ID, 'Bravo'), _defineProperty({}, INNER_ID, 'Charlie')]);
|
|
258
|
-
|
|
259
246
|
var PAGE = {
|
|
260
247
|
id: 'page',
|
|
261
248
|
formData: FORM_DATA,
|
|
@@ -284,7 +271,6 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
284
271
|
};
|
|
285
272
|
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA, function () {});
|
|
286
273
|
expect(ROWS.length).toEqual(4);
|
|
287
|
-
|
|
288
274
|
var checkTitleRow = function checkTitleRow(index, row) {
|
|
289
275
|
expect(row).toEqual({
|
|
290
276
|
pageId: PAGE.id,
|
|
@@ -295,7 +281,6 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
295
281
|
type: 'title'
|
|
296
282
|
});
|
|
297
283
|
};
|
|
298
|
-
|
|
299
284
|
var checkValueRow = function checkValueRow(index, row, value) {
|
|
300
285
|
(0, _setupTests.expectObjectLike)(row, {
|
|
301
286
|
pageId: PAGE.id,
|
|
@@ -313,7 +298,6 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
313
298
|
full_path: "".concat(OUTER_ID, "[").concat(index, "].").concat(INNER_ID)
|
|
314
299
|
});
|
|
315
300
|
};
|
|
316
|
-
|
|
317
301
|
checkTitleRow(0, ROWS[0]);
|
|
318
302
|
checkValueRow(0, ROWS[1], 'Bravo');
|
|
319
303
|
checkTitleRow(1, ROWS[2]);
|
|
@@ -396,9 +380,7 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
|
|
|
396
380
|
value: FORM_DATA.container,
|
|
397
381
|
formData: FORM_DATA
|
|
398
382
|
};
|
|
399
|
-
|
|
400
383
|
var ON_ACTION = function ON_ACTION() {};
|
|
401
|
-
|
|
402
384
|
var ROWS = (0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.container, ON_ACTION);
|
|
403
385
|
expect(ROWS.length).toEqual(2);
|
|
404
386
|
});
|
|
@@ -4,27 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _elevateNestedComponents = _interopRequireDefault(require("../Component/elevateNestedComponents"));
|
|
9
|
-
|
|
10
8
|
var _models = require("../../models");
|
|
11
|
-
|
|
12
9
|
var _FormPage = _interopRequireDefault(require("../FormPage"));
|
|
13
|
-
|
|
14
10
|
var _getCYARow = _interopRequireDefault(require("./getCYARow"));
|
|
15
|
-
|
|
16
11
|
var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
|
|
17
|
-
|
|
18
12
|
var _getCYARowForGroup2 = _interopRequireDefault(require("./getCYARowForGroup"));
|
|
19
|
-
|
|
20
13
|
var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
|
|
21
|
-
|
|
22
14
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
23
|
-
|
|
24
15
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
17
|
// Local imports
|
|
29
18
|
|
|
30
19
|
/**
|
|
@@ -38,11 +27,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
38
27
|
var getCYARowsForPage = function getCYARowsForPage(page, onAction) {
|
|
39
28
|
if (_FormPage.default.showCYA(page, page.formData)) {
|
|
40
29
|
var _page$groups;
|
|
41
|
-
|
|
42
30
|
if (page.collection) {
|
|
43
31
|
return (0, _getCYARowsForCollectionPage.default)(page, onAction);
|
|
44
32
|
}
|
|
45
|
-
|
|
46
33
|
var allComponents = (0, _elevateNestedComponents.default)(page.components, page.formData);
|
|
47
34
|
var rows = allComponents.filter(function (c) {
|
|
48
35
|
return (0, _showComponentCYA.default)(c, page.formData);
|
|
@@ -50,21 +37,17 @@ var getCYARowsForPage = function getCYARowsForPage(page, onAction) {
|
|
|
50
37
|
switch (component.type) {
|
|
51
38
|
case _models.ComponentTypes.CONTAINER:
|
|
52
39
|
return (0, _getCYARowsForContainer.default)(page, component, page.formData[component.fieldId], onAction);
|
|
53
|
-
|
|
54
40
|
case _models.ComponentTypes.COLLECTION:
|
|
55
41
|
return (0, _getCYARowsForCollection.default)(page, component, page.formData[component.fieldId], onAction);
|
|
56
|
-
|
|
57
42
|
default:
|
|
58
43
|
return (0, _getCYARow.default)(page, component, onAction);
|
|
59
44
|
}
|
|
60
45
|
});
|
|
61
|
-
|
|
62
46
|
if (((_page$groups = page.groups) === null || _page$groups === void 0 ? void 0 : _page$groups.length) > 0) {
|
|
63
47
|
page.groups.forEach(function (group) {
|
|
64
48
|
var _getCYARowForGroup = (0, _getCYARowForGroup2.default)(page, group, rows, onAction),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
row = _getCYARowForGroup.row,
|
|
50
|
+
insertAt = _getCYARowForGroup.insertAt;
|
|
68
51
|
if (insertAt > -1) {
|
|
69
52
|
rows.splice(insertAt, 0, row);
|
|
70
53
|
} else {
|
|
@@ -78,12 +61,9 @@ var getCYARowsForPage = function getCYARowsForPage(page, onAction) {
|
|
|
78
61
|
return !allReplacedIds.includes(r.id);
|
|
79
62
|
});
|
|
80
63
|
}
|
|
81
|
-
|
|
82
64
|
return rows;
|
|
83
65
|
}
|
|
84
|
-
|
|
85
66
|
return [];
|
|
86
67
|
};
|
|
87
|
-
|
|
88
68
|
var _default = getCYARowsForPage;
|
|
89
69
|
exports.default = _default;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _setupTests = require("../../setupTests");
|
|
4
|
-
|
|
5
4
|
var _models = require("../../models");
|
|
6
|
-
|
|
7
5
|
var _getCYARowsForPage = _interopRequireDefault(require("./getCYARowsForPage"));
|
|
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', function () {
|
|
18
14
|
describe('CheckYourAnswers', function () {
|
|
19
15
|
describe('getCYARowsForPage', function () {
|
|
@@ -32,9 +28,7 @@ describe('utils', function () {
|
|
|
32
28
|
a: 'Bravo'
|
|
33
29
|
}
|
|
34
30
|
};
|
|
35
|
-
|
|
36
31
|
var ON_ACTION = function ON_ACTION() {};
|
|
37
|
-
|
|
38
32
|
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
39
33
|
expect(ROWS.length).toEqual(1);
|
|
40
34
|
ROWS.forEach(function (row, index) {
|
|
@@ -70,9 +64,7 @@ describe('utils', function () {
|
|
|
70
64
|
},
|
|
71
65
|
cya_link: {}
|
|
72
66
|
};
|
|
73
|
-
|
|
74
67
|
var ON_ACTION = function ON_ACTION() {};
|
|
75
|
-
|
|
76
68
|
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
77
69
|
expect(ROWS.length).toEqual(2);
|
|
78
70
|
ROWS.forEach(function (row, index) {
|
|
@@ -114,9 +106,7 @@ describe('utils', function () {
|
|
|
114
106
|
},
|
|
115
107
|
cya_link: {}
|
|
116
108
|
};
|
|
117
|
-
|
|
118
109
|
var ON_ACTION = function ON_ACTION() {};
|
|
119
|
-
|
|
120
110
|
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
121
111
|
expect(ROWS.length).toEqual(2);
|
|
122
112
|
ROWS.forEach(function (row, index) {
|
|
@@ -158,9 +148,7 @@ describe('utils', function () {
|
|
|
158
148
|
components: [CONTAINER],
|
|
159
149
|
formData: FORM_DATA
|
|
160
150
|
};
|
|
161
|
-
|
|
162
151
|
var ON_ACTION = function ON_ACTION() {};
|
|
163
|
-
|
|
164
152
|
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
165
153
|
expect(ROWS.length).toEqual(1);
|
|
166
154
|
ROWS.forEach(function (row, index) {
|
|
@@ -217,14 +205,11 @@ describe('utils', function () {
|
|
|
217
205
|
postCode: 'SW1A 2AA'
|
|
218
206
|
}
|
|
219
207
|
};
|
|
220
|
-
|
|
221
208
|
var ON_ACTION = function ON_ACTION() {};
|
|
222
|
-
|
|
223
209
|
var _renderWithValidation = (0, _setupTests.renderWithValidation)((0, _getCYARowsForPage.default)(PAGE, ON_ACTION).map(function (row) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
210
|
+
return row.value;
|
|
211
|
+
})),
|
|
212
|
+
container = _renderWithValidation.container;
|
|
228
213
|
expect(container.childNodes.length).toEqual(4);
|
|
229
214
|
var addressValues = container.childNodes;
|
|
230
215
|
expect(addressValues[0].childNodes[0].textContent).toEqual('10 Downing Street');
|
|
@@ -258,12 +243,9 @@ describe('utils', function () {
|
|
|
258
243
|
components: [COLLECTION],
|
|
259
244
|
formData: FORM_DATA
|
|
260
245
|
};
|
|
261
|
-
|
|
262
246
|
var ON_ACTION = function ON_ACTION() {};
|
|
263
|
-
|
|
264
247
|
var ROWS = (0, _getCYARowsForPage.default)(PAGE, ON_ACTION);
|
|
265
248
|
expect(ROWS.length).toEqual(2); // Title and item row
|
|
266
|
-
|
|
267
249
|
(0, _setupTests.expectObjectLike)(ROWS[1], {
|
|
268
250
|
pageId: PAGE.id,
|
|
269
251
|
fieldId: COMPONENT.fieldId,
|
|
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getCYARowsForPage = _interopRequireDefault(require("./getCYARowsForPage"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
// Local imports
|
|
10
|
+
|
|
13
11
|
var CheckYourAnswers = {
|
|
14
12
|
getRows: _getCYARowsForPage.default
|
|
15
13
|
};
|
|
@@ -4,19 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.EXCLUDE_FROM_CYA = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../models");
|
|
9
|
-
|
|
10
8
|
var _Component = _interopRequireDefault(require("../Component"));
|
|
11
|
-
|
|
12
9
|
var _Container = _interopRequireDefault(require("../Container"));
|
|
13
|
-
|
|
14
10
|
var _getSourceData = _interopRequireDefault(require("../Data/getSourceData"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
// Local imports
|
|
13
|
+
|
|
19
14
|
var EXCLUDE_FROM_CYA = [_models.ComponentTypes.ALERT, _models.ComponentTypes.HEADING, _models.ComponentTypes.HTML, _models.ComponentTypes.INSET_TEXT];
|
|
15
|
+
|
|
20
16
|
/**
|
|
21
17
|
* Determines whether a given component should display on the Check your answers screen.
|
|
22
18
|
*
|
|
@@ -25,36 +21,27 @@ var EXCLUDE_FROM_CYA = [_models.ComponentTypes.ALERT, _models.ComponentTypes.HEA
|
|
|
25
21
|
*
|
|
26
22
|
* @returns A boolean true if the component should show; otherwise false.
|
|
27
23
|
*/
|
|
28
|
-
|
|
29
24
|
exports.EXCLUDE_FROM_CYA = EXCLUDE_FROM_CYA;
|
|
30
|
-
|
|
31
25
|
var showComponentCYA = function showComponentCYA(options, data) {
|
|
32
26
|
if (!options) {
|
|
33
27
|
return false;
|
|
34
28
|
}
|
|
35
|
-
|
|
36
29
|
if (EXCLUDE_FROM_CYA.includes(options.type)) {
|
|
37
30
|
return false;
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
if (options.hasOwnProperty('show_on_cya') && !options.show_on_cya) {
|
|
41
33
|
return false;
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
if (options.hideOnCyaWhenEmpty && options.type === _models.ComponentTypes.COLLECTION) {
|
|
45
36
|
var itemCollectionsData = (0, _getSourceData.default)(data, options.full_path);
|
|
46
|
-
|
|
47
37
|
if (!(itemCollectionsData !== null && itemCollectionsData !== void 0 && itemCollectionsData.length)) {
|
|
48
38
|
return false;
|
|
49
39
|
}
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
if (options.type === _models.ComponentTypes.CONTAINER) {
|
|
53
42
|
return _Container.default.show(options, data);
|
|
54
43
|
}
|
|
55
|
-
|
|
56
44
|
return _Component.default.show(options, data);
|
|
57
45
|
};
|
|
58
|
-
|
|
59
46
|
var _default = showComponentCYA;
|
|
60
47
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
|
-
|
|
5
4
|
var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
|
|
6
|
-
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
6
|
// Local imports
|
|
7
|
+
|
|
10
8
|
describe('utils', function () {
|
|
11
9
|
describe('CheckYourAnswers', function () {
|
|
12
10
|
describe('showComponentCYA', function () {
|
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
9
|
+
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); }
|
|
12
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
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); }
|
|
18
15
|
/**
|
|
19
16
|
* Duplicates the currently active entry in a named collection's data.
|
|
20
17
|
* Once duplicated, the new entry is set as the active entry.
|
|
@@ -24,22 +21,17 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
24
21
|
*/
|
|
25
22
|
var duplicateCollectionPageActiveEntry = function duplicateCollectionPageActiveEntry(collectionName, formData) {
|
|
26
23
|
var _formData$collectionN;
|
|
27
|
-
|
|
28
24
|
var currentIndex = (0, _getCollectionPageActiveIndex.default)(collectionName, formData);
|
|
29
25
|
var currentEntry = (_formData$collectionN = formData[collectionName]) === null || _formData$collectionN === void 0 ? void 0 : _formData$collectionN[currentIndex];
|
|
30
|
-
|
|
31
26
|
if (!currentEntry) {
|
|
32
27
|
return false;
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
var newEntry = _objectSpread(_objectSpread({}, currentEntry), {}, {
|
|
36
30
|
id: Date.now().toString()
|
|
37
31
|
});
|
|
38
|
-
|
|
39
32
|
formData[collectionName].push(newEntry);
|
|
40
33
|
formData["".concat(collectionName, "ActiveId")] = newEntry.id;
|
|
41
34
|
return true;
|
|
42
35
|
};
|
|
43
|
-
|
|
44
36
|
var _default = duplicateCollectionPageActiveEntry;
|
|
45
37
|
exports.default = _default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _duplicateCollectionPageActiveEntry = _interopRequireDefault(require("./duplicateCollectionPageActiveEntry"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
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); }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); }
|
|
9
9
|
describe('utils.CollectionPage.duplicateCollectionPageActiveEntry', function () {
|
|
10
10
|
var COLLECTION_NAME = 'testCollection';
|
|
11
11
|
var OBJ = {
|
|
@@ -14,7 +14,6 @@ describe('utils.CollectionPage.duplicateCollectionPageActiveEntry', function ()
|
|
|
14
14
|
};
|
|
15
15
|
it('should duplicate the active entry if one exists', function () {
|
|
16
16
|
var _FORM_DATA;
|
|
17
|
-
|
|
18
17
|
var FORM_DATA = (_FORM_DATA = {}, _defineProperty(_FORM_DATA, "".concat(COLLECTION_NAME, "ActiveId"), '1'), _defineProperty(_FORM_DATA, COLLECTION_NAME, [OBJ]), _FORM_DATA);
|
|
19
18
|
(0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
|
|
20
19
|
expect(FORM_DATA[COLLECTION_NAME].length).toEqual(2);
|
|
@@ -26,13 +25,13 @@ describe('utils.CollectionPage.duplicateCollectionPageActiveEntry', function ()
|
|
|
26
25
|
});
|
|
27
26
|
it('should do nothing if there is no active entry', function () {
|
|
28
27
|
var _FORM_DATA2;
|
|
29
|
-
|
|
30
28
|
var FORM_DATA = (_FORM_DATA2 = {}, _defineProperty(_FORM_DATA2, "".concat(COLLECTION_NAME, "ActiveId"), '2'), _defineProperty(_FORM_DATA2, COLLECTION_NAME, [OBJ]), _FORM_DATA2);
|
|
31
29
|
(0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
|
|
32
30
|
expect(FORM_DATA[COLLECTION_NAME].length).toEqual(1);
|
|
33
31
|
expect(FORM_DATA[COLLECTION_NAME][0]).toEqual(OBJ);
|
|
34
32
|
expect(FORM_DATA["".concat(COLLECTION_NAME, "ActiveId")]).toEqual('2'); // Shouldn't have changed.
|
|
35
33
|
});
|
|
34
|
+
|
|
36
35
|
it('should do nothing if the collection does not exist', function () {
|
|
37
36
|
var FORM_DATA = {};
|
|
38
37
|
(0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Gets the index of the active entry in a named collection's data.
|
|
10
9
|
* @param {string} collectionName The name of the collection.
|
|
@@ -13,22 +12,17 @@ exports.default = void 0;
|
|
|
13
12
|
*/
|
|
14
13
|
var getCollectionPageActiveIndex = function getCollectionPageActiveIndex(collectionName, formData) {
|
|
15
14
|
var _formData$collectionN;
|
|
16
|
-
|
|
17
15
|
if (!collectionName) {
|
|
18
16
|
return null;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
var id = formData === null || formData === void 0 ? void 0 : formData["".concat(collectionName, "ActiveId")];
|
|
22
|
-
|
|
23
19
|
if (!id) {
|
|
24
20
|
return null;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
var activeIndex = (_formData$collectionN = formData[collectionName]) === null || _formData$collectionN === void 0 ? void 0 : _formData$collectionN.findIndex(function (item) {
|
|
28
23
|
return item.id === id;
|
|
29
24
|
});
|
|
30
25
|
return activeIndex > -1 ? activeIndex : null;
|
|
31
26
|
};
|
|
32
|
-
|
|
33
27
|
var _default = getCollectionPageActiveIndex;
|
|
34
28
|
exports.default = _default;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('utils.CollectionPage.getCollectionPageActiveIndex', function () {
|
|
9
8
|
it('should return the index of the active item in the collection, if one exists', function () {
|
|
10
9
|
var COLLECTION_NAME = 'test';
|
|
@@ -4,16 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _duplicateCollectionPageActiveEntry = _interopRequireDefault(require("./duplicateCollectionPageActiveEntry"));
|
|
9
|
-
|
|
10
8
|
var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
|
|
11
|
-
|
|
12
9
|
var _mergeCollectionPages = _interopRequireDefault(require("./mergeCollectionPages"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
// Local imports
|
|
12
|
+
|
|
17
13
|
var CollectionPage = {
|
|
18
14
|
duplicateActiveEntry: _duplicateCollectionPageActiveEntry.default,
|
|
19
15
|
getActiveIndex: _getCollectionPageActiveIndex.default,
|
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
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); }
|
|
8
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; }
|
|
9
|
-
|
|
10
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; }
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
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); }
|
|
14
13
|
var createMasterPage = function createMasterPage(page) {
|
|
15
14
|
return {
|
|
16
15
|
id: page.id,
|
|
@@ -21,12 +20,12 @@ var createMasterPage = function createMasterPage(page) {
|
|
|
21
20
|
collectionPages: [page]
|
|
22
21
|
};
|
|
23
22
|
};
|
|
24
|
-
|
|
25
23
|
var mergeIntoMasterPage = function mergeIntoMasterPage(page, masterPage) {
|
|
26
24
|
masterPage.collection = _objectSpread(_objectSpread({}, masterPage.collection), page.collection);
|
|
27
25
|
masterPage.formData = _objectSpread(_objectSpread({}, masterPage.formData), page.formData);
|
|
28
26
|
masterPage.collectionPages = [].concat(masterPage.collectionPages, [page]);
|
|
29
27
|
};
|
|
28
|
+
|
|
30
29
|
/**
|
|
31
30
|
* Loop over an array of pages, merging any CollectionPages into a
|
|
32
31
|
* single master page for that collection. A master page is created
|
|
@@ -38,13 +37,10 @@ var mergeIntoMasterPage = function mergeIntoMasterPage(page, masterPage) {
|
|
|
38
37
|
* @param { array } pages Array of pages in the form.
|
|
39
38
|
* @returns An array of the same pages, with a master page for each collection.
|
|
40
39
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
40
|
var mergeCollectionPages = function mergeCollectionPages(pages) {
|
|
44
41
|
var masterPages = {};
|
|
45
42
|
return pages.map(function (page) {
|
|
46
43
|
var _page$collection;
|
|
47
|
-
|
|
48
44
|
if (page !== null && page !== void 0 && (_page$collection = page.collection) !== null && _page$collection !== void 0 && _page$collection.name) {
|
|
49
45
|
if (!masterPages[page.collection.name]) {
|
|
50
46
|
// If no master page exists for this collection.name, then
|
|
@@ -59,12 +55,10 @@ var mergeCollectionPages = function mergeCollectionPages(pages) {
|
|
|
59
55
|
return null;
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
|
-
|
|
63
58
|
return page;
|
|
64
59
|
}).filter(function (page) {
|
|
65
60
|
return !!page;
|
|
66
61
|
});
|
|
67
62
|
};
|
|
68
|
-
|
|
69
63
|
var _default = mergeCollectionPages;
|
|
70
64
|
exports.default = _default;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _mergeCollectionPages = _interopRequireDefault(require("./mergeCollectionPages"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('utils.CollectionPage.mergeCollectionPages', function () {
|
|
9
8
|
var TEXT_COMP = {
|
|
10
9
|
id: 'testText',
|
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
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); }
|
|
8
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; }
|
|
9
|
-
|
|
10
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; }
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
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); }
|
|
14
13
|
/**
|
|
15
14
|
* Adds a show_when to a component.
|
|
16
15
|
* If the component has no show_when, then an array is created
|
|
@@ -26,13 +25,10 @@ var addShowWhen = function addShowWhen(component, condition) {
|
|
|
26
25
|
if (!component) {
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
if (!condition) {
|
|
31
29
|
return component;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
var result = _objectSpread({}, component);
|
|
35
|
-
|
|
36
32
|
if (result.show_when) {
|
|
37
33
|
if (Array.isArray(condition)) {
|
|
38
34
|
result.show_when = Array.isArray(result.show_when) ? [].concat(condition, result.show_when) : [].concat(condition, [result.show_when]);
|
|
@@ -42,9 +38,7 @@ var addShowWhen = function addShowWhen(component, condition) {
|
|
|
42
38
|
} else {
|
|
43
39
|
result.show_when = condition;
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
return result;
|
|
47
42
|
};
|
|
48
|
-
|
|
49
43
|
var _default = addShowWhen;
|
|
50
44
|
exports.default = _default;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _addShowWhen = _interopRequireDefault(require("./addShowWhen"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('utils.Component.addShowWhen', function () {
|
|
9
8
|
var NEW_SHOW_WHEN = {
|
|
10
9
|
field: 'field',
|