@ukhomeoffice/cop-react-form-renderer 5.14.2 → 5.14.4
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 +15 -15
- package/dist/components/CheckYourAnswers/Answer.test.js +94 -128
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +99 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +291 -501
- package/dist/components/CheckYourAnswers/index.js +2 -3
- package/dist/components/CollectionPage/CollectionPage.js +64 -58
- package/dist/components/CollectionPage/CollectionPage.test.js +212 -238
- package/dist/components/CollectionPage/index.js +2 -3
- package/dist/components/FormComponent/Collection.js +77 -113
- package/dist/components/FormComponent/Collection.test.js +688 -787
- package/dist/components/FormComponent/Container.js +44 -43
- package/dist/components/FormComponent/Container.test.js +316 -346
- package/dist/components/FormComponent/FormComponent.js +58 -64
- package/dist/components/FormComponent/FormComponent.test.js +180 -219
- package/dist/components/FormComponent/helpers/addLabel.js +5 -9
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +2 -3
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -2
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
- package/dist/components/FormComponent/helpers/index.js +5 -5
- package/dist/components/FormComponent/index.js +2 -3
- package/dist/components/FormPage/FormPage.js +65 -79
- package/dist/components/FormPage/FormPage.test.js +134 -170
- package/dist/components/FormPage/index.js +2 -3
- package/dist/components/FormRenderer/FormRenderer.js +151 -193
- package/dist/components/FormRenderer/FormRenderer.test.js +598 -920
- package/dist/components/FormRenderer/handlers/cyaAction.js +4 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +2 -5
- package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
- package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
- package/dist/components/FormRenderer/handlers/index.js +3 -4
- package/dist/components/FormRenderer/handlers/navigate.js +5 -6
- package/dist/components/FormRenderer/handlers/submissionError.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.js +2 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +10 -10
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +2 -5
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +19 -27
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +17 -17
- package/dist/components/FormRenderer/helpers/getCYA.js +6 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -10
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +19 -34
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +3 -6
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -13
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +12 -13
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -92
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +66 -66
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
- package/dist/components/FormRenderer/helpers/index.js +3 -4
- package/dist/components/FormRenderer/index.js +2 -3
- package/dist/components/FormRenderer/onCYAAction.js +52 -62
- package/dist/components/FormRenderer/onCYAAction.test.js +146 -138
- package/dist/components/FormRenderer/onPageAction.js +48 -47
- package/dist/components/FormRenderer/onPageAction.test.js +219 -205
- package/dist/components/FormRenderer/onTaskAction.js +12 -17
- package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
- package/dist/components/PageActions/ActionButton.js +15 -19
- package/dist/components/PageActions/ActionButton.test.js +58 -79
- package/dist/components/PageActions/PageActions.js +12 -13
- package/dist/components/PageActions/PageActions.test.js +88 -116
- package/dist/components/PageActions/index.js +2 -3
- package/dist/components/SummaryList/GroupAction.js +15 -23
- package/dist/components/SummaryList/GroupAction.test.js +41 -37
- package/dist/components/SummaryList/RowAction.js +14 -19
- package/dist/components/SummaryList/RowAction.test.js +41 -37
- package/dist/components/SummaryList/SummaryList.js +25 -30
- package/dist/components/SummaryList/SummaryList.test.js +160 -182
- package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -8
- package/dist/components/SummaryList/SummaryListRow.js +9 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +8 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -8
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +24 -24
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +2 -3
- package/dist/components/TaskList/Task.js +22 -33
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +46 -75
- package/dist/components/TaskList/TaskList.test.js +118 -113
- package/dist/components/TaskList/TaskState.js +9 -9
- package/dist/components/TaskList/TaskState.test.js +56 -49
- package/dist/components/TaskList/index.js +2 -3
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +59 -85
- package/dist/context/HooksContext/HooksContext.test.js +28 -36
- package/dist/context/HooksContext/index.js +4 -6
- package/dist/context/ValidationContext/ValidationContext.js +35 -76
- package/dist/context/ValidationContext/ValidationContext.test.js +50 -61
- package/dist/context/ValidationContext/index.js +4 -6
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +17 -43
- package/dist/hooks/useGetRequest.js +61 -106
- package/dist/hooks/useHooks.js +2 -5
- package/dist/hooks/useRefData.js +29 -45
- package/dist/hooks/useValidation.js +2 -5
- package/dist/index.js +15 -17
- package/dist/models/CollectionLabels.js +2 -3
- package/dist/models/ComponentTypes.js +25 -26
- package/dist/models/EventTypes.js +5 -6
- package/dist/models/FormPages.js +5 -6
- package/dist/models/FormTypes.js +9 -10
- package/dist/models/HubFormats.js +4 -5
- package/dist/models/PageAction.js +45 -42
- package/dist/models/TaskStates.js +30 -31
- package/dist/models/index.js +11 -12
- package/dist/setupTests.js +20 -24
- package/dist/utils/CheckYourAnswers/getCYAAction.js +6 -7
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +21 -23
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +18 -20
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +72 -72
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +20 -27
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +41 -47
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +71 -78
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +133 -114
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +27 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +16 -23
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
- package/dist/utils/CheckYourAnswers/index.js +3 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +7 -9
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -16
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +19 -20
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +4 -8
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +15 -15
- package/dist/utils/CollectionPage/index.js +3 -4
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -29
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +15 -15
- package/dist/utils/Component/addShowWhen.js +5 -10
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +20 -22
- package/dist/utils/Component/applyToComponentTree.test.js +28 -33
- package/dist/utils/Component/cleanAttributes.js +11 -16
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +7 -9
- package/dist/utils/Component/elevateNestedComponents.test.js +19 -19
- package/dist/utils/Component/getComponent.js +91 -99
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +51 -63
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +41 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -37
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +12 -11
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +24 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +59 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +19 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +35 -41
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +24 -32
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
- package/dist/utils/Component/getDefaultValue.js +7 -9
- package/dist/utils/Component/getDefaultValue.test.js +14 -14
- package/dist/utils/Component/index.js +3 -4
- package/dist/utils/Component/isEditable.js +3 -7
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -3
- package/dist/utils/Component/optionIsSelected.test.js +10 -10
- package/dist/utils/Component/setupContainerComponentsPath.js +30 -33
- package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
- package/dist/utils/Component/showComponent.js +4 -6
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +6 -6
- package/dist/utils/Condition/index.js +3 -4
- package/dist/utils/Condition/meetsAllConditions.js +9 -10
- package/dist/utils/Condition/meetsAllConditions.test.js +18 -18
- package/dist/utils/Condition/meetsCondition.js +19 -27
- package/dist/utils/Condition/meetsCondition.test.js +377 -377
- package/dist/utils/Condition/meetsOneCondition.js +7 -8
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +15 -21
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +5 -8
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +3 -4
- package/dist/utils/Container/setupNesting.js +17 -24
- package/dist/utils/Container/setupNesting.test.js +28 -31
- package/dist/utils/Container/showContainer.js +5 -10
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +41 -52
- package/dist/utils/Data/applyFormula.test.js +26 -26
- package/dist/utils/Data/getAutocompleteSource.js +11 -14
- package/dist/utils/Data/getAutocompleteSource.test.js +59 -59
- package/dist/utils/Data/getDataPath.js +21 -32
- package/dist/utils/Data/getDataPath.test.js +20 -20
- package/dist/utils/Data/getOptions.js +22 -28
- package/dist/utils/Data/getOptions.test.js +21 -21
- package/dist/utils/Data/getSourceData.js +7 -21
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +3 -4
- package/dist/utils/Data/refDataToOptions.js +12 -17
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +8 -10
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +32 -48
- package/dist/utils/Data/setupFormData.test.js +99 -98
- package/dist/utils/Data/setupRefDataUrlForComponent.js +22 -30
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -12
- package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
- package/dist/utils/FormPage/getFormPage.js +17 -19
- package/dist/utils/FormPage/getFormPage.test.js +49 -48
- package/dist/utils/FormPage/getFormPages.js +9 -15
- package/dist/utils/FormPage/getFormPages.test.js +22 -25
- package/dist/utils/FormPage/getPageActions.js +11 -19
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +6 -9
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -4
- package/dist/utils/FormPage/showFormPage.js +5 -10
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +4 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +21 -29
- package/dist/utils/FormPage/useComponent.test.js +71 -73
- package/dist/utils/Format/formatData.js +2 -3
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -9
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +7 -10
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -7
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +3 -4
- package/dist/utils/Hub/getFormHub.js +3 -4
- package/dist/utils/Hub/getFormHub.test.js +29 -32
- package/dist/utils/Hub/index.js +3 -4
- package/dist/utils/Meta/constants.js +2 -4
- package/dist/utils/Meta/documents/getDocuments.js +2 -6
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +3 -4
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -19
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
- package/dist/utils/Meta/index.js +3 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +5 -6
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/getFirstOf.js +9 -10
- package/dist/utils/Operate/getFirstOf.test.js +33 -33
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +13 -14
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/index.js +3 -4
- package/dist/utils/Operate/persistValueInFormData.js +7 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +10 -11
- package/dist/utils/Operate/runPageOperations.test.js +36 -37
- package/dist/utils/Operate/setValueInFormData.js +6 -7
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +9 -10
- package/dist/utils/Operate/shouldRun.test.js +22 -28
- package/dist/utils/Validate/additional/conditionallyRequired.js +5 -7
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -9
- package/dist/utils/Validate/additional/index.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeAfter.js +4 -5
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +4 -5
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -14
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +34 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +5 -6
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +6 -7
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +3 -4
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +3 -4
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeShorterThan.js +2 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +4 -7
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +2 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +4 -7
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -25
- package/dist/utils/Validate/index.js +3 -4
- package/dist/utils/Validate/validateCollection.js +22 -29
- package/dist/utils/Validate/validateCollection.test.js +85 -77
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +169 -147
- package/dist/utils/Validate/validateContainer.js +16 -22
- package/dist/utils/Validate/validateContainer.test.js +52 -48
- package/dist/utils/Validate/validateDate.js +14 -21
- package/dist/utils/Validate/validateDate.test.js +28 -29
- package/dist/utils/Validate/validateEmail.js +8 -11
- package/dist/utils/Validate/validateEmail.test.js +26 -26
- package/dist/utils/Validate/validateMultifile.js +6 -10
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +20 -22
- package/dist/utils/Validate/validatePage.test.js +146 -143
- package/dist/utils/Validate/validateRegex.js +6 -10
- package/dist/utils/Validate/validateRegex.test.js +17 -17
- package/dist/utils/Validate/validateRequired.js +6 -9
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +6 -9
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +8 -16
- package/dist/utils/Validate/validateTime.test.js +15 -15
- package/dist/utils/index.js +10 -12
- package/package.json +9 -6
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.PageActionTypes = exports.DefaultPageActions = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var TYPE_SAVE_AND_CONTINUE = 'saveAndContinue';
|
|
18
|
-
var TYPE_SAVE_AND_NAVIGATE = 'saveAndNavigate';
|
|
19
|
-
var TYPE_SAVE_AND_RETURN = 'saveAndReturn';
|
|
20
|
-
var TYPE_SUBMIT = 'submit';
|
|
21
|
-
var PageActionTypes = {
|
|
7
|
+
const TYPE_CANCEL = 'cancel';
|
|
8
|
+
const TYPE_COLLECTION_ADD = 'collectionAdd';
|
|
9
|
+
const TYPE_COLLECTION_DUPLICATE = 'collectionDuplicate';
|
|
10
|
+
const TYPE_COLLECTION_REMOVE = 'collectionRemove';
|
|
11
|
+
const TYPE_NAVIGATE = 'navigate';
|
|
12
|
+
const TYPE_SAVE_AND_CONTINUE = 'saveAndContinue';
|
|
13
|
+
const TYPE_SAVE_AND_NAVIGATE = 'saveAndNavigate';
|
|
14
|
+
const TYPE_SAVE_AND_RETURN = 'saveAndReturn';
|
|
15
|
+
const TYPE_SUBMIT = 'submit';
|
|
16
|
+
const PageActionTypes = exports.PageActionTypes = {
|
|
22
17
|
CANCEL: TYPE_CANCEL,
|
|
23
18
|
COLLECTION_ADD: TYPE_COLLECTION_ADD,
|
|
24
19
|
COLLECTION_DUPLICATE: TYPE_COLLECTION_DUPLICATE,
|
|
@@ -29,33 +24,41 @@ var PageActionTypes = {
|
|
|
29
24
|
SAVE_AND_RETURN: TYPE_SAVE_AND_RETURN,
|
|
30
25
|
SUBMIT: TYPE_SUBMIT
|
|
31
26
|
};
|
|
32
|
-
exports.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
27
|
+
const DefaultPageActions = exports.DefaultPageActions = {
|
|
28
|
+
[TYPE_CANCEL]: {
|
|
29
|
+
type: TYPE_CANCEL,
|
|
30
|
+
validate: false,
|
|
31
|
+
label: 'Cancel',
|
|
32
|
+
classModifiers: 'secondary'
|
|
33
|
+
},
|
|
34
|
+
[TYPE_COLLECTION_ADD]: undefined,
|
|
35
|
+
[TYPE_COLLECTION_DUPLICATE]: undefined,
|
|
36
|
+
[TYPE_COLLECTION_REMOVE]: undefined,
|
|
37
|
+
[TYPE_NAVIGATE]: undefined,
|
|
38
|
+
// No default for this.
|
|
39
|
+
[TYPE_SAVE_AND_CONTINUE]: {
|
|
40
|
+
type: TYPE_SAVE_AND_CONTINUE,
|
|
41
|
+
validate: true,
|
|
42
|
+
label: 'Save and continue'
|
|
43
|
+
},
|
|
44
|
+
[TYPE_SAVE_AND_NAVIGATE]: {
|
|
45
|
+
type: TYPE_SAVE_AND_NAVIGATE,
|
|
46
|
+
validate: true,
|
|
47
|
+
label: 'Save and continue'
|
|
48
|
+
},
|
|
49
|
+
[TYPE_SAVE_AND_RETURN]: {
|
|
50
|
+
type: TYPE_SAVE_AND_RETURN,
|
|
51
|
+
validate: false,
|
|
52
|
+
label: 'Save and return later',
|
|
53
|
+
classModifiers: 'secondary'
|
|
54
|
+
},
|
|
55
|
+
[TYPE_SUBMIT]: {
|
|
56
|
+
type: TYPE_SUBMIT,
|
|
57
|
+
validate: true
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const PageAction = {
|
|
57
61
|
TYPES: PageActionTypes,
|
|
58
62
|
DEFAULTS: DefaultPageActions
|
|
59
63
|
};
|
|
60
|
-
var _default = PageAction;
|
|
61
|
-
exports.default = _default;
|
|
64
|
+
var _default = exports.default = PageAction;
|
|
@@ -4,43 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.StateTypes = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var TYPE_IN_PROGRESS = 'inProgress';
|
|
14
|
-
var TYPE_NOT_STARTED = 'notStarted';
|
|
15
|
-
var TYPE_CANNOT_START_YET = 'cannotStartYet';
|
|
16
|
-
var TYPE_SKIPPED = 'skipped';
|
|
17
|
-
var StateTypes = {
|
|
7
|
+
const TYPE_COMPLETE = 'complete';
|
|
8
|
+
const TYPE_IN_PROGRESS = 'inProgress';
|
|
9
|
+
const TYPE_NOT_STARTED = 'notStarted';
|
|
10
|
+
const TYPE_CANNOT_START_YET = 'cannotStartYet';
|
|
11
|
+
const TYPE_SKIPPED = 'skipped';
|
|
12
|
+
const StateTypes = exports.StateTypes = {
|
|
18
13
|
COMPLETE: TYPE_COMPLETE,
|
|
19
14
|
IN_PROGRESS: TYPE_IN_PROGRESS,
|
|
20
15
|
NOT_STARTED: TYPE_NOT_STARTED,
|
|
21
16
|
CANNOT_START_YET: TYPE_CANNOT_START_YET,
|
|
22
17
|
SKIPPED: TYPE_SKIPPED
|
|
23
18
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
19
|
+
const StateDetails = {
|
|
20
|
+
[TYPE_COMPLETE]: {
|
|
21
|
+
label: 'Completed',
|
|
22
|
+
colour: 'dark-blue'
|
|
23
|
+
},
|
|
24
|
+
[TYPE_IN_PROGRESS]: {
|
|
25
|
+
label: 'In Progress',
|
|
26
|
+
colour: 'white'
|
|
27
|
+
},
|
|
28
|
+
[TYPE_NOT_STARTED]: {
|
|
29
|
+
label: 'Not Started',
|
|
30
|
+
colour: 'dark-grey'
|
|
31
|
+
},
|
|
32
|
+
[TYPE_CANNOT_START_YET]: {
|
|
33
|
+
label: 'Cannot Start Yet',
|
|
34
|
+
colour: 'dark-grey'
|
|
35
|
+
},
|
|
36
|
+
[TYPE_SKIPPED]: {
|
|
37
|
+
label: 'Skipped',
|
|
38
|
+
colour: 'dark-grey'
|
|
39
|
+
} // Shouldn't ever see this, but just in case.
|
|
40
|
+
};
|
|
41
|
+
const TaskStates = {
|
|
42
42
|
TYPES: StateTypes,
|
|
43
43
|
DETAILS: StateDetails
|
|
44
44
|
};
|
|
45
|
-
var _default = TaskStates;
|
|
46
|
-
exports.default = _default;
|
|
45
|
+
var _default = exports.default = TaskStates;
|
package/dist/models/index.js
CHANGED
|
@@ -5,49 +5,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
Object.defineProperty(exports, "CollectionLabels", {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: function
|
|
8
|
+
get: function () {
|
|
9
9
|
return _CollectionLabels.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "ComponentTypes", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function
|
|
14
|
+
get: function () {
|
|
15
15
|
return _ComponentTypes.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "EventTypes", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function
|
|
20
|
+
get: function () {
|
|
21
21
|
return _EventTypes.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "FormPages", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function
|
|
26
|
+
get: function () {
|
|
27
27
|
return _FormPages.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "FormTypes", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function
|
|
32
|
+
get: function () {
|
|
33
33
|
return _FormTypes.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "HubFormats", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function
|
|
38
|
+
get: function () {
|
|
39
39
|
return _HubFormats.default;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "PageAction", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function
|
|
44
|
+
get: function () {
|
|
45
45
|
return _PageAction.default;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "TaskStates", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function
|
|
50
|
+
get: function () {
|
|
51
51
|
return _TaskStates.default;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -60,10 +60,10 @@ var _FormTypes = _interopRequireDefault(require("./FormTypes"));
|
|
|
60
60
|
var _HubFormats = _interopRequireDefault(require("./HubFormats"));
|
|
61
61
|
var _PageAction = _interopRequireDefault(require("./PageAction"));
|
|
62
62
|
var _TaskStates = _interopRequireDefault(require("./TaskStates"));
|
|
63
|
-
function _interopRequireDefault(
|
|
63
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
64
64
|
// Local imports
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
const Models = {
|
|
67
67
|
CollectionLabels: _CollectionLabels.default,
|
|
68
68
|
ComponentTypes: _ComponentTypes.default,
|
|
69
69
|
EventTypes: _EventTypes.default,
|
|
@@ -73,5 +73,4 @@ var Models = {
|
|
|
73
73
|
PageAction: _PageAction.default,
|
|
74
74
|
TaskStates: _TaskStates.default
|
|
75
75
|
};
|
|
76
|
-
var _default = Models;
|
|
77
|
-
exports.default = _default;
|
|
76
|
+
var _default = exports.default = Models;
|
package/dist/setupTests.js
CHANGED
|
@@ -8,38 +8,34 @@ var _react = require("@testing-library/react");
|
|
|
8
8
|
var _reactHooks = require("@testing-library/react-hooks");
|
|
9
9
|
var _reactDom = require("react-dom");
|
|
10
10
|
var _context = require("./context");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, ui)), options);
|
|
17
|
-
};
|
|
11
|
+
const renderWithValidation = (ui, options) => (0, _react.render)(/*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
12
|
+
overrides: options?.hooks
|
|
13
|
+
}, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
|
|
14
|
+
key: "vcp"
|
|
15
|
+
}, ui)), options);
|
|
18
16
|
exports.renderWithValidation = renderWithValidation;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, ui)), container);
|
|
25
|
-
};
|
|
17
|
+
const renderDomWithValidation = (ui, container, options) => (0, _reactDom.render)(/*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
18
|
+
overrides: options?.hooks
|
|
19
|
+
}, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
|
|
20
|
+
key: "vcp"
|
|
21
|
+
}, ui)), container);
|
|
26
22
|
exports.renderDomWithValidation = renderDomWithValidation;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
const renderHookWithProvider = (hook, options) => {
|
|
24
|
+
const wrapper = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
children
|
|
27
|
+
} = _ref;
|
|
30
28
|
return /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
|
|
31
|
-
overrides: options
|
|
29
|
+
overrides: options?.hooks
|
|
32
30
|
}, children);
|
|
33
31
|
};
|
|
34
|
-
return (0, _reactHooks.renderHook)(
|
|
35
|
-
|
|
36
|
-
}, {
|
|
37
|
-
wrapper: wrapper
|
|
32
|
+
return (0, _reactHooks.renderHook)(() => hook(), {
|
|
33
|
+
wrapper
|
|
38
34
|
});
|
|
39
35
|
};
|
|
40
36
|
exports.renderHookWithProvider = renderHookWithProvider;
|
|
41
|
-
|
|
42
|
-
Object.keys(expected).forEach(
|
|
37
|
+
const expectObjectLike = (received, expected) => {
|
|
38
|
+
Object.keys(expected).forEach(key => {
|
|
43
39
|
expect(received[key]).toEqual(expected[key]);
|
|
44
40
|
});
|
|
45
41
|
};
|
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
7
|
+
const getPageFromCYALink = link => {
|
|
8
8
|
if (link.page) {
|
|
9
9
|
return link.page;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
const url = link.href || link.url;
|
|
12
12
|
if (url) {
|
|
13
13
|
return url.split('/').pop();
|
|
14
14
|
}
|
|
@@ -28,17 +28,16 @@ var getPageFromCYALink = function getPageFromCYALink(link) {
|
|
|
28
28
|
* method will convert both by taking the final part of the relative path:
|
|
29
29
|
* - `href: '/bravo'` => `page: 'bravo'`
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const getCYAAction = (readonly, page, onAction) => {
|
|
32
|
+
const cyaLink = page?.cya_link;
|
|
33
33
|
if (readonly !== true && cyaLink) {
|
|
34
34
|
return {
|
|
35
35
|
page: getPageFromCYALink(cyaLink) || page.id || '#',
|
|
36
36
|
label: cyaLink.label || 'Change',
|
|
37
37
|
aria_suffix: cyaLink.aria_suffix,
|
|
38
|
-
onAction
|
|
38
|
+
onAction
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
return null;
|
|
42
42
|
};
|
|
43
|
-
var _default = getCYAAction;
|
|
44
|
-
exports.default = _default;
|
|
43
|
+
var _default = exports.default = getCYAAction;
|
|
@@ -1,119 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
|
|
4
|
-
function _interopRequireDefault(
|
|
4
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
5
|
// Local imports
|
|
6
6
|
|
|
7
|
-
describe('utils',
|
|
8
|
-
describe('CheckYourAnswers',
|
|
9
|
-
describe('getCYAAction',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
it('should return null if readonly', function () {
|
|
17
|
-
expect((0, _getCYAAction.default)(true, {}, function () {})).toBeNull();
|
|
7
|
+
describe('utils', () => {
|
|
8
|
+
describe('CheckYourAnswers', () => {
|
|
9
|
+
describe('getCYAAction', () => {
|
|
10
|
+
const getPage = (cyaLink, id) => ({
|
|
11
|
+
cya_link: cyaLink,
|
|
12
|
+
id
|
|
13
|
+
});
|
|
14
|
+
it('should return null if readonly', () => {
|
|
15
|
+
expect((0, _getCYAAction.default)(true, {}, () => {})).toBeNull();
|
|
18
16
|
});
|
|
19
|
-
it('should return null if there is no cya_link',
|
|
20
|
-
expect((0, _getCYAAction.default)(false, null,
|
|
17
|
+
it('should return null if there is no cya_link', () => {
|
|
18
|
+
expect((0, _getCYAAction.default)(false, null, () => {})).toBeNull();
|
|
21
19
|
});
|
|
22
|
-
it('should return a default action if the cya_link is empty and the page has no id',
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
it('should return a default action if the cya_link is empty and the page has no id', () => {
|
|
21
|
+
const cyaLink = {};
|
|
22
|
+
const onAction = () => {};
|
|
25
23
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
26
24
|
page: '#',
|
|
27
25
|
label: 'Change',
|
|
28
|
-
onAction
|
|
26
|
+
onAction
|
|
29
27
|
});
|
|
30
28
|
});
|
|
31
|
-
it('should return a default action if the cya_link is empty but the page has an id',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
it('should return a default action if the cya_link is empty but the page has an id', () => {
|
|
30
|
+
const PAGE_ID = 'page-id';
|
|
31
|
+
const cyaLink = {};
|
|
32
|
+
const onAction = () => {};
|
|
35
33
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink, PAGE_ID), onAction)).toEqual({
|
|
36
34
|
page: PAGE_ID,
|
|
37
35
|
label: 'Change',
|
|
38
|
-
onAction
|
|
36
|
+
onAction
|
|
39
37
|
});
|
|
40
38
|
});
|
|
41
|
-
it('should use page specified in cya_link',
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
it('should use page specified in cya_link', () => {
|
|
40
|
+
const PAGE = 'alpha';
|
|
41
|
+
const cyaLink = {
|
|
44
42
|
page: PAGE
|
|
45
43
|
};
|
|
46
|
-
|
|
44
|
+
const onAction = () => {};
|
|
47
45
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
48
46
|
page: PAGE,
|
|
49
47
|
label: 'Change',
|
|
50
|
-
onAction
|
|
48
|
+
onAction
|
|
51
49
|
});
|
|
52
50
|
});
|
|
53
|
-
it('should convert an href specified in cya_link',
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
it('should convert an href specified in cya_link', () => {
|
|
52
|
+
const HREF = '/alpha/bravo';
|
|
53
|
+
const cyaLink = {
|
|
56
54
|
href: HREF
|
|
57
55
|
};
|
|
58
|
-
|
|
56
|
+
const onAction = () => {};
|
|
59
57
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
60
58
|
page: 'bravo',
|
|
61
59
|
label: 'Change',
|
|
62
|
-
onAction
|
|
60
|
+
onAction
|
|
63
61
|
});
|
|
64
62
|
});
|
|
65
|
-
it('should convert a url specified in cya_link',
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
it('should convert a url specified in cya_link', () => {
|
|
64
|
+
const URL = '/alpha/bravo';
|
|
65
|
+
const cyaLink = {
|
|
68
66
|
url: URL
|
|
69
67
|
};
|
|
70
|
-
|
|
68
|
+
const onAction = () => {};
|
|
71
69
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
72
70
|
page: 'bravo',
|
|
73
71
|
label: 'Change',
|
|
74
|
-
onAction
|
|
72
|
+
onAction
|
|
75
73
|
});
|
|
76
74
|
});
|
|
77
|
-
it('should use label specified in cya_link',
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
it('should use label specified in cya_link', () => {
|
|
76
|
+
const LABEL = 'Alpha Bravo Charlie';
|
|
77
|
+
const cyaLink = {
|
|
80
78
|
label: LABEL
|
|
81
79
|
};
|
|
82
|
-
|
|
80
|
+
const onAction = () => {};
|
|
83
81
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
84
82
|
page: '#',
|
|
85
83
|
label: LABEL,
|
|
86
|
-
onAction
|
|
84
|
+
onAction
|
|
87
85
|
});
|
|
88
86
|
});
|
|
89
|
-
it('should use aria_suffix specified in cya_link',
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
it('should use aria_suffix specified in cya_link', () => {
|
|
88
|
+
const ARIA_SUFFIX = 'This is hidden text';
|
|
89
|
+
const cyaLink = {
|
|
92
90
|
aria_suffix: ARIA_SUFFIX
|
|
93
91
|
};
|
|
94
|
-
|
|
92
|
+
const onAction = () => {};
|
|
95
93
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
96
94
|
page: '#',
|
|
97
95
|
label: 'Change',
|
|
98
96
|
aria_suffix: ARIA_SUFFIX,
|
|
99
|
-
onAction
|
|
97
|
+
onAction
|
|
100
98
|
});
|
|
101
99
|
});
|
|
102
|
-
it('should use all properties specified in cya_link',
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
it('should use all properties specified in cya_link', () => {
|
|
101
|
+
const PAGE = 'alpha';
|
|
102
|
+
const LABEL = 'Alpha Bravo Charlie';
|
|
103
|
+
const ARIA_SUFFIX = 'This is hidden text';
|
|
104
|
+
const cyaLink = {
|
|
107
105
|
label: LABEL,
|
|
108
106
|
page: PAGE,
|
|
109
107
|
aria_suffix: ARIA_SUFFIX
|
|
110
108
|
};
|
|
111
|
-
|
|
109
|
+
const onAction = () => {};
|
|
112
110
|
expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
|
|
113
111
|
page: PAGE,
|
|
114
112
|
label: LABEL,
|
|
115
113
|
aria_suffix: ARIA_SUFFIX,
|
|
116
|
-
onAction
|
|
114
|
+
onAction
|
|
117
115
|
});
|
|
118
116
|
});
|
|
119
117
|
});
|
|
@@ -6,39 +6,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
8
8
|
var _models = require("../../models");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var getCYACollectionChangeAction = function getCYACollectionChangeAction(page, item, _onAction, labelCount, action) {
|
|
16
|
-
var label = (action === null || action === void 0 ? void 0 : action.label) || _models.CollectionLabels.change;
|
|
9
|
+
// Global imports
|
|
10
|
+
|
|
11
|
+
// Local imports
|
|
12
|
+
|
|
13
|
+
const getCYACollectionChangeAction = (page, item, onAction, labelCount, action) => {
|
|
14
|
+
const label = action?.label || _models.CollectionLabels.change;
|
|
17
15
|
return {
|
|
18
16
|
pageId: page.id,
|
|
19
|
-
fieldId:
|
|
20
|
-
key:
|
|
17
|
+
fieldId: `change${labelCount}${action.page}`,
|
|
18
|
+
key: `change${labelCount}${action.page}`,
|
|
21
19
|
type: 'action',
|
|
22
20
|
action: {
|
|
23
|
-
onAction:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
data[
|
|
21
|
+
onAction: row => {
|
|
22
|
+
const changeCallback = cyaData => {
|
|
23
|
+
const data = cyaData;
|
|
24
|
+
data[`${page.collection.name}ActiveId`] = item.id;
|
|
27
25
|
return data;
|
|
28
26
|
};
|
|
29
|
-
|
|
27
|
+
let nextPage = row;
|
|
30
28
|
if (action.page) {
|
|
31
29
|
nextPage = {
|
|
32
30
|
pageId: action.page
|
|
33
31
|
};
|
|
34
32
|
}
|
|
35
|
-
|
|
33
|
+
onAction(nextPage, changeCallback);
|
|
36
34
|
},
|
|
37
|
-
label: _copReactComponents.Utils.interpolateString(label,
|
|
35
|
+
label: _copReactComponents.Utils.interpolateString(label, {
|
|
36
|
+
...item,
|
|
38
37
|
index: labelCount
|
|
39
|
-
})
|
|
38
|
+
})
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
};
|
|
43
|
-
var _default = getCYACollectionChangeAction;
|
|
44
|
-
exports.default = _default;
|
|
42
|
+
var _default = exports.default = getCYACollectionChangeAction;
|