@ukhomeoffice/cop-react-form-renderer 6.7.0-alpha → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +22 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +180 -92
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +137 -103
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +861 -463
- package/dist/components/CollectionPage/CollectionPage.js +63 -73
- package/dist/components/CollectionPage/CollectionPage.test.js +366 -316
- package/dist/components/CollectionSummary/BannerStrip.js +13 -13
- package/dist/components/CollectionSummary/BannerStrip.test.js +76 -80
- package/dist/components/CollectionSummary/CollectionSummary.js +126 -99
- package/dist/components/CollectionSummary/CollectionSummary.test.js +188 -152
- package/dist/components/CollectionSummary/Confirmation.js +12 -14
- package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
- package/dist/components/CollectionSummary/RenderListView.js +52 -46
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +77 -78
- package/dist/components/CollectionSummary/SummaryCard.js +152 -110
- package/dist/components/CollectionSummary/SummaryCard.test.js +1018 -929
- package/dist/components/CollectionSummary/SummaryCardDetails.js +137 -94
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +13 -4
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +331 -128
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +35 -30
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +74 -62
- package/dist/components/FormComponent/Collection.js +108 -74
- package/dist/components/FormComponent/Collection.test.js +1081 -909
- package/dist/components/FormComponent/Container.js +39 -40
- package/dist/components/FormComponent/Container.test.js +412 -312
- package/dist/components/FormComponent/FormComponent.js +72 -69
- package/dist/components/FormComponent/FormComponent.test.js +414 -353
- package/dist/components/FormComponent/helpers/addLabel.js +7 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
- package/dist/components/FormComponent/helpers/getComponentError.js +5 -3
- package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
- package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
- package/dist/components/FormComponent/helpers/index.js +4 -4
- package/dist/components/FormPage/FormPage.js +80 -65
- package/dist/components/FormPage/FormPage.test.js +163 -127
- package/dist/components/FormRenderer/FormRenderer.js +180 -143
- package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
- package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
- package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
- package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
- package/dist/components/FormRenderer/handlers/index.js +1 -1
- package/dist/components/FormRenderer/handlers/navigate.js +3 -3
- 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 +15 -15
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
- package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
- package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
- package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
- package/dist/components/FormRenderer/helpers/getPage.js +4 -2
- package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +97 -103
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +78 -71
- package/dist/components/FormRenderer/helpers/index.js +1 -1
- package/dist/components/FormRenderer/onCYAAction.js +51 -59
- package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
- package/dist/components/FormRenderer/onPageAction.js +39 -43
- package/dist/components/FormRenderer/onPageAction.test.js +208 -223
- package/dist/components/FormRenderer/onTaskAction.js +13 -9
- package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
- package/dist/components/PageActions/ActionButton.js +15 -12
- package/dist/components/PageActions/ActionButton.test.js +78 -56
- package/dist/components/PageActions/PageActions.js +10 -10
- package/dist/components/PageActions/PageActions.test.js +115 -86
- package/dist/components/SummaryList/GroupAction.js +17 -9
- package/dist/components/SummaryList/GroupAction.test.js +33 -37
- package/dist/components/SummaryList/RowAction.js +16 -11
- package/dist/components/SummaryList/RowAction.test.js +33 -37
- package/dist/components/SummaryList/SummaryList.js +34 -21
- package/dist/components/SummaryList/SummaryList.scss +15 -0
- package/dist/components/SummaryList/SummaryList.test.js +226 -143
- package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +53 -0
- package/dist/components/SummaryList/SummaryListHeadingRowWithAction.scss +38 -0
- package/dist/components/SummaryList/SummaryListRow.js +4 -6
- package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
- package/dist/components/SummaryList/helpers/index.js +1 -1
- package/dist/components/TaskList/Task.js +29 -19
- package/dist/components/TaskList/Task.test.js +76 -83
- package/dist/components/TaskList/TaskList.js +92 -49
- package/dist/components/TaskList/TaskList.scss +24 -0
- package/dist/components/TaskList/TaskList.test.js +255 -113
- package/dist/components/TaskList/TaskState.js +5 -7
- package/dist/components/TaskList/TaskState.test.js +45 -52
- package/dist/components/index.js +7 -7
- package/dist/context/HooksContext/HooksContext.js +80 -57
- package/dist/context/HooksContext/HooksContext.test.js +35 -26
- package/dist/context/HooksContext/index.js +4 -3
- package/dist/context/ValidationContext/ValidationContext.js +94 -43
- package/dist/context/ValidationContext/ValidationContext.test.js +68 -56
- package/dist/context/ValidationContext/index.js +4 -3
- package/dist/context/index.js +2 -2
- package/dist/hooks/index.js +10 -9
- package/dist/hooks/useAxios.js +40 -14
- package/dist/hooks/useGetRequest.js +97 -61
- package/dist/hooks/useHooks.js +3 -1
- package/dist/hooks/useRefData.js +39 -26
- package/dist/hooks/useValidation.js +3 -1
- package/dist/index.js +14 -13
- 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 +38 -44
- package/dist/models/TaskStates.js +28 -29
- package/dist/models/index.js +9 -9
- package/dist/setupTests.js +31 -30
- package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
- package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +61 -58
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +108 -87
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +281 -162
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +42 -0
- package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +56 -0
- package/dist/utils/CheckYourAnswers/index.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -17
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +22 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +38 -47
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
- package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
- package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
- package/dist/utils/CollectionPage/getErrorsForCollection.js +24 -24
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +22 -20
- package/dist/utils/CollectionPage/getQuickEditPage.js +31 -35
- package/dist/utils/CollectionPage/getQuickEditPage.test.js +27 -15
- package/dist/utils/CollectionPage/index.js +1 -1
- package/dist/utils/CollectionPage/mergeCollectionPages.js +43 -31
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +26 -26
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
- package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
- package/dist/utils/CollectionPage/setCollectionPageData.js +16 -10
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +24 -24
- package/dist/utils/Component/addShowWhen.js +8 -4
- package/dist/utils/Component/addShowWhen.test.js +37 -37
- package/dist/utils/Component/applyToComponentTree.js +18 -18
- package/dist/utils/Component/applyToComponentTree.test.js +32 -27
- package/dist/utils/Component/cleanAttributes.js +13 -10
- package/dist/utils/Component/cleanAttributes.test.js +18 -17
- package/dist/utils/Component/elevateNestedComponents.js +7 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +68 -30
- package/dist/utils/Component/getComponent.js +94 -88
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +72 -57
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
- package/dist/utils/Component/getDefaultValue.js +8 -6
- package/dist/utils/Component/getDefaultValue.test.js +12 -12
- package/dist/utils/Component/getDefaultValueFromConfig.js +21 -22
- package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
- package/dist/utils/Component/index.js +1 -1
- package/dist/utils/Component/isEditable.js +4 -2
- package/dist/utils/Component/isEditable.test.js +15 -14
- package/dist/utils/Component/optionIsSelected.js +6 -1
- package/dist/utils/Component/optionIsSelected.test.js +35 -9
- package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
- package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
- package/dist/utils/Component/showComponent.js +1 -1
- package/dist/utils/Component/showComponent.test.js +28 -28
- package/dist/utils/Component/wrapInFormGroup.js +2 -2
- package/dist/utils/Condition/index.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +8 -8
- package/dist/utils/Condition/meetsAllConditions.test.js +20 -20
- package/dist/utils/Condition/meetsCondition.js +25 -16
- package/dist/utils/Condition/meetsCondition.test.js +402 -402
- package/dist/utils/Condition/meetsOneCondition.js +5 -5
- package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
- package/dist/utils/Condition/setupConditions.js +18 -13
- package/dist/utils/Condition/setupConditions.test.js +7 -7
- package/dist/utils/Container/getEditableComponents.js +5 -3
- package/dist/utils/Container/getEditableComponents.test.js +45 -43
- package/dist/utils/Container/index.js +1 -1
- package/dist/utils/Container/setupNesting.js +20 -16
- package/dist/utils/Container/setupNesting.test.js +30 -27
- package/dist/utils/Container/showContainer.js +7 -3
- package/dist/utils/Container/showContainer.test.js +30 -30
- package/dist/utils/Data/applyFormula.js +48 -38
- package/dist/utils/Data/applyFormula.test.js +20 -20
- package/dist/utils/Data/getAutocompleteSource.js +26 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
- package/dist/utils/Data/getDataPath.js +28 -18
- package/dist/utils/Data/getDataPath.test.js +12 -12
- package/dist/utils/Data/getOptions.js +30 -24
- package/dist/utils/Data/getOptions.test.js +27 -27
- package/dist/utils/Data/getSourceData.js +19 -6
- package/dist/utils/Data/getSourceData.test.js +80 -84
- package/dist/utils/Data/index.js +1 -1
- package/dist/utils/Data/nestInRefdataOptions.js +16 -9
- package/dist/utils/Data/nestInRefdataOptions.test.js +16 -16
- package/dist/utils/Data/refDataToOptions.js +13 -10
- package/dist/utils/Data/refDataToOptions.test.js +19 -19
- package/dist/utils/Data/setDataItem.js +8 -7
- package/dist/utils/Data/setDataItem.test.js +37 -37
- package/dist/utils/Data/setupFormData.js +21 -13
- package/dist/utils/Data/setupFormData.test.js +50 -51
- package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
- package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
- package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
- package/dist/utils/FormPage/getConditionalText.js +3 -3
- package/dist/utils/FormPage/getConditionalText.test.js +29 -29
- package/dist/utils/FormPage/getFormPage.js +16 -15
- package/dist/utils/FormPage/getFormPage.test.js +46 -47
- package/dist/utils/FormPage/getFormPages.js +12 -7
- package/dist/utils/FormPage/getFormPages.test.js +23 -20
- package/dist/utils/FormPage/getPageActions.js +15 -9
- package/dist/utils/FormPage/getPageActions.test.js +32 -32
- package/dist/utils/FormPage/getParagraphFromText.js +7 -5
- package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
- package/dist/utils/FormPage/index.js +4 -2
- package/dist/utils/FormPage/showFormPage.js +7 -3
- package/dist/utils/FormPage/showFormPage.test.js +32 -32
- package/dist/utils/FormPage/showFormPageCYA.js +1 -1
- package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
- package/dist/utils/FormPage/useComponent.js +28 -21
- package/dist/utils/FormPage/useComponent.test.js +79 -77
- package/dist/utils/Format/formatData.js +1 -1
- package/dist/utils/Format/formatData.test.js +18 -18
- package/dist/utils/Format/formatDataForComponent.js +6 -5
- package/dist/utils/Format/formatDataForComponent.test.js +78 -50
- package/dist/utils/Format/formatDataForForm.js +8 -6
- package/dist/utils/Format/formatDataForForm.test.js +16 -13
- package/dist/utils/Format/formatDataForPage.js +5 -4
- package/dist/utils/Format/formatDataForPage.test.js +25 -20
- package/dist/utils/Format/index.js +1 -1
- package/dist/utils/Hub/getFormHub.js +1 -1
- package/dist/utils/Hub/getFormHub.test.js +31 -28
- package/dist/utils/Hub/index.js +1 -1
- 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 +16 -24
- package/dist/utils/Meta/documents/index.js +1 -1
- package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
- package/dist/utils/Meta/index.js +1 -1
- package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
- package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
- package/dist/utils/Operate/getFirstOf.js +5 -5
- package/dist/utils/Operate/getFirstOf.test.js +31 -31
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +52 -46
- package/dist/utils/Operate/getLength.js +50 -0
- package/dist/utils/Operate/getLength.test.js +89 -0
- package/dist/utils/Operate/index.js +1 -1
- package/dist/utils/Operate/persistValueInFormData.js +3 -3
- package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
- package/dist/utils/Operate/runPageOperations.js +9 -7
- package/dist/utils/Operate/runPageOperations.test.js +36 -35
- package/dist/utils/Operate/setValueInFormData.js +2 -2
- package/dist/utils/Operate/setValueInFormData.test.js +16 -16
- package/dist/utils/Operate/shouldRun.js +6 -6
- package/dist/utils/Operate/shouldRun.test.js +27 -21
- package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
- package/dist/utils/Validate/additional/index.js +6 -6
- package/dist/utils/Validate/additional/index.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
- package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
- package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
- package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +11 -7
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
- package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +4 -4
- package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +39 -35
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
- package/dist/utils/Validate/additional/mustNotContainSql.js +4 -3
- package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +26 -28
- package/dist/utils/Validate/additional/utils.js +22 -9
- package/dist/utils/Validate/index.js +1 -1
- package/dist/utils/Validate/validateCollection.js +25 -19
- package/dist/utils/Validate/validateCollection.test.js +66 -74
- package/dist/utils/Validate/validateComponent.js +21 -18
- package/dist/utils/Validate/validateComponent.test.js +176 -166
- package/dist/utils/Validate/validateContainer.js +20 -15
- package/dist/utils/Validate/validateContainer.test.js +52 -58
- package/dist/utils/Validate/validateDate.js +21 -15
- package/dist/utils/Validate/validateDate.test.js +32 -31
- package/dist/utils/Validate/validateEmail.js +8 -6
- package/dist/utils/Validate/validateEmail.test.js +25 -25
- package/dist/utils/Validate/validateMultifile.js +7 -5
- package/dist/utils/Validate/validateMultifile.test.js +18 -17
- package/dist/utils/Validate/validatePage.js +22 -19
- package/dist/utils/Validate/validatePage.test.js +203 -215
- package/dist/utils/Validate/validateRegex.js +5 -3
- package/dist/utils/Validate/validateRegex.test.js +14 -14
- package/dist/utils/Validate/validateRequired.js +6 -4
- package/dist/utils/Validate/validateRequired.test.js +18 -18
- package/dist/utils/Validate/validateTextArea.js +6 -4
- package/dist/utils/Validate/validateTextArea.test.js +20 -20
- package/dist/utils/Validate/validateTime.js +26 -11
- package/dist/utils/Validate/validateTime.test.js +62 -16
- package/dist/utils/index.js +9 -7
- package/package.json +2 -2
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.js +0 -37
- package/dist/utils/CheckYourAnswers/getComponentRowForCYA.test.js +0 -41
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
4
|
var _getUpdatedSectionStates = _interopRequireDefault(require("./getUpdatedSectionStates"));
|
|
5
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
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); }
|
|
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; }
|
|
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; }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
12
|
+
describe('components.FormRenderer.helpers.getUpdatedSectionStates', function () {
|
|
13
|
+
describe('sequential tasks', function () {
|
|
14
|
+
it("should set all tasks to '".concat(_models.TaskStates.TYPES.CANNOT_START_YET, "' excluding the first which should be '").concat(_models.TaskStates.TYPES.NOT_STARTED, "'"), function () {
|
|
15
|
+
var SECTIONS = [{
|
|
12
16
|
name: 'Add event details',
|
|
13
17
|
tasks: [{
|
|
14
18
|
name: 'Date, location and mode details',
|
|
@@ -30,15 +34,15 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
30
34
|
pages: ['journeyDetails']
|
|
31
35
|
}]
|
|
32
36
|
}];
|
|
33
|
-
|
|
37
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, {});
|
|
34
38
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
35
39
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
36
40
|
expect(updatedSections[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
37
41
|
expect(updatedSections[1].tasks[1].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
38
42
|
expect(updatedSections[1].tasks[2].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
39
43
|
});
|
|
40
|
-
it("should set tasks after any '".concat(_models.TaskStates.TYPES.COMPLETE, "' ones to '").concat(_models.TaskStates.TYPES.NOT_STARTED, "'"), ()
|
|
41
|
-
|
|
44
|
+
it("should set tasks after any '".concat(_models.TaskStates.TYPES.COMPLETE, "' ones to '").concat(_models.TaskStates.TYPES.NOT_STARTED, "'"), function () {
|
|
45
|
+
var SECTIONS = [{
|
|
42
46
|
name: 'Add event details',
|
|
43
47
|
tasks: [{
|
|
44
48
|
name: 'Date, location and mode details',
|
|
@@ -48,17 +52,17 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
48
52
|
pages: ['officeDetails']
|
|
49
53
|
}]
|
|
50
54
|
}];
|
|
51
|
-
|
|
55
|
+
var TASKS = {
|
|
52
56
|
'Date, location and mode details': {
|
|
53
57
|
complete: true
|
|
54
58
|
}
|
|
55
59
|
};
|
|
56
|
-
|
|
60
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS);
|
|
57
61
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
58
62
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
59
63
|
});
|
|
60
|
-
it("should set tasks after any '".concat(_models.TaskStates.TYPES.COMPLETE, "' ones to '").concat(_models.TaskStates.TYPES.NOT_STARTED, " across different sections'"), ()
|
|
61
|
-
|
|
64
|
+
it("should set tasks after any '".concat(_models.TaskStates.TYPES.COMPLETE, "' ones to '").concat(_models.TaskStates.TYPES.NOT_STARTED, " across different sections'"), function () {
|
|
65
|
+
var SECTIONS = [{
|
|
62
66
|
name: 'Add event details',
|
|
63
67
|
tasks: [{
|
|
64
68
|
name: 'Date, location and mode details',
|
|
@@ -77,7 +81,7 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
77
81
|
pages: ['immigrationDate']
|
|
78
82
|
}]
|
|
79
83
|
}];
|
|
80
|
-
|
|
84
|
+
var TASKS = {
|
|
81
85
|
'Date, location and mode details': {
|
|
82
86
|
complete: true
|
|
83
87
|
},
|
|
@@ -85,14 +89,14 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
85
89
|
complete: true
|
|
86
90
|
}
|
|
87
91
|
};
|
|
88
|
-
|
|
92
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS);
|
|
89
93
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
90
94
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
91
95
|
expect(updatedSections[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
92
96
|
expect(updatedSections[1].tasks[1].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
93
97
|
});
|
|
94
|
-
it("should set tasks to '".concat(_models.TaskStates.TYPES.IN_PROGRESS, "' if they have a current page but are not complete"), ()
|
|
95
|
-
|
|
98
|
+
it("should set tasks to '".concat(_models.TaskStates.TYPES.IN_PROGRESS, "' if they have a current page but are not complete"), function () {
|
|
99
|
+
var SECTIONS = [{
|
|
96
100
|
name: 'Add event details',
|
|
97
101
|
tasks: [{
|
|
98
102
|
name: 'Date, location and mode details',
|
|
@@ -102,18 +106,18 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
102
106
|
pages: ['officeDetails']
|
|
103
107
|
}]
|
|
104
108
|
}];
|
|
105
|
-
|
|
109
|
+
var TASKS = {
|
|
106
110
|
'Date, location and mode details': {
|
|
107
111
|
complete: false,
|
|
108
112
|
currentPage: 'eventMode'
|
|
109
113
|
}
|
|
110
114
|
};
|
|
111
|
-
|
|
115
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS);
|
|
112
116
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.IN_PROGRESS);
|
|
113
117
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
114
118
|
});
|
|
115
|
-
it("should set the status of any tasks in a section with a failed show_when to '".concat(_models.TaskStates.TYPES.SKIPPED, "'"), ()
|
|
116
|
-
|
|
119
|
+
it("should set the status of any tasks in a section with a failed show_when to '".concat(_models.TaskStates.TYPES.SKIPPED, "'"), function () {
|
|
120
|
+
var SECTIONS = [{
|
|
117
121
|
name: 'Add event details',
|
|
118
122
|
tasks: [{
|
|
119
123
|
name: 'Date, location and mode details',
|
|
@@ -137,7 +141,7 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
137
141
|
pages: ['immigrationDate']
|
|
138
142
|
}]
|
|
139
143
|
}];
|
|
140
|
-
|
|
144
|
+
var TASKS = {
|
|
141
145
|
'Date, location and mode details': {
|
|
142
146
|
complete: true
|
|
143
147
|
},
|
|
@@ -145,18 +149,18 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
145
149
|
complete: true
|
|
146
150
|
}
|
|
147
151
|
};
|
|
148
|
-
|
|
152
|
+
var DATA = {
|
|
149
153
|
field: 'hideMe'
|
|
150
154
|
};
|
|
151
|
-
|
|
155
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, false, DATA);
|
|
152
156
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
153
157
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
154
158
|
expect(updatedSections[1].skipped).toEqual(true);
|
|
155
159
|
expect(updatedSections[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
156
160
|
expect(updatedSections[1].tasks[1].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
157
161
|
});
|
|
158
|
-
it("should set the status of any tasks with a failed show_when to '".concat(_models.TaskStates.TYPES.SKIPPED, "'"), ()
|
|
159
|
-
|
|
162
|
+
it("should set the status of any tasks with a failed show_when to '".concat(_models.TaskStates.TYPES.SKIPPED, "'"), function () {
|
|
163
|
+
var SECTIONS = [{
|
|
160
164
|
name: 'Add event details',
|
|
161
165
|
tasks: [{
|
|
162
166
|
name: 'Date, location and mode details',
|
|
@@ -176,15 +180,15 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
176
180
|
}
|
|
177
181
|
}]
|
|
178
182
|
}];
|
|
179
|
-
|
|
183
|
+
var DATA = {
|
|
180
184
|
field: 'hideMe'
|
|
181
185
|
};
|
|
182
|
-
|
|
186
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, {}, false, DATA);
|
|
183
187
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
184
188
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
185
189
|
});
|
|
186
|
-
it("should set the status of any tasks to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "' if previous tasks within a section have been skipped"), ()
|
|
187
|
-
|
|
190
|
+
it("should set the status of any tasks to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "' if previous tasks within a section have been skipped"), function () {
|
|
191
|
+
var SECTIONS = [{
|
|
188
192
|
name: 'Add event details',
|
|
189
193
|
tasks: [{
|
|
190
194
|
name: 'task one',
|
|
@@ -220,22 +224,22 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
220
224
|
}
|
|
221
225
|
}]
|
|
222
226
|
}];
|
|
223
|
-
|
|
227
|
+
var DATA = {
|
|
224
228
|
field: 'hideMe'
|
|
225
229
|
};
|
|
226
|
-
|
|
230
|
+
var TASKS = {
|
|
227
231
|
'task one': {
|
|
228
232
|
complete: true
|
|
229
233
|
}
|
|
230
234
|
};
|
|
231
|
-
|
|
235
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, false, DATA);
|
|
232
236
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
233
237
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
234
238
|
expect(updatedSections[0].tasks[2].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
235
239
|
expect(updatedSections[0].tasks[3].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
236
240
|
});
|
|
237
|
-
it("should set the status of any tasks to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "' if previous tasks within the last section have been skipped"), ()
|
|
238
|
-
|
|
241
|
+
it("should set the status of any tasks to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "' if previous tasks within the last section have been skipped"), function () {
|
|
242
|
+
var SECTIONS = [{
|
|
239
243
|
name: 'Add event details',
|
|
240
244
|
tasks: [{
|
|
241
245
|
name: 'task one',
|
|
@@ -261,22 +265,22 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
261
265
|
pages: ['eventDate', 'eventMode']
|
|
262
266
|
}]
|
|
263
267
|
}];
|
|
264
|
-
|
|
268
|
+
var DATA = {
|
|
265
269
|
field: 'showMe'
|
|
266
270
|
};
|
|
267
|
-
|
|
271
|
+
var TASKS = {
|
|
268
272
|
'task one': {
|
|
269
273
|
complete: true
|
|
270
274
|
}
|
|
271
275
|
};
|
|
272
|
-
|
|
276
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, false, DATA);
|
|
273
277
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
274
278
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
275
279
|
expect(updatedSections[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
276
280
|
});
|
|
277
281
|
});
|
|
278
|
-
it("should set the status of any tasks to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "' if previous tasks have been skipped"), ()
|
|
279
|
-
|
|
282
|
+
it("should set the status of any tasks to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "' if previous tasks have been skipped"), function () {
|
|
283
|
+
var SECTIONS = [{
|
|
280
284
|
name: 'Add event details',
|
|
281
285
|
show_when: {
|
|
282
286
|
field: 'field',
|
|
@@ -300,20 +304,20 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
300
304
|
pages: ['immigrationDate']
|
|
301
305
|
}]
|
|
302
306
|
}];
|
|
303
|
-
|
|
304
|
-
|
|
307
|
+
var TASKS = {};
|
|
308
|
+
var DATA = {
|
|
305
309
|
field: 'hideMe'
|
|
306
310
|
};
|
|
307
|
-
|
|
311
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, false, DATA);
|
|
308
312
|
expect(updatedSections[0].skipped).toEqual(true);
|
|
309
313
|
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
310
314
|
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
311
315
|
expect(updatedSections[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
312
316
|
expect(updatedSections[1].tasks[1].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET);
|
|
313
317
|
});
|
|
314
|
-
describe('non-sequential tasks', ()
|
|
315
|
-
|
|
316
|
-
|
|
318
|
+
describe('non-sequential tasks', function () {
|
|
319
|
+
var NON_SEQUENTIAL = true;
|
|
320
|
+
var SECTIONS = [{
|
|
317
321
|
name: 'First',
|
|
318
322
|
tasks: [{
|
|
319
323
|
name: 'Alpha'
|
|
@@ -332,29 +336,31 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
332
336
|
name: 'Delta'
|
|
333
337
|
}]
|
|
334
338
|
}];
|
|
335
|
-
it("should set all states to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "', except any that depend on others"), ()
|
|
336
|
-
|
|
339
|
+
it("should set all states to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "', except any that depend on others"), function () {
|
|
340
|
+
var RESULT = (0, _getUpdatedSectionStates.default)(SECTIONS, {}, NON_SEQUENTIAL);
|
|
337
341
|
expect(RESULT[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Alpha
|
|
338
342
|
expect(RESULT[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Bravo
|
|
339
343
|
expect(RESULT[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
340
344
|
expect(RESULT[2].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Delta
|
|
341
345
|
});
|
|
342
|
-
|
|
343
|
-
|
|
346
|
+
|
|
347
|
+
it('should keep dependent state unable to start if any dependencies are not complete', function () {
|
|
348
|
+
var ALPHA_COMPLETE = (0, _getUpdatedSectionStates.default)(SECTIONS, {
|
|
344
349
|
Alpha: {
|
|
345
350
|
complete: true
|
|
346
351
|
}
|
|
347
352
|
}, NON_SEQUENTIAL);
|
|
348
353
|
expect(ALPHA_COMPLETE[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
349
|
-
|
|
354
|
+
var BRAVO_COMPLETE = (0, _getUpdatedSectionStates.default)(SECTIONS, {
|
|
350
355
|
Bravo: {
|
|
351
356
|
complete: true
|
|
352
357
|
}
|
|
353
358
|
}, NON_SEQUENTIAL);
|
|
354
359
|
expect(BRAVO_COMPLETE[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
355
360
|
});
|
|
356
|
-
|
|
357
|
-
|
|
361
|
+
|
|
362
|
+
it('should allow dependent state to start if all dependencies are complete', function () {
|
|
363
|
+
var TASKS = {
|
|
358
364
|
'Alpha': {
|
|
359
365
|
complete: true
|
|
360
366
|
},
|
|
@@ -363,12 +369,13 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
363
369
|
},
|
|
364
370
|
'Delta': {}
|
|
365
371
|
};
|
|
366
|
-
|
|
372
|
+
var RESULT = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, NON_SEQUENTIAL);
|
|
367
373
|
expect(RESULT[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Charlie
|
|
368
374
|
expect(RESULT[2].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Delta
|
|
369
375
|
});
|
|
370
|
-
|
|
371
|
-
|
|
376
|
+
|
|
377
|
+
it('should not allow dependent state to start if incomplete dependencies are skipped, but skipped are not ignored', function () {
|
|
378
|
+
var TASKS = {
|
|
372
379
|
'Alpha': {
|
|
373
380
|
complete: true
|
|
374
381
|
},
|
|
@@ -378,18 +385,17 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
378
385
|
},
|
|
379
386
|
'Delta': {}
|
|
380
387
|
};
|
|
381
|
-
|
|
388
|
+
var RESULT = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, NON_SEQUENTIAL);
|
|
382
389
|
expect(RESULT[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
383
390
|
});
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
tasks: [{
|
|
388
|
-
...SECTIONS[1].tasks[0],
|
|
391
|
+
|
|
392
|
+
it('should allow dependent state to start if incomplete dependencies are skipped, and skipped are ignored', function () {
|
|
393
|
+
var SKIPPABLE_SECTIONS = [SECTIONS[0], _objectSpread(_objectSpread({}, SECTIONS[1]), {}, {
|
|
394
|
+
tasks: [_objectSpread(_objectSpread({}, SECTIONS[1].tasks[0]), {}, {
|
|
389
395
|
ignoreSkipped: true
|
|
390
|
-
}]
|
|
391
|
-
}, SECTIONS[2]];
|
|
392
|
-
|
|
396
|
+
})]
|
|
397
|
+
}), SECTIONS[2]];
|
|
398
|
+
var TASKS = {
|
|
393
399
|
'Alpha': {
|
|
394
400
|
complete: true
|
|
395
401
|
},
|
|
@@ -399,11 +405,12 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
399
405
|
},
|
|
400
406
|
'Delta': {}
|
|
401
407
|
};
|
|
402
|
-
|
|
408
|
+
var RESULT = (0, _getUpdatedSectionStates.default)(SKIPPABLE_SECTIONS, TASKS, NON_SEQUENTIAL);
|
|
403
409
|
expect(RESULT[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Charlie
|
|
404
410
|
});
|
|
405
|
-
|
|
406
|
-
|
|
411
|
+
|
|
412
|
+
it('should automatically skip tasks that are not shown', function () {
|
|
413
|
+
var SHOW_WHEN_SECTIONS = [{
|
|
407
414
|
name: 'First',
|
|
408
415
|
tasks: [{
|
|
409
416
|
name: 'Alpha'
|
|
@@ -431,7 +438,7 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
431
438
|
ignoreSkipped: true
|
|
432
439
|
}]
|
|
433
440
|
}];
|
|
434
|
-
|
|
441
|
+
var TASKS = {
|
|
435
442
|
'Alpha': {
|
|
436
443
|
complete: true
|
|
437
444
|
},
|
|
@@ -440,11 +447,11 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', () => {
|
|
|
440
447
|
},
|
|
441
448
|
'Delta': {}
|
|
442
449
|
};
|
|
443
|
-
|
|
450
|
+
var DATA = {
|
|
444
451
|
echo: 'foxtrot',
|
|
445
452
|
golf: 'hotel'
|
|
446
453
|
};
|
|
447
|
-
|
|
454
|
+
var RESULT = (0, _getUpdatedSectionStates.default)(SHOW_WHEN_SECTIONS, TASKS, NON_SEQUENTIAL, DATA);
|
|
448
455
|
expect(RESULT[2].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Charlie
|
|
449
456
|
});
|
|
450
457
|
});
|
|
@@ -16,7 +16,7 @@ var _getUpdatedSectionStates = _interopRequireDefault(require("./getUpdatedSecti
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
// Local imports
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
var helpers = {
|
|
20
20
|
canActionProceed: _canActionProceed.default,
|
|
21
21
|
canCYASubmit: _canCYASubmit.default,
|
|
22
22
|
cleanHiddenNestedData: _cleanHiddenNestedData.default,
|
|
@@ -9,13 +9,17 @@ var _utils = _interopRequireDefault(require("../../utils"));
|
|
|
9
9
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
10
10
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports.
|
|
14
18
|
/**
|
|
15
19
|
*
|
|
16
20
|
* @param {*} action
|
|
17
21
|
*/
|
|
18
|
-
|
|
22
|
+
var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, components, data, setData, type, pageId, currentTask, hooks, addErrors, hub, onPageChange, formState, submitting, setSubmitting) {
|
|
19
23
|
// Check to see whether the action is able to proceed, which in
|
|
20
24
|
// in the case of a submission will validate the fields in the page.
|
|
21
25
|
if (action.type === _models.PageAction.TYPES.SUBMIT && hub !== _models.HubFormats.TASK) {
|
|
@@ -23,40 +27,36 @@ const onCYAAction = (setPagePoint, action, pages, validate, components, data, se
|
|
|
23
27
|
if (_helpers.default.canCYASubmit(pages, validate.pages) && !submitting) {
|
|
24
28
|
setSubmitting(true);
|
|
25
29
|
// Submit.
|
|
26
|
-
|
|
27
|
-
pages,
|
|
28
|
-
components
|
|
29
|
-
}, {
|
|
30
|
-
...data
|
|
31
|
-
}, _models.EventTypes.SUBMIT);
|
|
30
|
+
var submissionData = _utils.default.Format.form({
|
|
31
|
+
pages: pages,
|
|
32
|
+
components: components
|
|
33
|
+
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
32
34
|
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
33
35
|
setData(submissionData);
|
|
34
36
|
// Now submit the data to the backend...
|
|
35
|
-
hooks.onSubmit(action.type, submissionData, ()
|
|
37
|
+
hooks.onSubmit(action.type, submissionData, function () {
|
|
36
38
|
hooks.onFormComplete();
|
|
37
39
|
setSubmitting(false);
|
|
38
|
-
}, errors
|
|
40
|
+
}, function (errors) {
|
|
39
41
|
setSubmitting(false);
|
|
40
42
|
_handlers.default.submissionError(errors, addErrors);
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
} else {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
var shouldValidate = !(Object.prototype.hasOwnProperty.call(action, 'validate') && !action.validate);
|
|
47
|
+
var canSubmit = shouldValidate ? _helpers.default.canCYASubmit(currentTask.fullPages, validate.pages) : true;
|
|
46
48
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_CONTINUE && hub === _models.HubFormats.TASK) {
|
|
47
49
|
if (canSubmit) {
|
|
48
|
-
|
|
49
|
-
pages,
|
|
50
|
-
components
|
|
51
|
-
}, {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
setData(submissionData);
|
|
56
|
-
hooks.onSubmit(action.type, submissionData, () => {
|
|
50
|
+
var _submissionData = _utils.default.Format.form({
|
|
51
|
+
pages: pages,
|
|
52
|
+
components: components
|
|
53
|
+
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
54
|
+
_submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData, currentTask, true);
|
|
55
|
+
setData(_submissionData);
|
|
56
|
+
hooks.onSubmit(action.type, _submissionData, function () {
|
|
57
57
|
setSubmitting(false);
|
|
58
58
|
onPageChange(_models.FormPages.HUB);
|
|
59
|
-
}, errors
|
|
59
|
+
}, function (errors) {
|
|
60
60
|
setSubmitting(false);
|
|
61
61
|
_handlers.default.submissionError(errors, addErrors);
|
|
62
62
|
});
|
|
@@ -66,19 +66,17 @@ const onCYAAction = (setPagePoint, action, pages, validate, components, data, se
|
|
|
66
66
|
setPagePoint('submit');
|
|
67
67
|
if (canSubmit) {
|
|
68
68
|
// Submit.
|
|
69
|
-
|
|
70
|
-
pages,
|
|
71
|
-
components
|
|
72
|
-
}, {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
76
|
-
setData(submissionData);
|
|
69
|
+
var _submissionData2 = _utils.default.Format.form({
|
|
70
|
+
pages: pages,
|
|
71
|
+
components: components
|
|
72
|
+
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
73
|
+
_submissionData2.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData2, currentTask, true);
|
|
74
|
+
setData(_submissionData2);
|
|
77
75
|
// Now submit the data to the backend...
|
|
78
|
-
hooks.onSubmit(action.type,
|
|
76
|
+
hooks.onSubmit(action.type, _submissionData2, function () {
|
|
79
77
|
hooks.onFormComplete();
|
|
80
78
|
setSubmitting(false);
|
|
81
|
-
}, errors
|
|
79
|
+
}, function (errors) {
|
|
82
80
|
setSubmitting(false);
|
|
83
81
|
_handlers.default.submissionError(errors, addErrors);
|
|
84
82
|
});
|
|
@@ -86,18 +84,16 @@ const onCYAAction = (setPagePoint, action, pages, validate, components, data, se
|
|
|
86
84
|
}
|
|
87
85
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_NAVIGATE) {
|
|
88
86
|
if (canSubmit) {
|
|
89
|
-
|
|
90
|
-
pages,
|
|
91
|
-
components
|
|
92
|
-
}, {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
setData(submissionData);
|
|
97
|
-
hooks.onSubmit(action.type, submissionData, () => {
|
|
87
|
+
var _submissionData3 = _utils.default.Format.form({
|
|
88
|
+
pages: pages,
|
|
89
|
+
components: components
|
|
90
|
+
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
91
|
+
_submissionData3.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData3, currentTask, true);
|
|
92
|
+
setData(_submissionData3);
|
|
93
|
+
hooks.onSubmit(action.type, _submissionData3, function () {
|
|
98
94
|
setSubmitting(false);
|
|
99
95
|
onPageChange(action.page);
|
|
100
|
-
}, errors
|
|
96
|
+
}, function (errors) {
|
|
101
97
|
setSubmitting(false);
|
|
102
98
|
_handlers.default.submissionError(errors, addErrors);
|
|
103
99
|
});
|
|
@@ -105,22 +101,20 @@ const onCYAAction = (setPagePoint, action, pages, validate, components, data, se
|
|
|
105
101
|
}
|
|
106
102
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
107
103
|
if (canSubmit) {
|
|
108
|
-
|
|
109
|
-
pages,
|
|
110
|
-
components
|
|
111
|
-
}, {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
setData(submissionData);
|
|
116
|
-
hooks.onSubmit(action.type, submissionData, () => {
|
|
104
|
+
var _submissionData4 = _utils.default.Format.form({
|
|
105
|
+
pages: pages,
|
|
106
|
+
components: components
|
|
107
|
+
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
108
|
+
_submissionData4.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData4, currentTask, false);
|
|
109
|
+
setData(_submissionData4);
|
|
110
|
+
hooks.onSubmit(action.type, _submissionData4, function () {
|
|
117
111
|
if (type === _models.FormTypes.TASK) {
|
|
118
112
|
onPageChange(undefined);
|
|
119
113
|
} else {
|
|
120
114
|
onPageChange(_models.FormPages.HUB);
|
|
121
115
|
}
|
|
122
116
|
setSubmitting(false);
|
|
123
|
-
}, errors
|
|
117
|
+
}, function (errors) {
|
|
124
118
|
setSubmitting(false);
|
|
125
119
|
_handlers.default.submissionError(errors, addErrors);
|
|
126
120
|
});
|
|
@@ -132,12 +126,10 @@ const onCYAAction = (setPagePoint, action, pages, validate, components, data, se
|
|
|
132
126
|
setSubmitting(false);
|
|
133
127
|
}
|
|
134
128
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
135
|
-
|
|
136
|
-
pages,
|
|
137
|
-
components
|
|
138
|
-
}, {
|
|
139
|
-
...data
|
|
140
|
-
}, _models.EventTypes.CANCEL);
|
|
129
|
+
var formData = _utils.default.Format.form({
|
|
130
|
+
pages: pages,
|
|
131
|
+
components: components
|
|
132
|
+
}, _objectSpread({}, data), _models.EventTypes.CANCEL);
|
|
141
133
|
hooks.onCancel(formData);
|
|
142
134
|
setSubmitting(false);
|
|
143
135
|
}
|