@ukhomeoffice/cop-react-form-renderer 6.14.0 → 6.14.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/README.md +5 -0
- package/dist/components/CheckYourAnswers/Answer.js +12 -11
- package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
- package/dist/components/CheckYourAnswers/index.js +1 -1
- package/dist/components/CollectionPage/CollectionPage.js +62 -60
- package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
- package/dist/components/CollectionPage/index.js +1 -1
- package/dist/components/CollectionSummary/BannerStrip.js +14 -14
- package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
- package/dist/components/CollectionSummary/CollectionSummary.js +75 -97
- package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
- package/dist/components/CollectionSummary/Confirmation.js +15 -13
- package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
- package/dist/components/CollectionSummary/RenderListView.js +34 -47
- package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
- package/dist/components/CollectionSummary/SummaryCard.js +101 -133
- package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
- package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
- package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
- package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
- package/dist/components/CollectionSummary/index.js +1 -1
- package/dist/components/FormComponent/Collection.js +63 -100
- package/dist/components/FormComponent/Collection.test.js +907 -1080
- package/dist/components/FormComponent/Container.js +35 -29
- package/dist/components/FormComponent/Container.test.js +378 -409
- package/dist/components/FormComponent/FormComponent.js +59 -63
- package/dist/components/FormComponent/FormComponent.test.js +354 -415
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
- package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
- package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
- 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 +1 -1
- package/dist/components/FormPage/FormPage.js +70 -93
- package/dist/components/FormPage/FormPage.test.js +150 -202
- package/dist/components/FormPage/index.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +131 -173
- package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
- package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
- 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 +2 -2
- package/dist/components/FormRenderer/handlers/navigate.js +4 -4
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +16 -16
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -25
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
- package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
- package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
- package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getNextPageId.js +14 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
- package/dist/components/FormRenderer/helpers/getPage.js +2 -4
- package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
- package/dist/components/FormRenderer/helpers/index.js +2 -2
- package/dist/components/FormRenderer/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +43 -44
- package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
- package/dist/components/FormRenderer/onPageAction.js +26 -35
- package/dist/components/FormRenderer/onPageAction.test.js +177 -186
- package/dist/components/FormRenderer/onTaskAction.js +11 -12
- package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
- package/dist/components/PageActions/ActionButton.js +14 -14
- package/dist/components/PageActions/ActionButton.test.js +57 -79
- package/dist/components/PageActions/PageActions.js +11 -11
- package/dist/components/PageActions/PageActions.test.js +87 -116
- package/dist/components/PageActions/index.js +1 -1
- package/dist/components/SummaryList/GroupAction.js +10 -18
- package/dist/components/SummaryList/GroupAction.test.js +38 -34
- package/dist/components/SummaryList/RowAction.js +12 -17
- package/dist/components/SummaryList/RowAction.test.js +38 -34
- package/dist/components/SummaryList/SummaryList.js +23 -25
- package/dist/components/SummaryList/SummaryList.test.js +162 -189
- package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
- package/dist/components/SummaryList/SummaryListRow.js +7 -5
- package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
- package/dist/components/SummaryList/helpers/index.js +2 -2
- package/dist/components/SummaryList/index.js +1 -1
- package/dist/components/TaskList/Task.js +20 -30
- package/dist/components/TaskList/Task.test.js +84 -77
- package/dist/components/TaskList/TaskList.js +56 -79
- package/dist/components/TaskList/TaskList.test.js +149 -149
- package/dist/components/TaskList/TaskState.js +8 -6
- package/dist/components/TaskList/TaskState.test.js +53 -46
- package/dist/components/TaskList/index.js +1 -1
- package/dist/components/index.js +8 -8
- package/dist/context/HooksContext/HooksContext.js +56 -79
- package/dist/context/HooksContext/HooksContext.test.js +27 -36
- package/dist/context/HooksContext/index.js +3 -4
- package/dist/context/ValidationContext/ValidationContext.js +44 -95
- package/dist/context/ValidationContext/ValidationContext.test.js +57 -69
- package/dist/context/ValidationContext/index.js +3 -4
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.js +10 -11
- package/dist/hooks/useAxios.js +15 -41
- package/dist/hooks/useGetRequest.js +62 -98
- package/dist/hooks/useHooks.js +1 -3
- package/dist/hooks/useRefData.js +25 -37
- package/dist/hooks/useValidation.js +1 -3
- package/dist/index.js +14 -15
- package/dist/models/CollectionLabels.js +1 -1
- package/dist/models/ComponentTypes.js +25 -25
- package/dist/models/EventTypes.js +4 -4
- package/dist/models/FormPages.js +4 -4
- package/dist/models/FormTypes.js +8 -8
- package/dist/models/HubFormats.js +3 -3
- package/dist/models/PageAction.js +44 -38
- package/dist/models/TaskStates.js +29 -28
- package/dist/models/index.js +10 -10
- package/dist/setupTests.js +30 -31
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +76 -93
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
- package/dist/utils/CheckYourAnswers/index.js +2 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
- package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
- package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
- package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
- package/dist/utils/CollectionPage/index.js +2 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
- package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
- package/dist/utils/Component/addShowWhen.js +5 -6
- package/dist/utils/Component/addShowWhen.test.js +38 -38
- package/dist/utils/Component/applyToComponentTree.js +12 -15
- package/dist/utils/Component/applyToComponentTree.test.js +28 -31
- package/dist/utils/Component/cleanAttributes.js +12 -11
- package/dist/utils/Component/cleanAttributes.test.js +17 -18
- package/dist/utils/Component/elevateNestedComponents.js +6 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
- package/dist/utils/Component/getComponent.js +79 -85
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +21 -26
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
- 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 +23 -27
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +201 -226
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +32 -39
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
- 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 +13 -13
- package/dist/utils/Component/getDefaultValueFromConfig.js +16 -20
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
- package/dist/utils/Component/index.js +2 -2
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/isEditable.test.js +14 -15
- package/dist/utils/Component/optionIsSelected.js +2 -4
- package/dist/utils/Component/optionIsSelected.test.js +12 -12
- package/dist/utils/Component/setupContainerComponentsPath.js +23 -28
- package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
- package/dist/utils/Component/showComponent.js +2 -2
- package/dist/utils/Component/showComponent.test.js +29 -29
- package/dist/utils/Component/wrapInFormGroup.js +4 -4
- package/dist/utils/Condition/index.js +2 -2
- package/dist/utils/Condition/meetsAllConditions.js +9 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
- package/dist/utils/Condition/meetsCondition.js +17 -26
- package/dist/utils/Condition/meetsCondition.test.js +403 -403
- package/dist/utils/Condition/meetsOneCondition.js +6 -6
- package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
- package/dist/utils/Condition/setupConditions.js +12 -15
- package/dist/utils/Condition/setupConditions.test.js +8 -8
- package/dist/utils/Container/getEditableComponents.js +4 -6
- package/dist/utils/Container/getEditableComponents.test.js +44 -46
- package/dist/utils/Container/index.js +2 -2
- package/dist/utils/Container/setupNesting.js +14 -15
- package/dist/utils/Container/setupNesting.test.js +20 -23
- package/dist/utils/Container/showContainer.js +4 -8
- package/dist/utils/Container/showContainer.test.js +31 -31
- package/dist/utils/Data/applyFormula.js +30 -44
- package/dist/utils/Data/applyFormula.test.js +21 -21
- package/dist/utils/Data/deleteValues.js +4 -8
- package/dist/utils/Data/deleteValues.test.js +11 -11
- package/dist/utils/Data/getAutocompleteSource.js +19 -27
- package/dist/utils/Data/getAutocompleteSource.test.js +76 -81
- package/dist/utils/Data/getDataPath.js +18 -28
- package/dist/utils/Data/getDataPath.test.js +13 -13
- package/dist/utils/Data/getOptions.js +35 -42
- package/dist/utils/Data/getOptions.test.js +37 -38
- package/dist/utils/Data/getSourceData.js +6 -19
- package/dist/utils/Data/getSourceData.test.js +85 -81
- package/dist/utils/Data/index.js +2 -2
- package/dist/utils/Data/nestInRefdataOptions.js +9 -12
- package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
- package/dist/utils/Data/refDataToOptions.js +9 -10
- package/dist/utils/Data/refDataToOptions.test.js +20 -20
- package/dist/utils/Data/setDataItem.js +7 -8
- package/dist/utils/Data/setDataItem.test.js +38 -38
- package/dist/utils/Data/setupFormData.js +13 -20
- package/dist/utils/Data/setupFormData.test.js +48 -47
- package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
- package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
- package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
- package/dist/utils/FormPage/getConditionalText.js +4 -4
- package/dist/utils/FormPage/getConditionalText.test.js +30 -30
- package/dist/utils/FormPage/getFormPage.js +12 -15
- package/dist/utils/FormPage/getFormPage.test.js +23 -24
- package/dist/utils/FormPage/getFormPages.js +8 -11
- package/dist/utils/FormPage/getFormPages.test.js +15 -16
- package/dist/utils/FormPage/getPageActions.js +10 -13
- package/dist/utils/FormPage/getPageActions.test.js +33 -33
- package/dist/utils/FormPage/getParagraphFromText.js +5 -7
- package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
- package/dist/utils/FormPage/index.js +3 -5
- package/dist/utils/FormPage/showFormPage.js +4 -8
- package/dist/utils/FormPage/showFormPage.test.js +33 -33
- package/dist/utils/FormPage/showFormPageCYA.js +2 -2
- package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
- package/dist/utils/FormPage/useComponent.js +15 -23
- package/dist/utils/FormPage/useComponent.test.js +49 -50
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +19 -19
- package/dist/utils/Format/formatDataForComponent.js +6 -7
- package/dist/utils/Format/formatDataForComponent.test.js +50 -78
- package/dist/utils/Format/formatDataForForm.js +5 -6
- package/dist/utils/Format/formatDataForForm.test.js +14 -17
- package/dist/utils/Format/formatDataForPage.js +4 -5
- package/dist/utils/Format/formatDataForPage.test.js +20 -25
- package/dist/utils/Format/index.js +2 -2
- package/dist/utils/Hub/getFormHub.js +2 -2
- package/dist/utils/Hub/getFormHub.test.js +23 -24
- package/dist/utils/Hub/index.js +2 -2
- package/dist/utils/Meta/constants.js +2 -2
- package/dist/utils/Meta/documents/getDocuments.js +1 -1
- package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
- package/dist/utils/Meta/documents/index.js +2 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
- package/dist/utils/Meta/index.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
- package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
- package/dist/utils/Operate/deleteValueInFormData.js +2 -2
- package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
- package/dist/utils/Operate/getFirstOf.js +6 -6
- package/dist/utils/Operate/getFirstOf.test.js +32 -32
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
- package/dist/utils/Operate/getLength.js +9 -9
- package/dist/utils/Operate/getLength.test.js +19 -19
- package/dist/utils/Operate/index.js +2 -2
- package/dist/utils/Operate/persistValueInFormData.js +4 -4
- package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
- package/dist/utils/Operate/runPageOperations.js +8 -8
- package/dist/utils/Operate/runPageOperations.test.js +24 -25
- package/dist/utils/Operate/setValueInFormData.js +3 -3
- package/dist/utils/Operate/setValueInFormData.test.js +17 -17
- package/dist/utils/Operate/shouldRun.js +7 -7
- package/dist/utils/Operate/shouldRun.test.js +22 -24
- package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
- package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
- package/dist/utils/Validate/additional/index.js +8 -8
- package/dist/utils/Validate/additional/index.test.js +22 -22
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
- package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
- package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -12
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -3
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
- package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
- package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +35 -36
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
- package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
- package/dist/utils/Validate/additional/utils.js +9 -22
- package/dist/utils/Validate/index.js +2 -2
- package/dist/utils/Validate/validateCollection.js +18 -23
- package/dist/utils/Validate/validateCollection.test.js +75 -67
- package/dist/utils/Validate/validateComponent.js +19 -19
- package/dist/utils/Validate/validateComponent.test.js +179 -154
- package/dist/utils/Validate/validateContainer.js +14 -17
- package/dist/utils/Validate/validateContainer.test.js +59 -53
- package/dist/utils/Validate/validateDate.js +16 -22
- package/dist/utils/Validate/validateDate.test.js +31 -32
- package/dist/utils/Validate/validateEmail.js +7 -9
- package/dist/utils/Validate/validateEmail.test.js +27 -27
- package/dist/utils/Validate/validateMultifile.js +5 -7
- package/dist/utils/Validate/validateMultifile.test.js +17 -18
- package/dist/utils/Validate/validatePage.js +13 -18
- package/dist/utils/Validate/validatePage.test.js +198 -195
- package/dist/utils/Validate/validateRegex.js +3 -5
- package/dist/utils/Validate/validateRegex.test.js +15 -15
- package/dist/utils/Validate/validateRequired.js +4 -6
- package/dist/utils/Validate/validateRequired.test.js +19 -19
- package/dist/utils/Validate/validateTextArea.js +4 -6
- package/dist/utils/Validate/validateTextArea.test.js +21 -21
- package/dist/utils/Validate/validateTime.js +12 -19
- package/dist/utils/Validate/validateTime.test.js +27 -27
- package/dist/utils/index.js +5 -6
- package/package.json +2 -4
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
var _models = require("../../models");
|
|
4
4
|
var _setupTests = require("../../setupTests");
|
|
5
5
|
var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
|
|
6
|
-
function _interopRequireDefault(
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _defineProperty(
|
|
11
|
-
function _toPropertyKey(
|
|
12
|
-
function _toPrimitive(
|
|
13
|
-
describe('utils.CheckYourAnswers.getCYARowsForCollection',
|
|
14
|
-
it('should get a single entry point row when there are no items',
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
11
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Local imports
|
|
12
|
+
describe('utils.CheckYourAnswers.getCYARowsForCollection', () => {
|
|
13
|
+
it('should get a single entry point row when there are no items', () => {
|
|
14
|
+
const FORM_DATA = undefined;
|
|
15
|
+
const PAGE = {
|
|
17
16
|
id: 'page',
|
|
18
17
|
components: [{
|
|
19
18
|
labels: {
|
|
@@ -23,42 +22,42 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
23
22
|
formData: FORM_DATA,
|
|
24
23
|
cya_link: {}
|
|
25
24
|
};
|
|
26
|
-
|
|
25
|
+
const COMPONENT = {
|
|
27
26
|
type: 'text',
|
|
28
27
|
readonly: true,
|
|
29
28
|
id: 'a',
|
|
30
29
|
fieldId: 'a',
|
|
31
30
|
label: 'Alpha'
|
|
32
31
|
};
|
|
33
|
-
|
|
32
|
+
const COLLECTION = {
|
|
34
33
|
id: 'collection',
|
|
35
34
|
fieldId: 'collection',
|
|
36
35
|
type: _models.ComponentTypes.COLLECTION,
|
|
37
36
|
item: [COMPONENT]
|
|
38
37
|
};
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const ON_ACTION = () => {};
|
|
39
|
+
const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, undefined, ON_ACTION);
|
|
41
40
|
expect(ROWS.length).toEqual(1);
|
|
42
41
|
});
|
|
43
|
-
it('should get an appropriate row for a collection with a single readonly text component',
|
|
44
|
-
|
|
42
|
+
it('should get an appropriate row for a collection with a single readonly text component', () => {
|
|
43
|
+
const FORM_DATA = {
|
|
45
44
|
collection: [{
|
|
46
45
|
a: 'Bravo'
|
|
47
46
|
}]
|
|
48
47
|
};
|
|
49
|
-
|
|
48
|
+
const PAGE = {
|
|
50
49
|
id: 'page',
|
|
51
50
|
formData: FORM_DATA,
|
|
52
51
|
cya_link: {}
|
|
53
52
|
};
|
|
54
|
-
|
|
53
|
+
const COMPONENT = {
|
|
55
54
|
type: 'text',
|
|
56
55
|
readonly: true,
|
|
57
56
|
id: 'a',
|
|
58
57
|
fieldId: 'a',
|
|
59
58
|
label: 'Alpha'
|
|
60
59
|
};
|
|
61
|
-
|
|
60
|
+
const COLLECTION = {
|
|
62
61
|
id: 'collection',
|
|
63
62
|
fieldId: 'collection',
|
|
64
63
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -67,8 +66,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
67
66
|
value: FORM_DATA.collection,
|
|
68
67
|
formData: FORM_DATA
|
|
69
68
|
};
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const ON_ACTION = () => {};
|
|
70
|
+
const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
|
|
72
71
|
expect(ROWS.length).toEqual(2); // Item title row + component row
|
|
73
72
|
(0, _setupTests.expectObjectLike)(ROWS[0], {
|
|
74
73
|
pageId: PAGE.id,
|
|
@@ -91,25 +90,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
91
90
|
value: 'Bravo'
|
|
92
91
|
});
|
|
93
92
|
});
|
|
94
|
-
it('should get an appropriate row for a collection with a single readonly text component where the item label is an empty string',
|
|
95
|
-
|
|
93
|
+
it('should get an appropriate row for a collection with a single readonly text component where the item label is an empty string', () => {
|
|
94
|
+
const FORM_DATA = {
|
|
96
95
|
collection: [{
|
|
97
96
|
a: 'Bravo'
|
|
98
97
|
}]
|
|
99
98
|
};
|
|
100
|
-
|
|
99
|
+
const PAGE = {
|
|
101
100
|
id: 'page',
|
|
102
101
|
formData: FORM_DATA,
|
|
103
102
|
cya_link: {}
|
|
104
103
|
};
|
|
105
|
-
|
|
104
|
+
const COMPONENT = {
|
|
106
105
|
type: 'text',
|
|
107
106
|
readonly: true,
|
|
108
107
|
id: 'a',
|
|
109
108
|
fieldId: 'a',
|
|
110
109
|
label: 'Alpha'
|
|
111
110
|
};
|
|
112
|
-
|
|
111
|
+
const COLLECTION = {
|
|
113
112
|
id: 'collection',
|
|
114
113
|
fieldId: 'collection',
|
|
115
114
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -121,8 +120,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
121
120
|
value: FORM_DATA.collection,
|
|
122
121
|
formData: FORM_DATA
|
|
123
122
|
};
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
const ON_ACTION = () => {};
|
|
124
|
+
const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
|
|
126
125
|
expect(ROWS.length).toEqual(1); // Just the component row, no title row
|
|
127
126
|
(0, _setupTests.expectObjectLike)(ROWS[0], {
|
|
128
127
|
pageId: PAGE.id,
|
|
@@ -136,26 +135,26 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
136
135
|
value: 'Bravo'
|
|
137
136
|
});
|
|
138
137
|
});
|
|
139
|
-
it('should interpolate a field label appropriately',
|
|
140
|
-
|
|
138
|
+
it('should interpolate a field label appropriately', () => {
|
|
139
|
+
const FORM_DATA = {
|
|
141
140
|
collection: [{
|
|
142
141
|
a: 'Bravo'
|
|
143
142
|
}]
|
|
144
143
|
};
|
|
145
|
-
|
|
144
|
+
const PAGE = {
|
|
146
145
|
id: 'page',
|
|
147
146
|
formData: FORM_DATA,
|
|
148
147
|
cya_link: {}
|
|
149
148
|
};
|
|
150
149
|
// eslint-disable-next-line no-template-curly-in-string
|
|
151
|
-
|
|
150
|
+
const COMPONENT = {
|
|
152
151
|
type: 'text',
|
|
153
152
|
readonly: true,
|
|
154
153
|
id: 'a',
|
|
155
154
|
fieldId: 'a',
|
|
156
155
|
label: 'Alpha ${index}'
|
|
157
156
|
};
|
|
158
|
-
|
|
157
|
+
const COLLECTION = {
|
|
159
158
|
id: 'collection',
|
|
160
159
|
fieldId: 'collection',
|
|
161
160
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -163,8 +162,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
163
162
|
value: FORM_DATA.collection,
|
|
164
163
|
formData: FORM_DATA
|
|
165
164
|
};
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
const ON_ACTION = () => {};
|
|
166
|
+
const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
|
|
168
167
|
expect(ROWS.length).toEqual(2); // Title and item row.
|
|
169
168
|
(0, _setupTests.expectObjectLike)(ROWS[1], {
|
|
170
169
|
pageId: PAGE.id,
|
|
@@ -177,29 +176,28 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
177
176
|
full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
|
|
178
177
|
label: 'Alpha 1' // no countOffset
|
|
179
178
|
}),
|
|
180
|
-
|
|
181
179
|
value: 'Bravo'
|
|
182
180
|
});
|
|
183
181
|
});
|
|
184
|
-
it('should ignore the result of the override function if it returns nullish',
|
|
185
|
-
|
|
182
|
+
it('should ignore the result of the override function if it returns nullish', () => {
|
|
183
|
+
const FORM_DATA = {
|
|
186
184
|
collection: [{
|
|
187
185
|
a: 'Bravo'
|
|
188
186
|
}]
|
|
189
187
|
};
|
|
190
|
-
|
|
188
|
+
const PAGE = {
|
|
191
189
|
id: 'page',
|
|
192
190
|
formData: FORM_DATA,
|
|
193
191
|
cya_link: {}
|
|
194
192
|
};
|
|
195
|
-
|
|
193
|
+
const COMPONENT = {
|
|
196
194
|
type: 'text',
|
|
197
195
|
readonly: true,
|
|
198
196
|
id: 'a',
|
|
199
197
|
fieldId: 'a',
|
|
200
198
|
label: 'Alpha'
|
|
201
199
|
};
|
|
202
|
-
|
|
200
|
+
const COLLECTION = {
|
|
203
201
|
id: 'collection',
|
|
204
202
|
fieldId: 'collection',
|
|
205
203
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -208,10 +206,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
208
206
|
value: FORM_DATA.collection,
|
|
209
207
|
formData: FORM_DATA
|
|
210
208
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return null;
|
|
214
|
-
});
|
|
209
|
+
const ON_ACTION = () => {};
|
|
210
|
+
const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, () => null);
|
|
215
211
|
expect(ROWS.length).toEqual(2); // Item title row + component row
|
|
216
212
|
(0, _setupTests.expectObjectLike)(ROWS[0], {
|
|
217
213
|
pageId: PAGE.id,
|
|
@@ -234,25 +230,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
234
230
|
value: 'Bravo'
|
|
235
231
|
});
|
|
236
232
|
});
|
|
237
|
-
it('should use rows produced by the override function if provided',
|
|
238
|
-
|
|
233
|
+
it('should use rows produced by the override function if provided', () => {
|
|
234
|
+
const FORM_DATA = {
|
|
239
235
|
collection: [{
|
|
240
236
|
a: 'Bravo'
|
|
241
237
|
}]
|
|
242
238
|
};
|
|
243
|
-
|
|
239
|
+
const PAGE = {
|
|
244
240
|
id: 'page',
|
|
245
241
|
formData: FORM_DATA,
|
|
246
242
|
cya_link: {}
|
|
247
243
|
};
|
|
248
|
-
|
|
244
|
+
const COMPONENT = {
|
|
249
245
|
type: 'text',
|
|
250
246
|
readonly: true,
|
|
251
247
|
id: 'a',
|
|
252
248
|
fieldId: 'a',
|
|
253
249
|
label: 'Alpha'
|
|
254
250
|
};
|
|
255
|
-
|
|
251
|
+
const COLLECTION = {
|
|
256
252
|
id: 'collection',
|
|
257
253
|
fieldId: 'collection',
|
|
258
254
|
type: _models.ComponentTypes.COLLECTION,
|
|
@@ -261,16 +257,16 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
|
|
|
261
257
|
value: FORM_DATA.collection,
|
|
262
258
|
formData: FORM_DATA
|
|
263
259
|
};
|
|
264
|
-
|
|
260
|
+
const ON_ACTION = () => {};
|
|
265
261
|
// eslint-disable-next-line arrow-body-style
|
|
266
|
-
|
|
262
|
+
const OVERRIDE = (page, comp) => {
|
|
267
263
|
// This will be called for each component in the collection,
|
|
268
264
|
// returning a custom row object.
|
|
269
265
|
return {
|
|
270
266
|
key: "CustomRowFor".concat(comp.label)
|
|
271
267
|
};
|
|
272
268
|
};
|
|
273
|
-
|
|
269
|
+
const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, OVERRIDE);
|
|
274
270
|
expect(ROWS.length).toEqual(2); // Item title row + component row
|
|
275
271
|
(0, _setupTests.expectObjectLike)(ROWS[0], {
|
|
276
272
|
pageId: PAGE.id,
|
|
@@ -12,41 +12,30 @@ var _showFormPageCYA = _interopRequireDefault(require("../FormPage/showFormPageC
|
|
|
12
12
|
var _getCYACollectionDeleteAction = _interopRequireDefault(require("./getCYACollectionDeleteAction"));
|
|
13
13
|
var _getCYACollectionChangeAction = _interopRequireDefault(require("./getCYACollectionChangeAction"));
|
|
14
14
|
var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
|
|
15
|
-
function _interopRequireDefault(
|
|
16
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
22
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
24
17
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
|
-
function _defineProperty(
|
|
26
|
-
function _toPropertyKey(
|
|
27
|
-
function _toPrimitive(
|
|
18
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Global imports
|
|
28
21
|
// Local imports
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCount, fullPath) {
|
|
47
|
-
var labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), page.collection.labels);
|
|
22
|
+
const getContainerForPage = (page, item, labelCount, fullPath) => ({
|
|
23
|
+
id: item.id,
|
|
24
|
+
fieldId: item.id,
|
|
25
|
+
type: _models.ComponentTypes.CONTAINER,
|
|
26
|
+
required: true,
|
|
27
|
+
full_path: fullPath,
|
|
28
|
+
components: page.components.map(component => _objectSpread(_objectSpread({}, component), {}, {
|
|
29
|
+
label: _copReactComponents.Utils.interpolateString(component.label, _objectSpread(_objectSpread({}, item), {}, {
|
|
30
|
+
index: labelCount
|
|
31
|
+
})),
|
|
32
|
+
full_path: "".concat(fullPath, ".").concat(component.fieldId)
|
|
33
|
+
}))
|
|
34
|
+
});
|
|
35
|
+
const getTitleRowForItem = (page, item, pageId, labelCount, fullPath) => {
|
|
36
|
+
const labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), page.collection.labels);
|
|
48
37
|
return {
|
|
49
|
-
pageId
|
|
38
|
+
pageId,
|
|
50
39
|
fieldId: 'Title',
|
|
51
40
|
full_path: "".concat(fullPath, ".Title"),
|
|
52
41
|
key: _copReactComponents.Utils.interpolateString(labels.item, _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -56,12 +45,12 @@ var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCo
|
|
|
56
45
|
size: page.collection.titleSize || 's'
|
|
57
46
|
};
|
|
58
47
|
};
|
|
59
|
-
|
|
48
|
+
const getHeadingRow = (config, pageId, labelCount, changeAction, item) => {
|
|
60
49
|
if (config.text === '') {
|
|
61
50
|
return null;
|
|
62
51
|
}
|
|
63
52
|
return {
|
|
64
|
-
pageId
|
|
53
|
+
pageId,
|
|
65
54
|
fieldId: "heading".concat(labelCount),
|
|
66
55
|
full_path: "heading".concat(labelCount),
|
|
67
56
|
key: _copReactComponents.Utils.interpolateString(config.text, item),
|
|
@@ -73,24 +62,22 @@ var getHeadingRow = function getHeadingRow(config, pageId, labelCount, changeAct
|
|
|
73
62
|
}
|
|
74
63
|
};
|
|
75
64
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
var getActionRows = function getActionRows(page, item, onAction, labelCount) {
|
|
65
|
+
const getCollectionNameHeading = (page, titleName, config, changeAction) => ({
|
|
66
|
+
pageId: page.id,
|
|
67
|
+
fieldId: "".concat(page.collection.name, "Title"),
|
|
68
|
+
full_path: "".concat(page.collection.name, "Title"),
|
|
69
|
+
key: (config === null || config === void 0 ? void 0 : config.text) || titleName.charAt(0).toUpperCase() + titleName.slice(1),
|
|
70
|
+
type: changeAction == null ? 'heading' : 'headingWithAction',
|
|
71
|
+
size: (config === null || config === void 0 ? void 0 : config.size) || 'm',
|
|
72
|
+
action: changeAction === null ? null : {
|
|
73
|
+
onAction: changeAction,
|
|
74
|
+
label: 'Change'
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const getActionRows = function (page, item, onAction, labelCount) {
|
|
91
78
|
var _page$collection;
|
|
92
|
-
|
|
93
|
-
return (_page$collection = page.collection) === null || _page$collection === void 0 || (_page$collection = _page$collection.actions) === null || _page$collection === void 0 ? void 0 : _page$collection.map(
|
|
79
|
+
let activeIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
80
|
+
return (_page$collection = page.collection) === null || _page$collection === void 0 || (_page$collection = _page$collection.actions) === null || _page$collection === void 0 ? void 0 : _page$collection.map(action => {
|
|
94
81
|
if (action.type === 'remove') {
|
|
95
82
|
return (0, _getCYACollectionDeleteAction.default)(page, item, onAction, labelCount, action, activeIds);
|
|
96
83
|
}
|
|
@@ -98,24 +85,20 @@ var getActionRows = function getActionRows(page, item, onAction, labelCount) {
|
|
|
98
85
|
return (0, _getCYACollectionChangeAction.default)(page, item, onAction, labelCount, action, activeIds);
|
|
99
86
|
}
|
|
100
87
|
return null;
|
|
101
|
-
}).filter(
|
|
102
|
-
return !!action;
|
|
103
|
-
});
|
|
88
|
+
}).filter(action => !!action);
|
|
104
89
|
};
|
|
105
90
|
|
|
106
91
|
// eslint-disable-next-line arrow-body-style
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
const getChangeActionForPage = function (page, onAction) {
|
|
93
|
+
let activeIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
94
|
+
return () => {
|
|
95
|
+
const changeCallback = changeData => {
|
|
96
|
+
const data = changeData;
|
|
112
97
|
// Looping over the keys here as applying the changes
|
|
113
98
|
// as 'let data = { ...data, ...activeIds }' seemed wasteful,
|
|
114
99
|
// data could be a huge object.
|
|
115
|
-
Object.entries(activeIds).forEach(
|
|
116
|
-
|
|
117
|
-
activeIdKey = _entry[0],
|
|
118
|
-
activeId = _entry[1];
|
|
100
|
+
Object.entries(activeIds).forEach(entry => {
|
|
101
|
+
const [activeIdKey, activeId] = entry;
|
|
119
102
|
data[activeIdKey] = activeId;
|
|
120
103
|
});
|
|
121
104
|
return data;
|
|
@@ -139,10 +122,10 @@ var getChangeActionForPage = function getChangeActionForPage(page, onAction) {
|
|
|
139
122
|
* @param {Object} activeIds The active IDs that must be set for the current item to be active.
|
|
140
123
|
* @returns An array of CYA rows for all child pages.
|
|
141
124
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
childPages.forEach(
|
|
145
|
-
|
|
125
|
+
const getCYARowsForChildPages = (childPages, item, onAction, fnOverride, labelCount, fullPath, activeIds) => {
|
|
126
|
+
let rows = [];
|
|
127
|
+
childPages.forEach(p => {
|
|
128
|
+
let childPage = p;
|
|
146
129
|
// If the child page is itself a master page, then we should produce the
|
|
147
130
|
// rows for it and it's children.
|
|
148
131
|
if (childPage.collection.masterPage) {
|
|
@@ -153,21 +136,21 @@ var getCYARowsForChildPages = function getCYARowsForChildPages(childPages, item,
|
|
|
153
136
|
// pages. Regular show_whens can now be used and this code should be removed
|
|
154
137
|
// at some point.
|
|
155
138
|
if (childPage.collection.route) {
|
|
156
|
-
|
|
139
|
+
const pageWithRoute = (0, _addShowWhen.default)(childPage, childPage.collection.route);
|
|
157
140
|
childPage = pageWithRoute || childPage;
|
|
158
141
|
}
|
|
159
142
|
// Check that the child page was actually shown to the user. This has
|
|
160
143
|
// to be done here as the show_when checks could rely upon item-level
|
|
161
144
|
// data.
|
|
162
145
|
if ((0, _showFormPageCYA.default)(childPage, _objectSpread(_objectSpread({}, childPage.formData), item))) {
|
|
163
|
-
|
|
146
|
+
const changeAction = getChangeActionForPage(childPage, onAction, activeIds);
|
|
164
147
|
if (childPage.collection.heading) {
|
|
165
|
-
|
|
166
|
-
|
|
148
|
+
const headingAction = childPage.collection.heading.changeLink ? changeAction : null;
|
|
149
|
+
const headingRow = getHeadingRow(childPage.collection.heading, childPage.id, labelCount, headingAction, item);
|
|
167
150
|
rows = rows.concat(headingRow);
|
|
168
151
|
}
|
|
169
|
-
|
|
170
|
-
|
|
152
|
+
const container = getContainerForPage(childPage, item, labelCount, fullPath);
|
|
153
|
+
const containerRows = (0, _getCYARowsForContainer.default)(_objectSpread(_objectSpread({}, childPage), {}, {
|
|
171
154
|
formData: _objectSpread(_objectSpread({}, childPage.formData), item)
|
|
172
155
|
}), container, _objectSpread(_objectSpread({}, childPage.formData), item), changeAction, fnOverride);
|
|
173
156
|
rows = rows.concat(containerRows);
|
|
@@ -187,33 +170,33 @@ var getCYARowsForChildPages = function getCYARowsForChildPages(childPages, item,
|
|
|
187
170
|
* @param {Object} activeIds The active IDs that must be set for the current item to be active.
|
|
188
171
|
* @returns An array of CYA rows.
|
|
189
172
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
173
|
+
const getCYARowsForCollectionPage = function (page, onAction, fnOverride, data) {
|
|
174
|
+
let activeIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
175
|
+
const collectionName = page.collection.name.split('.').pop();
|
|
176
|
+
let collectionData = data[collectionName] || null;
|
|
177
|
+
const activeId = data["".concat(collectionName, "ActiveId")];
|
|
195
178
|
if (!collectionData || collectionData.length === 0) {
|
|
196
179
|
return [];
|
|
197
180
|
}
|
|
198
|
-
|
|
181
|
+
let rows = [];
|
|
199
182
|
if (!page.collection.hideNameFromCYA) {
|
|
200
183
|
var _page$collection$coll;
|
|
201
|
-
|
|
184
|
+
const headingChangeAction = (_page$collection$coll = page.collection.collectionHeading) !== null && _page$collection$coll !== void 0 && _page$collection$coll.changeLinkPage ? getChangeActionForPage({
|
|
202
185
|
id: page.collection.collectionHeading.changeLinkPage
|
|
203
186
|
}, onAction, activeIds) : null;
|
|
204
187
|
rows.push(getCollectionNameHeading(page, collectionName, page.collection.collectionHeading, headingChangeAction));
|
|
205
188
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
189
|
+
let itemIndex = 0;
|
|
190
|
+
const hideItemTitles = Array.isArray(page.collection.hideItemTitles) ? (0, _meetsAllConditions.default)(page.collection.hideItemTitles, data) : page.collection.hideItemTitles;
|
|
191
|
+
const onlyShowActiveEntry = Array.isArray(page.collection.onlyShowActiveEntryOnCYA) ? (0, _meetsAllConditions.default)(page.collection.onlyShowActiveEntryOnCYA, data) : page.collection.onlyShowActiveEntryOnCYA;
|
|
209
192
|
if (onlyShowActiveEntry) {
|
|
210
|
-
|
|
193
|
+
const activeEntry = collectionData.find((entry, index) => {
|
|
211
194
|
itemIndex = index;
|
|
212
195
|
return entry.id === activeId;
|
|
213
196
|
});
|
|
214
197
|
collectionData = [activeEntry];
|
|
215
198
|
}
|
|
216
|
-
collectionData.forEach(
|
|
199
|
+
collectionData.forEach(item => {
|
|
217
200
|
var _page$collection2;
|
|
218
201
|
if (!item) {
|
|
219
202
|
return; // Skip this iteration if item is undefined
|
|
@@ -222,13 +205,15 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
|
|
|
222
205
|
// This helps us make sure the right entry is being affected
|
|
223
206
|
// by change/remove links.
|
|
224
207
|
// eslint-disable-next-line no-param-reassign
|
|
225
|
-
activeIds = _objectSpread(_objectSpread({}, activeIds), {},
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
208
|
+
activeIds = _objectSpread(_objectSpread({}, activeIds), {}, {
|
|
209
|
+
["".concat(collectionName, "ActiveId")]: item.id
|
|
210
|
+
});
|
|
211
|
+
const labelCount = itemIndex + 1;
|
|
212
|
+
const actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
|
|
213
|
+
const fullPath = "".concat(page.collection.name, "[").concat(itemIndex, "]");
|
|
214
|
+
const actionRows = getActionRows(page, item, onAction, labelCount, activeIds);
|
|
230
215
|
if (!hideItemTitles) {
|
|
231
|
-
|
|
216
|
+
const titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
|
|
232
217
|
rows = rows.concat(titleRow);
|
|
233
218
|
}
|
|
234
219
|
if (actionPosition === 'top') {
|
|
@@ -240,8 +225,6 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
|
|
|
240
225
|
}
|
|
241
226
|
itemIndex += 1;
|
|
242
227
|
});
|
|
243
|
-
return rows.filter(
|
|
244
|
-
return !!row;
|
|
245
|
-
});
|
|
228
|
+
return rows.filter(row => !!row);
|
|
246
229
|
};
|
|
247
230
|
var _default = exports.default = getCYARowsForCollectionPage;
|