@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
|
@@ -4,20 +4,22 @@ var _models = require("../../../models");
|
|
|
4
4
|
var _PageAction = require("../../../models/PageAction");
|
|
5
5
|
var _getSubmissionStatus = _interopRequireDefault(require("./getSubmissionStatus"));
|
|
6
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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); }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
|
|
11
|
+
describe('components', function () {
|
|
12
|
+
describe('FormRenderer', function () {
|
|
13
|
+
describe('helpers', function () {
|
|
14
|
+
describe('getSubmissionStatus', function () {
|
|
15
|
+
var OPTIONS = [{
|
|
14
16
|
value: 'romeo',
|
|
15
17
|
label: 'Romeo'
|
|
16
18
|
}, {
|
|
17
19
|
value: 'juliet',
|
|
18
20
|
label: 'Juliet'
|
|
19
21
|
}];
|
|
20
|
-
|
|
22
|
+
var RADIOS = {
|
|
21
23
|
id: 'radios',
|
|
22
24
|
fieldId: 'radios',
|
|
23
25
|
type: _models.ComponentTypes.RADIOS,
|
|
@@ -25,29 +27,29 @@ describe('components', () => {
|
|
|
25
27
|
options: OPTIONS
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
|
-
|
|
30
|
+
var TEXT = {
|
|
29
31
|
id: 'text',
|
|
30
32
|
fieldId: 'text',
|
|
31
33
|
type: _models.ComponentTypes.TEXT
|
|
32
34
|
};
|
|
33
|
-
|
|
35
|
+
var HTML = {
|
|
34
36
|
type: _models.ComponentTypes.HTML,
|
|
35
37
|
content: 'HTML'
|
|
36
38
|
};
|
|
37
|
-
|
|
39
|
+
var SHOW_WHEN_JULIET = {
|
|
38
40
|
field: RADIOS.fieldId,
|
|
39
41
|
op: '=',
|
|
40
42
|
value: OPTIONS[1].value
|
|
41
43
|
};
|
|
42
|
-
|
|
44
|
+
var SHOW_WHEN_ROMEO = {
|
|
43
45
|
field: RADIOS.fieldId,
|
|
44
46
|
op: '=',
|
|
45
47
|
value: OPTIONS[0].value
|
|
46
48
|
};
|
|
47
|
-
|
|
49
|
+
var FORM_DATA = {
|
|
48
50
|
radios: OPTIONS[0].value
|
|
49
51
|
}; // 'romeo'
|
|
50
|
-
|
|
52
|
+
var PAGES = [{
|
|
51
53
|
id: 'alpha'
|
|
52
54
|
}, {
|
|
53
55
|
id: 'bravo'
|
|
@@ -66,18 +68,18 @@ describe('components', () => {
|
|
|
66
68
|
components: [TEXT],
|
|
67
69
|
show_when: SHOW_WHEN_ROMEO
|
|
68
70
|
}];
|
|
69
|
-
describe("when the action type is '".concat(_models.PageAction.TYPES.NAVIGATE, "'"), ()
|
|
70
|
-
it('should return undefined if the action has no page property', ()
|
|
71
|
-
|
|
71
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.NAVIGATE, "'"), function () {
|
|
72
|
+
it('should return undefined if the action has no page property', function () {
|
|
73
|
+
var ACTION = {
|
|
72
74
|
type: _models.PageAction.TYPES.NAVIGATE
|
|
73
75
|
};
|
|
74
76
|
expect((0, _getSubmissionStatus.default)(_models.FormTypes.HUB, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
75
77
|
page: undefined
|
|
76
78
|
});
|
|
77
79
|
});
|
|
78
|
-
it('should return the page on the action if it exists among the pages', ()
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
it('should return the page on the action if it exists among the pages', function () {
|
|
81
|
+
var PAGE = PAGES[1].id;
|
|
82
|
+
var ACTION = {
|
|
81
83
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
82
84
|
page: PAGE
|
|
83
85
|
};
|
|
@@ -85,9 +87,9 @@ describe('components', () => {
|
|
|
85
87
|
page: PAGE
|
|
86
88
|
});
|
|
87
89
|
});
|
|
88
|
-
it('should return undefined if the page on the action does not exist among the pages', ()
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
it('should return undefined if the page on the action does not exist among the pages', function () {
|
|
91
|
+
var PAGE = 'golf';
|
|
92
|
+
var ACTION = {
|
|
91
93
|
type: _models.PageAction.TYPES.NAVIGATE,
|
|
92
94
|
page: PAGE
|
|
93
95
|
};
|
|
@@ -96,11 +98,11 @@ describe('components', () => {
|
|
|
96
98
|
});
|
|
97
99
|
});
|
|
98
100
|
});
|
|
99
|
-
describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), ()
|
|
100
|
-
Object.values(_models.FormTypes).forEach(formType
|
|
101
|
+
describe("when the action type is '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), function () {
|
|
102
|
+
Object.values(_models.FormTypes).forEach(function (formType) {
|
|
101
103
|
if (formType !== _models.FormTypes.TASK && formType !== _models.FormTypes.FORM_WITH_TASK) {
|
|
102
|
-
it("should return the current page if the form type is '".concat(formType, "'"), ()
|
|
103
|
-
|
|
104
|
+
it("should return the current page if the form type is '".concat(formType, "'"), function () {
|
|
105
|
+
var ACTION = _models.PageAction.DEFAULTS.saveAndReturn;
|
|
104
106
|
expect((0, _getSubmissionStatus.default)(formType, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
105
107
|
page: PAGES[0].id
|
|
106
108
|
});
|
|
@@ -108,15 +110,15 @@ describe('components', () => {
|
|
|
108
110
|
}
|
|
109
111
|
});
|
|
110
112
|
});
|
|
111
|
-
describe("when the form type is '".concat(_models.FormTypes.HUB, "'"), ()
|
|
112
|
-
|
|
113
|
-
it("should return '".concat(_models.FormPages.HUB, "' by default"), ()
|
|
113
|
+
describe("when the form type is '".concat(_models.FormTypes.HUB, "'"), function () {
|
|
114
|
+
var FORM_TYPE = _models.FormTypes.HUB;
|
|
115
|
+
it("should return '".concat(_models.FormPages.HUB, "' by default"), function () {
|
|
114
116
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
115
117
|
page: _models.FormPages.HUB
|
|
116
118
|
});
|
|
117
119
|
});
|
|
118
|
-
it('should return action.page if specified', ()
|
|
119
|
-
|
|
120
|
+
it('should return action.page if specified', function () {
|
|
121
|
+
var ACTION = {
|
|
120
122
|
page: 'bob'
|
|
121
123
|
};
|
|
122
124
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, undefined, ACTION, FORM_DATA)).toMatchObject({
|
|
@@ -124,63 +126,63 @@ describe('components', () => {
|
|
|
124
126
|
});
|
|
125
127
|
});
|
|
126
128
|
});
|
|
127
|
-
describe("when the form type is '".concat(_models.FormTypes.CYA, "'"), ()
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
it('should return the first page by default', ()
|
|
129
|
+
describe("when the form type is '".concat(_models.FormTypes.CYA, "'"), function () {
|
|
130
|
+
var FORM_TYPE = _models.FormTypes.CYA;
|
|
131
|
+
var ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
132
|
+
it('should return the first page by default', function () {
|
|
131
133
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, ACTION, FORM_DATA)).toMatchObject({
|
|
132
134
|
page: PAGES[0].id
|
|
133
135
|
});
|
|
134
136
|
});
|
|
135
|
-
it('should return the second page when on the first page', ()
|
|
137
|
+
it('should return the second page when on the first page', function () {
|
|
136
138
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id, ACTION, FORM_DATA)).toMatchObject({
|
|
137
139
|
page: PAGES[1].id
|
|
138
140
|
});
|
|
139
141
|
});
|
|
140
|
-
it('should return the third page when on the second page', ()
|
|
142
|
+
it('should return the third page when on the second page', function () {
|
|
141
143
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[1].id, ACTION, FORM_DATA)).toMatchObject({
|
|
142
144
|
page: PAGES[2].id
|
|
143
145
|
});
|
|
144
146
|
});
|
|
145
|
-
it("should return the fifth page when on the third page because the fourth page show_when is not met", ()
|
|
147
|
+
it("should return the fifth page when on the third page because the fourth page show_when is not met", function () {
|
|
146
148
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[2].id, ACTION, FORM_DATA)).toMatchObject({
|
|
147
149
|
page: PAGES[4].id
|
|
148
150
|
});
|
|
149
151
|
});
|
|
150
|
-
it("should return the sixth page when on the fifth page because the sixth page show_when is met", ()
|
|
152
|
+
it("should return the sixth page when on the fifth page because the sixth page show_when is met", function () {
|
|
151
153
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[4].id, ACTION, FORM_DATA)).toMatchObject({
|
|
152
154
|
page: PAGES[5].id
|
|
153
155
|
});
|
|
154
156
|
});
|
|
155
|
-
it("should return '".concat(_models.FormPages.CYA, "' when on the sixth (last) page"), ()
|
|
156
|
-
|
|
157
|
+
it("should return '".concat(_models.FormPages.CYA, "' when on the sixth (last) page"), function () {
|
|
158
|
+
var lastPageIndex = PAGES.length - 1;
|
|
157
159
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[lastPageIndex].id, ACTION, FORM_DATA)).toMatchObject({
|
|
158
160
|
page: _models.FormPages.CYA
|
|
159
161
|
});
|
|
160
162
|
});
|
|
161
163
|
});
|
|
162
|
-
describe("when the form type is '".concat(_models.FormTypes.WIZARD, "'"), ()
|
|
163
|
-
|
|
164
|
-
it('should return the first page by default', ()
|
|
164
|
+
describe("when the form type is '".concat(_models.FormTypes.WIZARD, "'"), function () {
|
|
165
|
+
var FORM_TYPE = _models.FormTypes.WIZARD;
|
|
166
|
+
it('should return the first page by default', function () {
|
|
165
167
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES)).toMatchObject({
|
|
166
168
|
page: PAGES[0].id
|
|
167
169
|
});
|
|
168
170
|
});
|
|
169
|
-
it('should return the second page when on the first page', ()
|
|
171
|
+
it('should return the second page when on the first page', function () {
|
|
170
172
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[0].id)).toMatchObject({
|
|
171
173
|
page: PAGES[1].id
|
|
172
174
|
});
|
|
173
175
|
});
|
|
174
|
-
it('should return undefined when on the last page', ()
|
|
176
|
+
it('should return undefined when on the last page', function () {
|
|
175
177
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, PAGES[PAGES.length - 1].id)).toMatchObject({
|
|
176
178
|
page: undefined
|
|
177
179
|
});
|
|
178
180
|
});
|
|
179
181
|
});
|
|
180
|
-
describe("when the form type is '".concat(_models.FormTypes.FORM, "'"), ()
|
|
181
|
-
|
|
182
|
-
it("should always return the first page if there any pages and the action is not '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), ()
|
|
183
|
-
|
|
182
|
+
describe("when the form type is '".concat(_models.FormTypes.FORM, "'"), function () {
|
|
183
|
+
var FORM_TYPE = _models.FormTypes.FORM;
|
|
184
|
+
it("should always return the first page if there any pages and the action is not '".concat(_models.PageAction.TYPES.SAVE_AND_RETURN, "'"), function () {
|
|
185
|
+
var ACTION = {
|
|
184
186
|
type: _models.PageAction.TYPES.SUBMIT,
|
|
185
187
|
nextPageId: 'bob'
|
|
186
188
|
};
|
|
@@ -197,99 +199,91 @@ describe('components', () => {
|
|
|
197
199
|
page: PAGES[0].id
|
|
198
200
|
});
|
|
199
201
|
});
|
|
200
|
-
it('should return undefined if there are no pages', ()
|
|
202
|
+
it('should return undefined if there are no pages', function () {
|
|
201
203
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, [])).toMatchObject({
|
|
202
204
|
page: undefined
|
|
203
205
|
});
|
|
204
206
|
});
|
|
205
207
|
});
|
|
206
|
-
describe("when the form type is '".concat(_models.FormTypes.TASK, "'"), ()
|
|
207
|
-
|
|
208
|
-
it("should mark the current task as complete if the current page is '".concat(_models.FormPages.CYA, "' and it is marked as complete"), ()
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
describe("when the form type is '".concat(_models.FormTypes.TASK, "'"), function () {
|
|
209
|
+
var FORM_TYPE = _models.FormTypes.TASK;
|
|
210
|
+
it("should mark the current task as complete if the current page is '".concat(_models.FormPages.CYA, "' and it is marked as complete"), function () {
|
|
211
|
+
var CURRENT_PAGE_ID = _models.FormPages.CYA;
|
|
212
|
+
var TASK_NAME = 'taskName';
|
|
213
|
+
var CURRENT_TASK = {
|
|
212
214
|
name: TASK_NAME
|
|
213
215
|
};
|
|
214
216
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, undefined, {}, CURRENT_TASK, true)).toMatchObject({
|
|
215
|
-
tasks: {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
}
|
|
217
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
218
|
+
complete: true
|
|
219
|
+
})
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
|
-
it("should update the current task with the current page and a false complete flag if the next page is not '".concat(_models.FormPages.CYA, "'"), ()
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
it("should update the current task with the current page and a false complete flag if the next page is not '".concat(_models.FormPages.CYA, "'"), function () {
|
|
223
|
+
var CURRENT_PAGE_ID = 'eventDate';
|
|
224
|
+
var TASK_NAME = 'taskName';
|
|
225
|
+
var CURRENT_TASK = {
|
|
226
226
|
name: TASK_NAME
|
|
227
227
|
};
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
var NEXT_PAGE_ID = 'eventMode';
|
|
229
|
+
var ACTION = {
|
|
230
230
|
type: _PageAction.PageActionTypes.SAVE_AND_NAVIGATE,
|
|
231
231
|
page: NEXT_PAGE_ID
|
|
232
232
|
};
|
|
233
233
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK)).toMatchObject({
|
|
234
|
-
tasks: {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
}
|
|
234
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
235
|
+
complete: false,
|
|
236
|
+
currentPage: NEXT_PAGE_ID
|
|
237
|
+
})
|
|
240
238
|
});
|
|
241
239
|
});
|
|
242
|
-
it("should mark the current task as complete if the action indicates as much", ()
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
it("should mark the current task as complete if the action indicates as much", function () {
|
|
241
|
+
var CURRENT_PAGE_ID = PAGES[0].id;
|
|
242
|
+
var TASK_NAME = 'taskName';
|
|
243
|
+
var CURRENT_TASK = {
|
|
246
244
|
name: TASK_NAME,
|
|
247
245
|
pages: [CURRENT_PAGE_ID]
|
|
248
246
|
};
|
|
249
|
-
|
|
247
|
+
var ACTION = {
|
|
250
248
|
complete: true
|
|
251
249
|
};
|
|
252
250
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true)).toMatchObject({
|
|
253
|
-
tasks: {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
}
|
|
251
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
252
|
+
complete: true
|
|
253
|
+
})
|
|
258
254
|
});
|
|
259
255
|
});
|
|
260
|
-
it("should mark the current task as complete if the current task is a pre-task-list task", ()
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
256
|
+
it("should mark the current task as complete if the current task is a pre-task-list task", function () {
|
|
257
|
+
var CURRENT_PAGE_ID = PAGES[PAGES.length - 1].id;
|
|
258
|
+
var TASK_NAME = undefined;
|
|
259
|
+
var CURRENT_TASK = {
|
|
264
260
|
name: TASK_NAME
|
|
265
261
|
};
|
|
266
|
-
|
|
262
|
+
var ACTION = {
|
|
267
263
|
complete: true
|
|
268
264
|
};
|
|
269
|
-
|
|
265
|
+
var TASKS = [{
|
|
270
266
|
type: 'pre-task-list',
|
|
271
267
|
pages: PAGES
|
|
272
268
|
}];
|
|
273
|
-
|
|
269
|
+
var SECTIONS = [{
|
|
274
270
|
tasks: TASKS
|
|
275
271
|
}];
|
|
276
272
|
expect((0, _getSubmissionStatus.default)(FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, {}, CURRENT_TASK, true, SECTIONS)).toMatchObject({
|
|
277
|
-
tasks: {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
}
|
|
273
|
+
tasks: _defineProperty({}, TASK_NAME, {
|
|
274
|
+
complete: true
|
|
275
|
+
})
|
|
282
276
|
});
|
|
283
277
|
});
|
|
284
|
-
it('should not update the current task state if the current page does not belong in the task', ()
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
278
|
+
it('should not update the current task state if the current page does not belong in the task', function () {
|
|
279
|
+
var CUSTOM_FORM_TYPE = _models.FormTypes.FORM_WITH_TASK;
|
|
280
|
+
var ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
281
|
+
var CURRENT_TASK = {
|
|
288
282
|
name: 'test-task',
|
|
289
283
|
pages: ['page-a']
|
|
290
284
|
};
|
|
291
|
-
|
|
292
|
-
|
|
285
|
+
var CURRENT_PAGE_ID = 'page-b';
|
|
286
|
+
var CUSTOM_FORM_DATA = {
|
|
293
287
|
formStatus: {
|
|
294
288
|
tasks: {
|
|
295
289
|
'test-task': {
|
|
@@ -7,20 +7,22 @@ exports.default = void 0;
|
|
|
7
7
|
var _models = require("../../../models");
|
|
8
8
|
var _utils = _interopRequireDefault(require("../../../utils"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
+
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
16
|
/**
|
|
13
17
|
* @param {boolean} complete - true if task complete
|
|
14
18
|
* @param {boolean} currentPage - true if current page
|
|
15
19
|
* @param {TaskStates.TYPES|string} defaultState - default state to set task
|
|
16
20
|
* @returns {TaskStates.TYPES|string} current task state
|
|
17
21
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = _ref;
|
|
23
|
-
let defaultState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _models.TaskStates.TYPES.NOT_STARTED;
|
|
22
|
+
var getCurrentTaskState = function getCurrentTaskState(_ref) {
|
|
23
|
+
var complete = _ref.complete,
|
|
24
|
+
currentPage = _ref.currentPage;
|
|
25
|
+
var defaultState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _models.TaskStates.TYPES.NOT_STARTED;
|
|
24
26
|
if (complete) {
|
|
25
27
|
return _models.TaskStates.TYPES.COMPLETE;
|
|
26
28
|
}
|
|
@@ -37,18 +39,18 @@ const getCurrentTaskState = function (_ref) {
|
|
|
37
39
|
* @param {boolean} ignoreSkipped - skipped tasks don't need to have been completed
|
|
38
40
|
* @returns {boolean} true if dependent tasks complete
|
|
39
41
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return mustBeComplete.reduce((allComplete, taskName)
|
|
43
|
-
|
|
42
|
+
var allDependentTasksComplete = function allDependentTasksComplete(taskStates, mustBeComplete) {
|
|
43
|
+
var ignoreSkipped = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
44
|
+
return mustBeComplete.reduce(function (allComplete, taskName) {
|
|
45
|
+
var task = taskStates[taskName];
|
|
44
46
|
if (ignoreSkipped && (task === null || task === void 0 ? void 0 : task.state) === _models.TaskStates.TYPES.SKIPPED) {
|
|
45
47
|
return allComplete;
|
|
46
48
|
}
|
|
47
49
|
return allComplete && (task === null || task === void 0 ? void 0 : task.complete);
|
|
48
50
|
}, true);
|
|
49
51
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
var isPreviousTaskComplete = function isPreviousTaskComplete(tasks, taskIndex) {
|
|
53
|
+
var lastTaskState = tasks[taskIndex - 1].state;
|
|
52
54
|
if (lastTaskState === _models.TaskStates.TYPES.COMPLETE) {
|
|
53
55
|
return true;
|
|
54
56
|
}
|
|
@@ -69,9 +71,9 @@ const isPreviousTaskComplete = (tasks, taskIndex) => {
|
|
|
69
71
|
* @returns {TYPES|string} new state
|
|
70
72
|
*/
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
var updateTaskState = function updateTaskState(task, taskIndex, taskList, taskStates) {
|
|
75
|
+
var nonSequential = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
76
|
+
var allowFirst = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
75
77
|
if (taskStates[task.name]) {
|
|
76
78
|
return getCurrentTaskState(taskStates[task.name], task.state);
|
|
77
79
|
}
|
|
@@ -81,7 +83,7 @@ const updateTaskState = function (task, taskIndex, taskList, taskStates) {
|
|
|
81
83
|
}
|
|
82
84
|
return _models.TaskStates.TYPES.NOT_STARTED;
|
|
83
85
|
}
|
|
84
|
-
|
|
86
|
+
var notStarted = allowFirst;
|
|
85
87
|
if (taskIndex) {
|
|
86
88
|
notStarted = isPreviousTaskComplete(taskList, taskIndex);
|
|
87
89
|
}
|
|
@@ -100,12 +102,14 @@ const updateTaskState = function (task, taskIndex, taskList, taskStates) {
|
|
|
100
102
|
* @param {boolean} allowFirst - true if first task can be started
|
|
101
103
|
* @returns {object} - updated section
|
|
102
104
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
})
|
|
107
|
-
clone.filter(
|
|
108
|
-
|
|
105
|
+
var updateTasks = function updateTasks(section, taskStates, nonSequential, allowFirst) {
|
|
106
|
+
var clone = section.tasks.map(function (a) {
|
|
107
|
+
return _objectSpread({}, a);
|
|
108
|
+
});
|
|
109
|
+
clone.filter(function (t) {
|
|
110
|
+
return t.state !== _models.TaskStates.TYPES.SKIPPED;
|
|
111
|
+
}).forEach(function (t, index) {
|
|
112
|
+
var task = t;
|
|
109
113
|
task.state = updateTaskState(task, index, clone, taskStates, nonSequential, allowFirst);
|
|
110
114
|
});
|
|
111
115
|
return clone;
|
|
@@ -120,9 +124,9 @@ const updateTasks = (section, taskStates, nonSequential, allowFirst) => {
|
|
|
120
124
|
* @returns {boolean} true if the last non-skipped section is complete, false
|
|
121
125
|
* if not.
|
|
122
126
|
*/
|
|
123
|
-
|
|
127
|
+
var isPreviousSectionComplete = function isPreviousSectionComplete(sections, currentIndex) {
|
|
124
128
|
var _sections;
|
|
125
|
-
|
|
129
|
+
var lastTaskState = (_sections = sections[currentIndex - 1]) === null || _sections === void 0 || (_sections = _sections.tasks.slice(-1)[0]) === null || _sections === void 0 ? void 0 : _sections.state;
|
|
126
130
|
if (lastTaskState === _models.TaskStates.TYPES.COMPLETE) {
|
|
127
131
|
return true;
|
|
128
132
|
}
|
|
@@ -140,62 +144,56 @@ const isPreviousSectionComplete = (sections, currentIndex) => {
|
|
|
140
144
|
* @param {object} data - current form data
|
|
141
145
|
* @returns {object[]} - updated sections - note this is a clone
|
|
142
146
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
147
|
+
var getUpdatedSectionStates = function getUpdatedSectionStates(sections, taskStates) {
|
|
148
|
+
var nonSequential = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
149
|
+
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
146
150
|
// Make a clone and handle any hidden sections.
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
var clone = sections.map(function (section) {
|
|
152
|
+
var showWhen = section.show_when ? [section.show_when].flat() : [];
|
|
149
153
|
if (data && !_utils.default.Condition.meetsAll(showWhen, data)) {
|
|
150
|
-
return {
|
|
151
|
-
...section,
|
|
154
|
+
return _objectSpread(_objectSpread({}, section), {}, {
|
|
152
155
|
skipped: true,
|
|
153
|
-
tasks: section.tasks.map(task
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
tasks: section.tasks.map(function (task) {
|
|
157
|
+
return _objectSpread(_objectSpread({}, task), {}, {
|
|
158
|
+
state: _models.TaskStates.TYPES.SKIPPED
|
|
159
|
+
});
|
|
160
|
+
})
|
|
161
|
+
});
|
|
158
162
|
}
|
|
159
163
|
;
|
|
160
|
-
return {
|
|
161
|
-
...section
|
|
162
|
-
};
|
|
164
|
+
return _objectSpread({}, section);
|
|
163
165
|
});
|
|
164
166
|
|
|
165
167
|
// Now iterate through the clone and handle any hidden tasks.
|
|
166
|
-
clone.forEach(s
|
|
167
|
-
|
|
168
|
-
section.tasks = section.tasks.map(task
|
|
169
|
-
|
|
168
|
+
clone.forEach(function (s) {
|
|
169
|
+
var section = s;
|
|
170
|
+
section.tasks = section.tasks.map(function (task) {
|
|
171
|
+
var showWhen = task.show_when ? [task.show_when].flat() : [];
|
|
170
172
|
if (data && !_utils.default.Condition.meetsAll(showWhen, data)) {
|
|
171
|
-
return {
|
|
172
|
-
...task,
|
|
173
|
+
return _objectSpread(_objectSpread({}, task), {}, {
|
|
173
174
|
state: _models.TaskStates.TYPES.SKIPPED
|
|
174
|
-
};
|
|
175
|
+
});
|
|
175
176
|
}
|
|
176
|
-
return {
|
|
177
|
-
...task
|
|
178
|
-
};
|
|
177
|
+
return _objectSpread({}, task);
|
|
179
178
|
});
|
|
180
179
|
});
|
|
181
180
|
|
|
182
181
|
// Update the taskStates to account for skipped tasks.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
states[task.name] = {
|
|
189
|
-
...states[task.name],
|
|
182
|
+
var states = _objectSpread({}, taskStates);
|
|
183
|
+
clone.forEach(function (section) {
|
|
184
|
+
section.tasks.filter(function (t) {
|
|
185
|
+
return t.state === _models.TaskStates.TYPES.SKIPPED;
|
|
186
|
+
}).forEach(function (task) {
|
|
187
|
+
states[task.name] = _objectSpread(_objectSpread({}, states[task.name]), {}, {
|
|
190
188
|
state: _models.TaskStates.TYPES.SKIPPED
|
|
191
|
-
};
|
|
189
|
+
});
|
|
192
190
|
});
|
|
193
191
|
});
|
|
194
192
|
|
|
195
193
|
// Now figure out all the task states.
|
|
196
|
-
clone.forEach((s, index)
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
clone.forEach(function (s, index) {
|
|
195
|
+
var section = s;
|
|
196
|
+
var allowFirst = index === 0 || isPreviousSectionComplete(clone, index);
|
|
199
197
|
section.tasks = updateTasks(section, states, nonSequential, allowFirst);
|
|
200
198
|
});
|
|
201
199
|
return clone;
|