@ukhomeoffice/cop-react-form-renderer 4.67.0 → 4.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/Answer.js +6 -16
- package/dist/components/CheckYourAnswers/Answer.test.js +104 -129
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +26 -64
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +428 -555
- package/dist/components/CheckYourAnswers/index.js +0 -3
- package/dist/components/CollectionPage/CollectionPage.js +13 -42
- package/dist/components/CollectionPage/CollectionPage.test.js +160 -206
- package/dist/components/CollectionPage/index.js +0 -3
- package/dist/components/FormComponent/Collection.js +35 -79
- package/dist/components/FormComponent/Collection.test.js +340 -391
- package/dist/components/FormComponent/Container.js +10 -31
- package/dist/components/FormComponent/Container.test.js +304 -357
- package/dist/components/FormComponent/FormComponent.js +17 -60
- package/dist/components/FormComponent/FormComponent.test.js +190 -228
- package/dist/components/FormComponent/helpers/addLabel.js +4 -7
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
- package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
- package/dist/components/FormComponent/helpers/index.js +0 -4
- package/dist/components/FormComponent/index.js +0 -3
- package/dist/components/FormPage/FormPage.js +21 -53
- package/dist/components/FormPage/FormPage.test.js +122 -160
- package/dist/components/FormPage/index.js +0 -3
- package/dist/components/FormRenderer/FormRenderer.js +106 -296
- package/dist/components/FormRenderer/FormRenderer.test.js +820 -1058
- package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
- package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
- package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
- package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
- package/dist/components/FormRenderer/handlers/index.js +0 -5
- package/dist/components/FormRenderer/handlers/navigate.js +0 -5
- package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
- package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +12 -16
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +48 -11
- package/dist/components/FormRenderer/helpers/getCYA.js +0 -9
- package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
- package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
- package/dist/components/FormRenderer/helpers/getPage.js +0 -5
- package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
- package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +4 -7
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +32 -41
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +122 -8
- package/dist/components/FormRenderer/helpers/index.js +1 -11
- package/dist/components/FormRenderer/index.js +0 -3
- package/dist/components/FormRenderer/onCYAAction.js +8 -30
- package/dist/components/FormRenderer/onCYAAction.test.js +54 -79
- package/dist/components/FormRenderer/onPageAction.js +123 -0
- package/dist/components/FormRenderer/onPageAction.test.js +632 -0
- package/dist/components/PageActions/ActionButton.js +2 -17
- package/dist/components/PageActions/ActionButton.test.js +58 -81
- package/dist/components/PageActions/PageActions.js +3 -10
- package/dist/components/PageActions/PageActions.test.js +95 -120
- package/dist/components/PageActions/index.js +0 -3
- package/dist/components/SummaryList/GroupAction.js +5 -26
- package/dist/components/SummaryList/GroupAction.test.js +14 -28
- package/dist/components/SummaryList/RowAction.js +5 -25
- package/dist/components/SummaryList/RowAction.test.js +14 -28
- package/dist/components/SummaryList/SummaryList.js +7 -31
- package/dist/components/SummaryList/SummaryList.test.js +69 -126
- package/dist/components/SummaryList/SummaryListHeadingRow.js +3 -8
- package/dist/components/SummaryList/SummaryListRow.js +4 -8
- package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
- package/dist/components/SummaryList/helpers/index.js +0 -2
- package/dist/components/SummaryList/index.js +0 -3
- package/dist/components/TaskList/Task.js +9 -31
- package/dist/components/TaskList/Task.test.js +32 -59
- package/dist/components/TaskList/TaskList.js +32 -59
- package/dist/components/TaskList/TaskList.test.js +52 -90
- package/dist/components/TaskList/TaskState.js +2 -10
- package/dist/components/TaskList/TaskState.test.js +23 -41
- package/dist/components/TaskList/index.js +0 -3
- package/dist/components/index.js +0 -7
- package/dist/context/HooksContext/HooksContext.js +21 -39
- package/dist/context/HooksContext/HooksContext.test.js +18 -34
- package/dist/context/HooksContext/index.js +0 -5
- package/dist/context/ValidationContext/ValidationContext.js +26 -56
- package/dist/context/ValidationContext/ValidationContext.test.js +43 -64
- package/dist/context/ValidationContext/index.js +0 -5
- package/dist/context/index.js +0 -3
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/useAxios.js +17 -36
- package/dist/hooks/useGetRequest.js +57 -93
- package/dist/hooks/useHooks.js +2 -4
- package/dist/hooks/useRefData.js +14 -41
- package/dist/hooks/useValidation.js +2 -4
- package/dist/index.js +0 -9
- package/dist/models/PageAction.js +4 -4
- package/dist/models/TaskStates.js +4 -4
- package/dist/models/index.js +1 -10
- package/dist/setupTests.js +0 -13
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +1 -19
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +4 -11
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +4 -9
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +4 -8
- package/dist/utils/CheckYourAnswers/getCYARow.js +3 -11
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +60 -25
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +6 -21
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +2 -9
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +4 -20
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +7 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +4 -32
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +4 -34
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +4 -15
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +4 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +7 -25
- package/dist/utils/CheckYourAnswers/index.js +1 -3
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -15
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +1 -3
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +4 -12
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +5 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +1 -2
- package/dist/utils/CollectionPage/index.js +1 -5
- package/dist/utils/CollectionPage/mergeCollectionPages.js +5 -11
- package/dist/utils/CollectionPage/mergeCollectionPages.test.js +1 -2
- package/dist/utils/Component/addShowWhen.js +4 -10
- package/dist/utils/Component/addShowWhen.test.js +1 -2
- package/dist/utils/Component/applyToComponentTree.js +4 -18
- package/dist/utils/Component/applyToComponentTree.test.js +4 -8
- package/dist/utils/Component/cleanAttributes.js +1 -8
- package/dist/utils/Component/cleanAttributes.test.js +15 -16
- package/dist/utils/Component/elevateNestedComponents.js +0 -6
- package/dist/utils/Component/elevateNestedComponents.test.js +0 -2
- package/dist/utils/Component/getComponent.js +13 -86
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +33 -51
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +12 -29
- package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +6 -24
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
- package/dist/utils/Component/getComponentTests/getComponent.list.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +5 -22
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
- package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +4 -10
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +8 -35
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +6 -23
- package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +10 -34
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +12 -31
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
- package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
- package/dist/utils/Component/getDefaultValue.js +4 -8
- package/dist/utils/Component/getDefaultValue.test.js +0 -3
- package/dist/utils/Component/index.js +0 -10
- package/dist/utils/Component/isEditable.js +1 -4
- package/dist/utils/Component/isEditable.test.js +1 -5
- package/dist/utils/Component/optionIsSelected.js +22 -0
- package/dist/utils/Component/optionIsSelected.test.js +42 -0
- package/dist/utils/Component/setupContainerComponentsPath.js +4 -9
- package/dist/utils/Component/setupContainerComponentsPath.test.js +0 -3
- package/dist/utils/Component/showComponent.js +1 -8
- package/dist/utils/Component/showComponent.test.js +1 -2
- package/dist/utils/Component/wrapInFormGroup.js +0 -7
- package/dist/utils/Condition/index.js +0 -5
- package/dist/utils/Condition/meetsAllConditions.js +0 -9
- package/dist/utils/Condition/meetsAllConditions.test.js +1 -2
- package/dist/utils/Condition/meetsCondition.js +9 -34
- package/dist/utils/Condition/meetsCondition.test.js +21 -14
- package/dist/utils/Condition/meetsOneCondition.js +1 -9
- package/dist/utils/Condition/meetsOneCondition.test.js +1 -2
- package/dist/utils/Condition/setupConditions.js +4 -13
- package/dist/utils/Condition/setupConditions.test.js +0 -2
- package/dist/utils/Container/getEditableComponents.js +0 -7
- package/dist/utils/Container/getEditableComponents.test.js +1 -12
- package/dist/utils/Container/index.js +0 -5
- package/dist/utils/Container/setupNesting.js +4 -12
- package/dist/utils/Container/setupNesting.test.js +4 -10
- package/dist/utils/Container/showContainer.js +9 -18
- package/dist/utils/Container/showContainer.test.js +1 -2
- package/dist/utils/Data/applyFormula.js +6 -29
- package/dist/utils/Data/applyFormula.test.js +1 -2
- package/dist/utils/Data/getAutocompleteSource.js +1 -5
- package/dist/utils/Data/getAutocompleteSource.test.js +1 -2
- package/dist/utils/Data/getDataPath.js +3 -17
- package/dist/utils/Data/getDataPath.test.js +0 -4
- package/dist/utils/Data/getOptions.js +4 -14
- package/dist/utils/Data/getOptions.test.js +1 -2
- package/dist/utils/Data/getSourceData.js +6 -21
- package/dist/utils/Data/getSourceData.test.js +4 -6
- package/dist/utils/Data/index.js +1 -11
- package/dist/utils/Data/refDataToOptions.js +5 -13
- package/dist/utils/Data/refDataToOptions.test.js +1 -2
- package/dist/utils/Data/setDataItem.js +0 -5
- package/dist/utils/Data/setDataItem.test.js +0 -2
- package/dist/utils/Data/setupFormData.js +6 -25
- package/dist/utils/Data/setupFormData.test.js +8 -11
- package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -15
- package/dist/utils/Data/setupRefDataUrlForComponent.test.js +1 -3
- package/dist/utils/FormPage/applyConditionalProperties.js +4 -11
- package/dist/utils/FormPage/applyConditionalProperties.test.js +4 -6
- package/dist/utils/FormPage/getFormPage.js +4 -16
- package/dist/utils/FormPage/getFormPage.test.js +10 -9
- package/dist/utils/FormPage/getFormPages.js +4 -9
- package/dist/utils/FormPage/getFormPages.test.js +6 -7
- package/dist/utils/FormPage/getPageActions.js +6 -19
- package/dist/utils/FormPage/getPageActions.test.js +1 -3
- package/dist/utils/FormPage/getParagraphFromText.js +0 -3
- package/dist/utils/FormPage/getParagraphFromText.test.js +1 -3
- package/dist/utils/FormPage/index.js +0 -7
- package/dist/utils/FormPage/showFormPage.js +9 -18
- package/dist/utils/FormPage/showFormPage.test.js +0 -2
- package/dist/utils/FormPage/showFormPageCYA.js +0 -5
- package/dist/utils/FormPage/showFormPageCYA.test.js +0 -2
- package/dist/utils/FormPage/useComponent.js +7 -19
- package/dist/utils/FormPage/useComponent.test.js +4 -7
- package/dist/utils/Format/formatData.js +0 -5
- package/dist/utils/Format/formatData.test.js +1 -2
- package/dist/utils/Format/formatDataForComponent.js +1 -6
- package/dist/utils/Format/formatDataForComponent.test.js +28 -47
- package/dist/utils/Format/formatDataForForm.js +4 -9
- package/dist/utils/Format/formatDataForForm.test.js +14 -11
- package/dist/utils/Format/formatDataForPage.js +1 -5
- package/dist/utils/Format/formatDataForPage.test.js +15 -12
- package/dist/utils/Format/index.js +1 -6
- package/dist/utils/Hub/getFormHub.js +0 -8
- package/dist/utils/Hub/getFormHub.test.js +6 -8
- package/dist/utils/Hub/index.js +1 -3
- package/dist/utils/Meta/documents/getDocuments.js +1 -4
- package/dist/utils/Meta/documents/getDocuments.test.js +4 -10
- package/dist/utils/Meta/documents/index.js +1 -5
- package/dist/utils/Meta/documents/setDocumentsForField.js +4 -11
- package/dist/utils/Meta/documents/setDocumentsForField.test.js +4 -16
- package/dist/utils/Meta/index.js +1 -4
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
- package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -2
- package/dist/utils/Operate/getFirstOf.js +2 -9
- package/dist/utils/Operate/getFirstOf.test.js +0 -2
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +6 -2
- package/dist/utils/Operate/index.js +0 -3
- package/dist/utils/Operate/persistValueInFormData.js +1 -8
- package/dist/utils/Operate/persistValueInFormData.test.js +0 -4
- package/dist/utils/Operate/runPageOperations.js +3 -19
- package/dist/utils/Operate/runPageOperations.test.js +4 -6
- package/dist/utils/Operate/setValueInFormData.js +2 -7
- package/dist/utils/Operate/setValueInFormData.test.js +0 -2
- package/dist/utils/Operate/shouldRun.js +1 -14
- package/dist/utils/Operate/shouldRun.test.js +5 -8
- package/dist/utils/Validate/additional/conditionallyRequired.js +0 -3
- package/dist/utils/Validate/additional/conditionallyRequired.test.js +0 -2
- package/dist/utils/Validate/additional/index.js +1 -22
- package/dist/utils/Validate/additional/index.test.js +0 -6
- package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
- package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
- package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +4 -8
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
- package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
- package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -3
- package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
- package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -5
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +0 -3
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +0 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +0 -6
- package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +4 -7
- package/dist/utils/Validate/additional/utils.js +10 -26
- package/dist/utils/Validate/index.js +1 -11
- package/dist/utils/Validate/validateCollection.js +4 -10
- package/dist/utils/Validate/validateCollection.test.js +4 -6
- package/dist/utils/Validate/validateComponent.js +5 -40
- package/dist/utils/Validate/validateComponent.test.js +120 -22
- package/dist/utils/Validate/validateContainer.js +4 -14
- package/dist/utils/Validate/validateContainer.test.js +4 -10
- package/dist/utils/Validate/validateDate.js +6 -38
- package/dist/utils/Validate/validateDate.test.js +0 -4
- package/dist/utils/Validate/validateEmail.js +1 -8
- package/dist/utils/Validate/validateEmail.test.js +5 -4
- package/dist/utils/Validate/validateMultifile.js +0 -7
- package/dist/utils/Validate/validateMultifile.test.js +5 -6
- package/dist/utils/Validate/validatePage.js +4 -16
- package/dist/utils/Validate/validatePage.test.js +30 -25
- package/dist/utils/Validate/validateRegex.js +0 -10
- package/dist/utils/Validate/validateRegex.test.js +5 -4
- package/dist/utils/Validate/validateRequired.js +0 -8
- package/dist/utils/Validate/validateRequired.test.js +5 -4
- package/dist/utils/Validate/validateTextArea.js +0 -8
- package/dist/utils/Validate/validateTextArea.test.js +0 -2
- package/dist/utils/Validate/validateTime.js +5 -22
- package/dist/utils/Validate/validateTime.test.js +0 -2
- package/dist/utils/index.js +4 -20
- package/package.json +2 -2
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
|
-
|
|
5
4
|
var _getPage = _interopRequireDefault(require("./getPage"));
|
|
6
|
-
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
6
|
// Local imports
|
|
7
|
+
|
|
10
8
|
describe('components', function () {
|
|
11
9
|
describe('FormRenderer', function () {
|
|
12
10
|
describe('helpers', function () {
|
|
@@ -4,24 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../../models");
|
|
9
|
-
|
|
10
8
|
var slicePages = function slicePages(pages, currentPageId) {
|
|
11
9
|
return pages.slice(0, pages.findIndex(function (p) {
|
|
12
10
|
return (p === null || p === void 0 ? void 0 : p.id) === currentPageId ? true : false;
|
|
13
11
|
}));
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
var getRelevantPages = function getRelevantPages(formState, pages, currentTaskPages) {
|
|
17
14
|
var _formState$page;
|
|
18
|
-
|
|
19
15
|
if (((_formState$page = formState.page) === null || _formState$page === void 0 ? void 0 : _formState$page.type) === _models.FormPages.PARTIAL_CYA) {
|
|
20
16
|
return currentTaskPages ? slicePages(currentTaskPages, formState.pageId) : slicePages(pages, formState.pageId);
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
return currentTaskPages ? currentTaskPages : pages;
|
|
24
19
|
};
|
|
25
|
-
|
|
26
20
|
var _default = getRelevantPages;
|
|
27
21
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
|
-
|
|
5
4
|
var _getRelevantPages = _interopRequireDefault(require("../helpers/getRelevantPages"));
|
|
6
|
-
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
6
|
// Local imports
|
|
7
|
+
|
|
10
8
|
describe('components', function () {
|
|
11
9
|
describe('FormRenderer', function () {
|
|
12
10
|
describe('helpers', function () {
|
|
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../../models");
|
|
9
|
-
|
|
10
8
|
var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentPageId, action, formData, currentTask, isCompleted, sections) {
|
|
15
11
|
if (formType === _models.FormTypes.TASK || formType === _models.FormTypes.FORM_WITH_TASK) {
|
|
16
12
|
var formStatus = formData.formStatus || {};
|
|
17
13
|
formStatus.tasks = formStatus.tasks || {};
|
|
18
14
|
formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
|
|
19
|
-
|
|
20
15
|
if (currentPageId === (_models.FormPages.CYA || 'submitForm') && isCompleted) {
|
|
21
16
|
formStatus.tasks[currentTask.name].complete = true;
|
|
22
17
|
} else if (!currentTask.name) {
|
|
@@ -28,7 +23,6 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
|
|
|
28
23
|
sections.forEach(function (section) {
|
|
29
24
|
section.tasks.forEach(function (task) {
|
|
30
25
|
var lastPage = task.pages[task.pages.length - 1];
|
|
31
|
-
|
|
32
26
|
if ((lastPage === currentPageId || lastPage.id === currentPageId) && isCompleted && (task === null || task === void 0 ? void 0 : task.type) === 'pre-task-list') {
|
|
33
27
|
formStatus.tasks[task.name] = {
|
|
34
28
|
complete: isCompleted,
|
|
@@ -54,21 +48,17 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
|
|
|
54
48
|
currentPage: currentPageId
|
|
55
49
|
};
|
|
56
50
|
}
|
|
57
|
-
|
|
58
51
|
formStatus.taskPage = formStatus.tasks[currentTask.name].currentPage;
|
|
59
52
|
return formStatus;
|
|
60
53
|
}
|
|
61
|
-
|
|
62
54
|
if ((action === null || action === void 0 ? void 0 : action.type) === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
63
55
|
return {
|
|
64
56
|
page: currentPageId
|
|
65
57
|
};
|
|
66
58
|
}
|
|
67
|
-
|
|
68
59
|
return {
|
|
69
60
|
page: (0, _getNextPageId.default)(formType, pages, currentPageId, action, formData)
|
|
70
61
|
};
|
|
71
62
|
};
|
|
72
|
-
|
|
73
63
|
var _default = getSubmissionStatus;
|
|
74
64
|
exports.default = _default;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
|
-
|
|
5
4
|
var _PageAction = require("../../../models/PageAction");
|
|
6
|
-
|
|
7
5
|
var _getSubmissionStatus = _interopRequireDefault(require("./getSubmissionStatus"));
|
|
8
|
-
|
|
9
6
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
11
|
describe('components', function () {
|
|
14
12
|
describe('FormRenderer', function () {
|
|
15
13
|
describe('helpers', function () {
|
|
@@ -51,7 +49,6 @@ describe('components', function () {
|
|
|
51
49
|
var FORM_DATA = {
|
|
52
50
|
radios: OPTIONS[0].value
|
|
53
51
|
}; // 'romeo'
|
|
54
|
-
|
|
55
52
|
var PAGES = [{
|
|
56
53
|
id: 'alpha'
|
|
57
54
|
}, {
|
|
@@ -4,19 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = _interopRequireDefault(require("../../../utils"));
|
|
9
|
-
|
|
10
8
|
var _models = require("../../../models");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
10
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
14
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
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); }
|
|
20
16
|
/**
|
|
21
17
|
*
|
|
22
18
|
* @param {boolean} complete - true if task complete
|
|
@@ -26,34 +22,30 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
26
22
|
*/
|
|
27
23
|
var getCurrentTaskState = function getCurrentTaskState(_ref) {
|
|
28
24
|
var complete = _ref.complete,
|
|
29
|
-
|
|
25
|
+
currentPage = _ref.currentPage;
|
|
30
26
|
var defaultState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _models.TaskStates.TYPES.NOT_STARTED;
|
|
31
|
-
|
|
32
27
|
if (complete) {
|
|
33
28
|
return _models.TaskStates.TYPES.COMPLETE;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
if (currentPage) {
|
|
37
31
|
return _models.TaskStates.TYPES.IN_PROGRESS;
|
|
38
32
|
}
|
|
39
|
-
|
|
40
33
|
return defaultState;
|
|
41
34
|
};
|
|
35
|
+
|
|
42
36
|
/**
|
|
43
37
|
* check if dependent tasks have been completed
|
|
44
38
|
* @param tasks - list of tasks
|
|
45
39
|
* @param mustBeComplete - tasks which are depended on
|
|
46
40
|
* @returns {boolean} true if dependent tasks complete
|
|
47
41
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
42
|
var allDependentTasksComplete = function allDependentTasksComplete(tasks, mustBeComplete) {
|
|
51
43
|
return mustBeComplete.reduce(function (allComplete, taskName) {
|
|
52
44
|
var _tasks$taskName;
|
|
53
|
-
|
|
54
45
|
return allComplete && ((_tasks$taskName = tasks[taskName]) === null || _tasks$taskName === void 0 ? void 0 : _tasks$taskName.complete);
|
|
55
46
|
}, true);
|
|
56
47
|
};
|
|
48
|
+
|
|
57
49
|
/**
|
|
58
50
|
* return updated task state
|
|
59
51
|
* @param {object} task - current task object
|
|
@@ -65,46 +57,55 @@ var allDependentTasksComplete = function allDependentTasksComplete(tasks, mustBe
|
|
|
65
57
|
* @returns {TYPES|string} new state
|
|
66
58
|
*/
|
|
67
59
|
|
|
68
|
-
|
|
69
60
|
var updateTaskState = function updateTaskState(task, taskIndex, taskList, tasks) {
|
|
70
|
-
var _taskList;
|
|
71
|
-
|
|
72
61
|
var nonSequential = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
73
62
|
var allowFirst = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
74
|
-
|
|
75
63
|
if (tasks[task.name]) {
|
|
76
64
|
return getCurrentTaskState(tasks[task.name], task.state);
|
|
77
65
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
taskIndex ?
|
|
81
|
-
|
|
66
|
+
return nonSequential ? task.depends_on && !allDependentTasksComplete(tasks, task.depends_on) ? _models.TaskStates.TYPES.CANNOT_START_YET : _models.TaskStates.TYPES.NOT_STARTED : (
|
|
67
|
+
// First task in taskList
|
|
68
|
+
taskIndex ?
|
|
69
|
+
// any task after a complete task in same section
|
|
70
|
+
isPreviousTaskComplete(taskList, taskIndex) : allowFirst) ? _models.TaskStates.TYPES.NOT_STARTED : _models.TaskStates.TYPES.CANNOT_START_YET;
|
|
82
71
|
};
|
|
72
|
+
|
|
83
73
|
/**
|
|
84
74
|
* update all tasks in section with new state.
|
|
85
75
|
* note use of clone and forEach as some tasks depend on previous update
|
|
86
76
|
* @param {object} section - section to be processed
|
|
87
|
-
* @param {number} sectionIndex - index number of current section
|
|
88
77
|
* @param tasks - task updates
|
|
89
78
|
* @param nonSequential - true if non-sequential task performance allowed
|
|
90
79
|
* @param allowFirst - true if first task can be started
|
|
91
80
|
* @returns {object} - updated section
|
|
92
81
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
var updateTasks = function updateTasks(section, sectionIndex, tasks, nonSequential, allowFirst) {
|
|
82
|
+
var updateTasks = function updateTasks(section, tasks, nonSequential, allowFirst, data) {
|
|
96
83
|
var clone = section.tasks.map(function (a) {
|
|
97
84
|
return _objectSpread({}, a);
|
|
98
85
|
});
|
|
99
86
|
clone.forEach(function (task, taskIndex, taskList) {
|
|
87
|
+
var _task$show_when;
|
|
100
88
|
if (section.skipped) {
|
|
101
89
|
task.state = _models.TaskStates.TYPES.SKIPPED;
|
|
90
|
+
} else if (data && !_utils.default.Condition.met(task.show_when, data[(_task$show_when = task.show_when) === null || _task$show_when === void 0 ? void 0 : _task$show_when.field])) {
|
|
91
|
+
task.state = _models.TaskStates.TYPES.SKIPPED;
|
|
102
92
|
} else {
|
|
103
93
|
task.state = updateTaskState(task, taskIndex, taskList, tasks, nonSequential, allowFirst);
|
|
104
94
|
}
|
|
105
95
|
});
|
|
106
96
|
return clone;
|
|
107
97
|
};
|
|
98
|
+
var isPreviousTaskComplete = function isPreviousTaskComplete(tasks, taskIndex) {
|
|
99
|
+
var lastTaskState = tasks[taskIndex - 1].state;
|
|
100
|
+
if (lastTaskState === _models.TaskStates.TYPES.COMPLETE) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (lastTaskState === _models.TaskStates.TYPES.SKIPPED) {
|
|
104
|
+
return taskIndex - 1 === 0 ? true : isPreviousTaskComplete(tasks, taskIndex - 1);
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
};
|
|
108
|
+
|
|
108
109
|
/**
|
|
109
110
|
* Checks if the previous section has been completed. If the last section
|
|
110
111
|
* was skipped then this function will check the section before that until
|
|
@@ -114,23 +115,18 @@ var updateTasks = function updateTasks(section, sectionIndex, tasks, nonSequenti
|
|
|
114
115
|
* @returns {boolean} true if the last non-skipped section is complete, false
|
|
115
116
|
* if not.
|
|
116
117
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
118
|
var isPreviousSectionComplete = function isPreviousSectionComplete(sections, currentIndex) {
|
|
120
119
|
var _sections, _sections$tasks$slice;
|
|
121
|
-
|
|
122
120
|
var lastTaskState = (_sections = sections[currentIndex - 1]) === null || _sections === void 0 ? void 0 : (_sections$tasks$slice = _sections.tasks.slice(-1)[0]) === null || _sections$tasks$slice === void 0 ? void 0 : _sections$tasks$slice.state;
|
|
123
|
-
|
|
124
121
|
if (lastTaskState === _models.TaskStates.TYPES.COMPLETE) {
|
|
125
122
|
return true;
|
|
126
123
|
}
|
|
127
|
-
|
|
128
124
|
if (lastTaskState === _models.TaskStates.TYPES.SKIPPED) {
|
|
129
125
|
return currentIndex - 1 === 0 ? true : isPreviousSectionComplete(sections, currentIndex - 1);
|
|
130
126
|
}
|
|
131
|
-
|
|
132
127
|
return false;
|
|
133
128
|
};
|
|
129
|
+
|
|
134
130
|
/**
|
|
135
131
|
* update task states in sections
|
|
136
132
|
* @param {object[]} sections - array of sections
|
|
@@ -139,8 +135,6 @@ var isPreviousSectionComplete = function isPreviousSectionComplete(sections, cur
|
|
|
139
135
|
* @param {object} data - current form data
|
|
140
136
|
* @returns {object[]} - updated sections - note this is a clone
|
|
141
137
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
138
|
var getUpdatedSectionStates = function getUpdatedSectionStates(sections, tasks) {
|
|
145
139
|
var nonSequential = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
146
140
|
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
@@ -149,18 +143,15 @@ var getUpdatedSectionStates = function getUpdatedSectionStates(sections, tasks)
|
|
|
149
143
|
});
|
|
150
144
|
clone.forEach(function (section, sectionIndex, sectionList) {
|
|
151
145
|
var _section$show_when;
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
var allowFirst = sectionIndex === 0 || isPreviousSectionComplete(sectionList, sectionIndex);
|
|
147
|
+
// Support a single show_when check on a section. Support for an
|
|
154
148
|
// array of checks will have to be added if required.
|
|
155
|
-
|
|
156
149
|
if (data && !_utils.default.Condition.met(section.show_when, data[(_section$show_when = section.show_when) === null || _section$show_when === void 0 ? void 0 : _section$show_when.field])) {
|
|
157
150
|
section.skipped = true;
|
|
158
151
|
}
|
|
159
|
-
|
|
160
|
-
section.tasks = updateTasks(section, sectionIndex, tasks, nonSequential, allowFirst);
|
|
152
|
+
section.tasks = updateTasks(section, tasks, nonSequential, allowFirst, data);
|
|
161
153
|
});
|
|
162
154
|
return clone;
|
|
163
155
|
};
|
|
164
|
-
|
|
165
156
|
var _default = getUpdatedSectionStates;
|
|
166
157
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getUpdatedSectionStates = _interopRequireDefault(require("./getUpdatedSectionStates"));
|
|
4
|
-
|
|
5
4
|
var _models = require("../../../models");
|
|
6
|
-
|
|
7
5
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
|
|
9
6
|
// Local imports
|
|
7
|
+
|
|
10
8
|
describe('components.FormRenderer.helpers.getUpdatedSectionStates', function () {
|
|
11
9
|
describe('sequential tasks', function () {
|
|
12
10
|
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 () {
|
|
@@ -157,6 +155,125 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
157
155
|
expect(updatedSections[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
158
156
|
expect(updatedSections[1].tasks[1].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
159
157
|
});
|
|
158
|
+
it("should set the status of any tasks with a failed show_when to '".concat(_models.TaskStates.TYPES.SKIPPED, "'"), function () {
|
|
159
|
+
var SECTIONS = [{
|
|
160
|
+
name: 'Add event details',
|
|
161
|
+
tasks: [{
|
|
162
|
+
name: 'Date, location and mode details',
|
|
163
|
+
pages: ['eventDate', 'eventMode'],
|
|
164
|
+
show_when: {
|
|
165
|
+
field: 'field',
|
|
166
|
+
op: '=',
|
|
167
|
+
value: 'showMe'
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
name: 'Officer and agency details',
|
|
171
|
+
pages: ['officeDetails'],
|
|
172
|
+
show_when: {
|
|
173
|
+
field: 'field',
|
|
174
|
+
op: '=',
|
|
175
|
+
value: 'hideMe'
|
|
176
|
+
}
|
|
177
|
+
}]
|
|
178
|
+
}];
|
|
179
|
+
var DATA = {
|
|
180
|
+
field: 'hideMe'
|
|
181
|
+
};
|
|
182
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, {}, false, DATA);
|
|
183
|
+
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
184
|
+
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
185
|
+
});
|
|
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"), function () {
|
|
187
|
+
var SECTIONS = [{
|
|
188
|
+
name: 'Add event details',
|
|
189
|
+
tasks: [{
|
|
190
|
+
name: 'task one',
|
|
191
|
+
pages: ['eventDate', 'eventMode'],
|
|
192
|
+
show_when: {
|
|
193
|
+
field: 'field',
|
|
194
|
+
op: '=',
|
|
195
|
+
value: 'hideMe'
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
name: 'task two',
|
|
199
|
+
pages: ['eventDate', 'eventMode'],
|
|
200
|
+
show_when: {
|
|
201
|
+
field: 'field',
|
|
202
|
+
op: '=',
|
|
203
|
+
value: 'showMe'
|
|
204
|
+
}
|
|
205
|
+
}, {
|
|
206
|
+
name: 'task three',
|
|
207
|
+
pages: ['eventDate', 'eventMode'],
|
|
208
|
+
show_when: {
|
|
209
|
+
field: 'field',
|
|
210
|
+
op: '=',
|
|
211
|
+
value: 'showMe'
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
name: 'task four',
|
|
215
|
+
pages: ['officeDetails'],
|
|
216
|
+
show_when: {
|
|
217
|
+
field: 'field',
|
|
218
|
+
op: '=',
|
|
219
|
+
value: 'hideMe'
|
|
220
|
+
}
|
|
221
|
+
}]
|
|
222
|
+
}];
|
|
223
|
+
var DATA = {
|
|
224
|
+
field: 'hideMe'
|
|
225
|
+
};
|
|
226
|
+
var TASKS = {
|
|
227
|
+
'task one': {
|
|
228
|
+
complete: true
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, false, DATA);
|
|
232
|
+
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
233
|
+
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
234
|
+
expect(updatedSections[0].tasks[2].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
235
|
+
expect(updatedSections[0].tasks[3].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
236
|
+
});
|
|
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"), function () {
|
|
238
|
+
var SECTIONS = [{
|
|
239
|
+
name: 'Add event details',
|
|
240
|
+
tasks: [{
|
|
241
|
+
name: 'task one',
|
|
242
|
+
pages: ['eventDate', 'eventMode'],
|
|
243
|
+
show_when: {
|
|
244
|
+
field: 'field',
|
|
245
|
+
op: '=',
|
|
246
|
+
value: 'showMe'
|
|
247
|
+
}
|
|
248
|
+
}, {
|
|
249
|
+
name: 'task two',
|
|
250
|
+
pages: ['officeDetails'],
|
|
251
|
+
show_when: {
|
|
252
|
+
field: 'field',
|
|
253
|
+
op: '=',
|
|
254
|
+
value: 'hideMe'
|
|
255
|
+
}
|
|
256
|
+
}]
|
|
257
|
+
}, {
|
|
258
|
+
name: 'Add people details',
|
|
259
|
+
tasks: [{
|
|
260
|
+
name: 'task three',
|
|
261
|
+
pages: ['eventDate', 'eventMode']
|
|
262
|
+
}]
|
|
263
|
+
}];
|
|
264
|
+
var DATA = {
|
|
265
|
+
field: 'showMe'
|
|
266
|
+
};
|
|
267
|
+
var TASKS = {
|
|
268
|
+
'task one': {
|
|
269
|
+
complete: true
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
var updatedSections = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, false, DATA);
|
|
273
|
+
expect(updatedSections[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.COMPLETE);
|
|
274
|
+
expect(updatedSections[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.SKIPPED);
|
|
275
|
+
expect(updatedSections[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED);
|
|
276
|
+
});
|
|
160
277
|
});
|
|
161
278
|
it("should set the status of any tasks to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "' if previous tasks have been skipped"), function () {
|
|
162
279
|
var SECTIONS = [{
|
|
@@ -218,13 +335,11 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
218
335
|
it("should set all states to '".concat(_models.TaskStates.TYPES.NOT_STARTED, "', except any that depend on others"), function () {
|
|
219
336
|
var RESULT = (0, _getUpdatedSectionStates.default)(SECTIONS, {}, NON_SEQUENTIAL);
|
|
220
337
|
expect(RESULT[0].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Alpha
|
|
221
|
-
|
|
222
338
|
expect(RESULT[0].tasks[1].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Bravo
|
|
223
|
-
|
|
224
339
|
expect(RESULT[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
225
|
-
|
|
226
340
|
expect(RESULT[2].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Delta
|
|
227
341
|
});
|
|
342
|
+
|
|
228
343
|
it('should keep dependent state unable to start if any dependencies are not complete', function () {
|
|
229
344
|
var ALPHA_COMPLETE = (0, _getUpdatedSectionStates.default)(SECTIONS, {
|
|
230
345
|
Alpha: {
|
|
@@ -232,7 +347,6 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
232
347
|
}
|
|
233
348
|
}, NON_SEQUENTIAL);
|
|
234
349
|
expect(ALPHA_COMPLETE[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
235
|
-
|
|
236
350
|
var BRAVO_COMPLETE = (0, _getUpdatedSectionStates.default)(SECTIONS, {
|
|
237
351
|
Bravo: {
|
|
238
352
|
complete: true
|
|
@@ -240,6 +354,7 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
240
354
|
}, NON_SEQUENTIAL);
|
|
241
355
|
expect(BRAVO_COMPLETE[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.CANNOT_START_YET); // Charlie
|
|
242
356
|
});
|
|
357
|
+
|
|
243
358
|
it('should allow dependent state to start if all dependencies are complete', function () {
|
|
244
359
|
var TASKS = {
|
|
245
360
|
'Alpha': {
|
|
@@ -252,7 +367,6 @@ describe('components.FormRenderer.helpers.getUpdatedSectionStates', function ()
|
|
|
252
367
|
};
|
|
253
368
|
var RESULT = (0, _getUpdatedSectionStates.default)(SECTIONS, TASKS, NON_SEQUENTIAL);
|
|
254
369
|
expect(RESULT[1].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Charlie
|
|
255
|
-
|
|
256
370
|
expect(RESULT[2].tasks[0].state).toEqual(_models.TaskStates.TYPES.NOT_STARTED); // Delta
|
|
257
371
|
});
|
|
258
372
|
});
|
|
@@ -4,28 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.helpers = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _canActionProceed = _interopRequireDefault(require("./canActionProceed"));
|
|
9
|
-
|
|
10
8
|
var _canCYASubmit = _interopRequireDefault(require("./canCYASubmit"));
|
|
11
|
-
|
|
12
9
|
var _cleanHiddenNestedData = _interopRequireDefault(require("./cleanHiddenNestedData"));
|
|
13
|
-
|
|
14
10
|
var _getFormState = _interopRequireDefault(require("./getFormState"));
|
|
15
|
-
|
|
16
11
|
var _getRelevantPages = _interopRequireDefault(require("./getRelevantPages"));
|
|
17
|
-
|
|
18
12
|
var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
|
|
19
|
-
|
|
20
13
|
var _getPage = _interopRequireDefault(require("./getPage"));
|
|
21
|
-
|
|
22
14
|
var _getSubmissionStatus = _interopRequireDefault(require("./getSubmissionStatus"));
|
|
23
|
-
|
|
24
15
|
var _getUpdatedSectionStates = _interopRequireDefault(require("./getUpdatedSectionStates"));
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
17
|
// Local imports
|
|
18
|
+
|
|
29
19
|
var helpers = {
|
|
30
20
|
canActionProceed: _canActionProceed.default,
|
|
31
21
|
canCYASubmit: _canCYASubmit.default,
|
|
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _FormRenderer = _interopRequireDefault(require("./FormRenderer"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = _FormRenderer.default;
|
|
13
10
|
exports.default = _default;
|
|
@@ -4,23 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _models = require("../../models");
|
|
9
|
-
|
|
10
8
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
11
|
-
|
|
12
9
|
var _handlers = _interopRequireDefault(require("./handlers"));
|
|
13
|
-
|
|
14
10
|
var _helpers = _interopRequireDefault(require("./helpers"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
12
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
18
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
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); }
|
|
24
18
|
/**
|
|
25
19
|
*
|
|
26
20
|
* @param {*} action
|
|
@@ -30,17 +24,15 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
30
24
|
// in the case of a submission will validate the fields in the page.
|
|
31
25
|
if (action.type === _models.PageAction.TYPES.SUBMIT && hub !== _models.HubFormats.TASK) {
|
|
32
26
|
setPagePoint('submit');
|
|
33
|
-
|
|
34
27
|
if (_helpers.default.canCYASubmit(pages, validate.pages)) {
|
|
35
28
|
// Submit.
|
|
36
29
|
var submissionData = _utils.default.Format.form({
|
|
37
30
|
pages: pages,
|
|
38
31
|
components: components
|
|
39
32
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
40
|
-
|
|
41
33
|
submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, submissionData, currentTask, true);
|
|
42
|
-
setData(submissionData);
|
|
43
|
-
|
|
34
|
+
setData(submissionData);
|
|
35
|
+
// Now submit the data to the backend...
|
|
44
36
|
hooks.onSubmit(action.type, submissionData, function () {
|
|
45
37
|
return hooks.onFormComplete();
|
|
46
38
|
}, function (errors) {
|
|
@@ -48,17 +40,14 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
48
40
|
});
|
|
49
41
|
}
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_CONTINUE && hub === _models.HubFormats.TASK) {
|
|
53
44
|
var shouldValidate = !(action.hasOwnProperty('validate') && !action.validate);
|
|
54
45
|
var canSubmit = shouldValidate ? _helpers.default.canCYASubmit(currentTask.fullPages, validate.pages) : true;
|
|
55
|
-
|
|
56
46
|
if (canSubmit) {
|
|
57
47
|
var _submissionData = _utils.default.Format.form({
|
|
58
48
|
pages: pages,
|
|
59
49
|
components: components
|
|
60
50
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
61
|
-
|
|
62
51
|
_submissionData.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData, currentTask, true);
|
|
63
52
|
setData(_submissionData);
|
|
64
53
|
hooks.onSubmit(action.type, _submissionData, function () {
|
|
@@ -68,20 +57,17 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
68
57
|
});
|
|
69
58
|
}
|
|
70
59
|
}
|
|
71
|
-
|
|
72
60
|
if (action.type === _models.PageAction.TYPES.SUBMIT && hub === _models.HubFormats.TASK) {
|
|
73
61
|
setPagePoint('submit');
|
|
74
|
-
|
|
75
62
|
if (_helpers.default.canCYASubmit(currentTask.fullPages, validate.pages)) {
|
|
76
63
|
// Submit.
|
|
77
64
|
var _submissionData2 = _utils.default.Format.form({
|
|
78
65
|
pages: pages,
|
|
79
66
|
components: components
|
|
80
67
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
81
|
-
|
|
82
68
|
_submissionData2.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData2, currentTask, true);
|
|
83
|
-
setData(_submissionData2);
|
|
84
|
-
|
|
69
|
+
setData(_submissionData2);
|
|
70
|
+
// Now submit the data to the backend...
|
|
85
71
|
hooks.onSubmit(action.type, _submissionData2, function () {
|
|
86
72
|
return hooks.onFormComplete();
|
|
87
73
|
}, function (errors) {
|
|
@@ -89,18 +75,14 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
89
75
|
});
|
|
90
76
|
}
|
|
91
77
|
}
|
|
92
|
-
|
|
93
78
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
94
79
|
var _shouldValidate = !(action.hasOwnProperty('validate') && !action.validate);
|
|
95
|
-
|
|
96
80
|
var _canSubmit = _shouldValidate ? _helpers.default.canCYASubmit(currentTask.fullPages, validate.pages) : true;
|
|
97
|
-
|
|
98
81
|
if (_canSubmit) {
|
|
99
82
|
var _submissionData3 = _utils.default.Format.form({
|
|
100
83
|
pages: pages,
|
|
101
84
|
components: components
|
|
102
85
|
}, _objectSpread({}, data), _models.EventTypes.SUBMIT);
|
|
103
|
-
|
|
104
86
|
_submissionData3.formStatus = _helpers.default.getSubmissionStatus(type, pages, pageId, action, _submissionData3, currentTask, false);
|
|
105
87
|
setData(_submissionData3);
|
|
106
88
|
hooks.onSubmit(action.type, _submissionData3, function () {
|
|
@@ -114,17 +96,13 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
114
96
|
});
|
|
115
97
|
}
|
|
116
98
|
}
|
|
117
|
-
|
|
118
99
|
if (action.type === _models.PageAction.TYPES.NAVIGATE) {
|
|
119
100
|
var _formState$page;
|
|
120
|
-
|
|
121
101
|
onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, (_formState$page = formState.page) === null || _formState$page === void 0 ? void 0 : _formState$page.formData));
|
|
122
102
|
}
|
|
123
|
-
|
|
124
103
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
125
104
|
hooks.onCancel();
|
|
126
105
|
}
|
|
127
106
|
};
|
|
128
|
-
|
|
129
107
|
var _default = onCYAAction;
|
|
130
108
|
exports.default = _default;
|