@ukhomeoffice/cop-react-form-renderer 4.66.1 → 4.68.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 +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 +4 -12
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
- 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 +1 -10
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +8 -23
- 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 +9 -12
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +41 -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 +7 -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/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 +2 -39
- package/dist/utils/Validate/validateComponent.test.js +4 -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
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getPageId = _interopRequireDefault(require("./getPageId"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Gets the pageId from the invoked CYA action and calls onChange if it is
|
|
14
11
|
* different to the currentPageId.
|
|
@@ -18,11 +15,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
*/
|
|
19
16
|
var cyaAction = function cyaAction(page, currentPageId, onChange) {
|
|
20
17
|
var pageId = (0, _getPageId.default)(page.action, page.pageId);
|
|
21
|
-
|
|
22
18
|
if (pageId !== currentPageId) {
|
|
23
19
|
onChange(pageId);
|
|
24
20
|
}
|
|
25
21
|
};
|
|
26
|
-
|
|
27
22
|
var _default = cyaAction;
|
|
28
23
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Gets the pageId from the invoked CYA action.
|
|
10
9
|
* @param {object} action The invoked action.
|
|
@@ -14,6 +13,5 @@ exports.default = void 0;
|
|
|
14
13
|
var getPageId = function getPageId(action, pageId) {
|
|
15
14
|
return (action === null || action === void 0 ? void 0 : action.page) || pageId;
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
var _default = getPageId;
|
|
19
17
|
exports.default = _default;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _getPageId = _interopRequireDefault(require("./getPageId"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('components', function () {
|
|
9
8
|
describe('FormRenderer', function () {
|
|
10
9
|
describe('handlers', function () {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _ = _interopRequireDefault(require("."));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('components', function () {
|
|
9
8
|
describe('FormRenderer', function () {
|
|
10
9
|
describe('handlers', function () {
|
|
@@ -15,13 +14,10 @@ describe('components', function () {
|
|
|
15
14
|
pageId: CURRENT_PAGE_ID
|
|
16
15
|
};
|
|
17
16
|
var ON_CHANGE_CALLS = [];
|
|
18
|
-
|
|
19
17
|
var ON_CHANGE = function ON_CHANGE(pageId) {
|
|
20
18
|
ON_CHANGE_CALLS.push(pageId);
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
_.default.cyaAction(PAGE, CURRENT_PAGE_ID, ON_CHANGE);
|
|
24
|
-
|
|
25
21
|
expect(ON_CHANGE_CALLS.length).toEqual(0);
|
|
26
22
|
});
|
|
27
23
|
it('should call the onChange method when the page has changed', function () {
|
|
@@ -31,13 +27,10 @@ describe('components', function () {
|
|
|
31
27
|
pageId: NEW_PAGE_ID
|
|
32
28
|
};
|
|
33
29
|
var ON_CHANGE_CALLS = [];
|
|
34
|
-
|
|
35
30
|
var ON_CHANGE = function ON_CHANGE(pageId) {
|
|
36
31
|
ON_CHANGE_CALLS.push(pageId);
|
|
37
32
|
};
|
|
38
|
-
|
|
39
33
|
_.default.cyaAction(PAGE, CURRENT_PAGE_ID, ON_CHANGE);
|
|
40
|
-
|
|
41
34
|
expect(ON_CHANGE_CALLS.length).toEqual(1);
|
|
42
35
|
expect(ON_CHANGE_CALLS[0]).toEqual(NEW_PAGE_ID);
|
|
43
36
|
});
|
|
@@ -49,13 +42,10 @@ describe('components', function () {
|
|
|
49
42
|
page: CURRENT_PAGE_ID
|
|
50
43
|
};
|
|
51
44
|
var ON_NAVIGATE_CALLS = [];
|
|
52
|
-
|
|
53
45
|
var ON_NAVIGATE = function ON_NAVIGATE(pageId) {
|
|
54
46
|
ON_NAVIGATE_CALLS.push(pageId);
|
|
55
47
|
};
|
|
56
|
-
|
|
57
48
|
_.default.navigate(ACTION, CURRENT_PAGE_ID, ON_NAVIGATE);
|
|
58
|
-
|
|
59
49
|
expect(ON_NAVIGATE_CALLS.length).toEqual(0);
|
|
60
50
|
});
|
|
61
51
|
it('should call the onNavigate method when the page has changed', function () {
|
|
@@ -65,13 +55,10 @@ describe('components', function () {
|
|
|
65
55
|
page: NEW_PAGE_ID
|
|
66
56
|
};
|
|
67
57
|
var ON_NAVIGATE_CALLS = [];
|
|
68
|
-
|
|
69
58
|
var ON_NAVIGATE = function ON_NAVIGATE(pageId) {
|
|
70
59
|
ON_NAVIGATE_CALLS.push(pageId);
|
|
71
60
|
};
|
|
72
|
-
|
|
73
61
|
_.default.navigate(ACTION, CURRENT_PAGE_ID, ON_NAVIGATE);
|
|
74
|
-
|
|
75
62
|
expect(ON_NAVIGATE_CALLS.length).toEqual(1);
|
|
76
63
|
expect(ON_NAVIGATE_CALLS[0]).toEqual(NEW_PAGE_ID);
|
|
77
64
|
});
|
|
@@ -79,15 +66,11 @@ describe('components', function () {
|
|
|
79
66
|
describe('submissionError', function () {
|
|
80
67
|
it('should call the onError method with the same errors', function () {
|
|
81
68
|
var ON_ERROR_CALLS = [];
|
|
82
|
-
|
|
83
69
|
var ON_ERROR = function ON_ERROR(errors) {
|
|
84
70
|
ON_ERROR_CALLS.push(errors);
|
|
85
71
|
};
|
|
86
|
-
|
|
87
72
|
var ERRORS = ['alpha', 'bravo', 'charlie'];
|
|
88
|
-
|
|
89
73
|
_.default.submissionError(ERRORS, ON_ERROR);
|
|
90
|
-
|
|
91
74
|
expect(ON_ERROR_CALLS.length).toEqual(1);
|
|
92
75
|
expect(ON_ERROR_CALLS[0]).toEqual(ERRORS);
|
|
93
76
|
});
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.handlers = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _cyaAction = _interopRequireDefault(require("./cyaAction"));
|
|
9
|
-
|
|
10
8
|
var _navigate = _interopRequireDefault(require("./navigate"));
|
|
11
|
-
|
|
12
9
|
var _submissionError = _interopRequireDefault(require("./submissionError"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
var handlers = {
|
|
17
12
|
cyaAction: _cyaAction.default,
|
|
18
13
|
navigate: _navigate.default,
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getPageId = _interopRequireDefault(require("./getPageId"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Gets the pageId from the invoked page action and calls onNavigate if it is
|
|
14
11
|
* different to the currentPageId.
|
|
@@ -18,11 +15,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
*/
|
|
19
16
|
var navigate = function navigate(action, currentPageId, onNavigate, state) {
|
|
20
17
|
var pageId = (0, _getPageId.default)(action, currentPageId);
|
|
21
|
-
|
|
22
18
|
if (pageId !== currentPageId) {
|
|
23
19
|
onNavigate(pageId, state);
|
|
24
20
|
}
|
|
25
21
|
};
|
|
26
|
-
|
|
27
22
|
var _default = navigate;
|
|
28
23
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Formats back-end errors and invokes an onError handler.
|
|
10
9
|
* @param {Array} errors The errors returned by the backend when submitting.
|
|
@@ -15,6 +14,5 @@ var submissionError = function submissionError(errors, onError) {
|
|
|
15
14
|
// what the errors will look like.
|
|
16
15
|
onError(errors);
|
|
17
16
|
};
|
|
18
|
-
|
|
19
17
|
var _default = submissionError;
|
|
20
18
|
exports.default = _default;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Assesses whether the action can proceed when navigating, submitting, etc.
|
|
10
9
|
* Presently, this will validate a page when submitting and, only if the page is
|
|
@@ -18,9 +17,7 @@ var canActionProceed = function canActionProceed(action, page, pageValidator) {
|
|
|
18
17
|
if (action.validate) {
|
|
19
18
|
return pageValidator(page).length === 0;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
return true;
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
var _default = canActionProceed;
|
|
26
23
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Validate = _interopRequireDefault(require("../../../utils/Validate"));
|
|
4
|
-
|
|
5
4
|
var _canActionProceed = _interopRequireDefault(require("./canActionProceed"));
|
|
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.canActionProceed', function () {
|
|
11
9
|
it('should return true when the action does not require validation', function () {
|
|
12
10
|
var ACTION = {
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Assesses whether the CYA screen can submit.
|
|
10
9
|
* Presently, this will validate all of the form pages and, only if all pages are
|
|
@@ -16,6 +15,5 @@ exports.default = void 0;
|
|
|
16
15
|
var canCYASubmit = function canCYASubmit(pages, pagesValidator) {
|
|
17
16
|
return pagesValidator(pages).length === 0;
|
|
18
17
|
};
|
|
19
|
-
|
|
20
18
|
var _default = canCYASubmit;
|
|
21
19
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Validate = _interopRequireDefault(require("../../../utils/Validate"));
|
|
4
|
-
|
|
5
4
|
var _canCYASubmit = _interopRequireDefault(require("./canCYASubmit"));
|
|
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.canCYASubmit', function () {
|
|
11
9
|
var ALPHA = {
|
|
12
10
|
id: 'a',
|
|
@@ -20,13 +18,11 @@ describe('components.FormRenderer.helpers.canCYASubmit', function () {
|
|
|
20
18
|
label: 'Charlie',
|
|
21
19
|
required: true
|
|
22
20
|
};
|
|
23
|
-
|
|
24
21
|
var validatePages = function validatePages(pages) {
|
|
25
22
|
return pages.flatMap(function (page) {
|
|
26
23
|
return _Validate.default.page(page);
|
|
27
24
|
});
|
|
28
25
|
};
|
|
29
|
-
|
|
30
26
|
it('should return true when all pages are valid', function () {
|
|
31
27
|
var PAGE_1 = {
|
|
32
28
|
components: [ALPHA],
|
|
@@ -4,27 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
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
8
|
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; }
|
|
9
|
-
|
|
10
9
|
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; }
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
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); }
|
|
14
13
|
var parentComponents = ['radios'];
|
|
15
|
-
|
|
16
14
|
var cleanHiddenNestedData = function cleanHiddenNestedData(patch, page) {
|
|
17
15
|
page.components.forEach(function (component) {
|
|
18
16
|
if (!parentComponents.includes(component.type)) {
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
var idsToDelete = getIdsToDelete(component, patch[component.id]);
|
|
23
20
|
idsToDelete.forEach(function (id) {
|
|
24
21
|
delete patch[id];
|
|
25
22
|
});
|
|
26
23
|
});
|
|
27
|
-
|
|
28
24
|
if (page.collection && patch[page.collection.name]) {
|
|
29
25
|
patch[page.collection.name] = patch[page.collection.name].map(function (entry) {
|
|
30
26
|
return cleanHiddenNestedData(entry, _objectSpread(_objectSpread({}, page), {}, {
|
|
@@ -32,13 +28,10 @@ var cleanHiddenNestedData = function cleanHiddenNestedData(patch, page) {
|
|
|
32
28
|
}));
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
return patch;
|
|
37
32
|
};
|
|
38
|
-
|
|
39
33
|
function getIdsToDelete(component, selectedValue) {
|
|
40
34
|
var _component$data, _component$data$optio;
|
|
41
|
-
|
|
42
35
|
var idsToDelete = [];
|
|
43
36
|
component === null || component === void 0 ? void 0 : (_component$data = component.data) === null || _component$data === void 0 ? void 0 : (_component$data$optio = _component$data.options) === null || _component$data$optio === void 0 ? void 0 : _component$data$optio.forEach(function (option) {
|
|
44
37
|
if (option.value !== selectedValue && option.nested) {
|
|
@@ -49,6 +42,5 @@ function getIdsToDelete(component, selectedValue) {
|
|
|
49
42
|
});
|
|
50
43
|
return idsToDelete;
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
var _default = cleanHiddenNestedData;
|
|
54
46
|
exports.default = _default;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cleanHiddenNestedData = _interopRequireDefault(require("./cleanHiddenNestedData"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
5
|
// Local imports
|
|
6
|
+
|
|
8
7
|
describe('components', function () {
|
|
9
8
|
describe('FormRenderer', function () {
|
|
10
9
|
describe('helpers', function () {
|
|
@@ -4,13 +4,9 @@ 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
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
// Local imports
|
|
15
11
|
|
|
16
12
|
/**
|
|
@@ -27,23 +23,18 @@ var getCYA = function getCYA(pageId, pages, hub) {
|
|
|
27
23
|
} else if (pageId === _models.FormPages.CYA) {
|
|
28
24
|
return {};
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
var currentPage = pages === null || pages === void 0 ? void 0 : pages.find(function (p) {
|
|
32
27
|
return p.id === pageId;
|
|
33
28
|
});
|
|
34
|
-
|
|
35
29
|
if ((currentPage === null || currentPage === void 0 ? void 0 : currentPage.type) === _models.FormPages.PARTIAL_CYA) {
|
|
36
30
|
var pageWithConditionals = _utils.default.FormPage.applyConditionalProperties(currentPage);
|
|
37
|
-
|
|
38
31
|
return {
|
|
39
32
|
title: pageWithConditionals.title,
|
|
40
33
|
hideChangeActions: pageWithConditionals.hideChangeActions,
|
|
41
34
|
hideGroupActions: pageWithConditionals.hideGroupActions
|
|
42
35
|
};
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
return undefined;
|
|
46
38
|
};
|
|
47
|
-
|
|
48
39
|
var _default = getCYA;
|
|
49
40
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
|
-
|
|
5
4
|
var _getCYA = _interopRequireDefault(require("./getCYA"));
|
|
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,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _getCYA = _interopRequireDefault(require("./getCYA"));
|
|
9
|
-
|
|
10
8
|
var _getPage = _interopRequireDefault(require("./getPage"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
// Local imports
|
|
15
11
|
|
|
16
12
|
/**
|
|
@@ -27,6 +23,5 @@ var getFormState = function getFormState(pageId, pages, hub) {
|
|
|
27
23
|
page: (0, _getPage.default)(pageId, pages, hub)
|
|
28
24
|
};
|
|
29
25
|
};
|
|
30
|
-
|
|
31
26
|
var _default = getFormState;
|
|
32
27
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
|
-
|
|
5
4
|
var _getFormState = _interopRequireDefault(require("./getFormState"));
|
|
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,34 +4,24 @@ 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 _FormPage = _interopRequireDefault(require("../../../utils/FormPage"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
var getNextHubPageId = function getNextHubPageId(action, currentPageId, pages, formData, formType) {
|
|
15
11
|
var _action$pages;
|
|
16
|
-
|
|
17
12
|
if (!currentPageId && formType === _models.FormTypes.FORM_WITH_TASK) {
|
|
18
13
|
var _formData$formStatus;
|
|
19
|
-
|
|
20
14
|
if (formData !== null && formData !== void 0 && (_formData$formStatus = formData.formStatus) !== null && _formData$formStatus !== void 0 && _formData$formStatus.taskPage) {
|
|
21
15
|
var currentPage = pages.find(function (page) {
|
|
22
16
|
return page.id === formData.formStatus.taskPage;
|
|
23
17
|
});
|
|
24
|
-
|
|
25
18
|
if ((currentPage === null || currentPage === void 0 ? void 0 : currentPage.type) === 'pre-task-list') {
|
|
26
19
|
return currentPage.id;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
return _models.FormPages.HUB;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
return pages.length > 0 ? pages[0].id : undefined;
|
|
33
24
|
}
|
|
34
|
-
|
|
35
25
|
var nextPage = undefined;
|
|
36
26
|
action === null || action === void 0 ? void 0 : (_action$pages = action.pages) === null || _action$pages === void 0 ? void 0 : _action$pages.forEach(function (page) {
|
|
37
27
|
if (_FormPage.default.show({
|
|
@@ -39,37 +29,29 @@ var getNextHubPageId = function getNextHubPageId(action, currentPageId, pages, f
|
|
|
39
29
|
}, formData)) {
|
|
40
30
|
nextPage = page.pageId;
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
;
|
|
44
33
|
});
|
|
45
34
|
return nextPage || (action === null || action === void 0 ? void 0 : action.page) || _models.FormPages.HUB;
|
|
46
35
|
};
|
|
47
|
-
|
|
48
36
|
var getNextCYAPageId = function getNextCYAPageId(pages, currentPageId, formData) {
|
|
49
37
|
return getNextWizardPageId(pages, currentPageId, formData) || _models.FormPages.CYA;
|
|
50
38
|
};
|
|
51
|
-
|
|
52
39
|
var getNextWizardPageId = function getNextWizardPageId(pages, currentPageId, formData) {
|
|
53
40
|
var _page;
|
|
54
|
-
|
|
55
41
|
var nextIndex = pages.findIndex(function (p) {
|
|
56
42
|
return p.id === currentPageId;
|
|
57
43
|
}) + 1;
|
|
58
44
|
var page = pages[nextIndex];
|
|
59
|
-
|
|
60
45
|
while (page && !_FormPage.default.show(page, formData)) {
|
|
61
46
|
nextIndex++;
|
|
62
47
|
page = pages[nextIndex];
|
|
63
48
|
}
|
|
64
|
-
|
|
65
49
|
return ((_page = page) === null || _page === void 0 ? void 0 : _page.id) || undefined;
|
|
66
50
|
};
|
|
67
|
-
|
|
68
51
|
var getNextFormPageId = function getNextFormPageId(pages) {
|
|
69
52
|
// A form has a single page... so always return that id.
|
|
70
53
|
return pages.length > 0 ? pages[0].id : undefined;
|
|
71
54
|
};
|
|
72
|
-
|
|
73
55
|
var getNextPageId = function getNextPageId(formType, pages, currentPageId, action, formData) {
|
|
74
56
|
if (action) {
|
|
75
57
|
if (action.type === _models.PageAction.TYPES.NAVIGATE) {
|
|
@@ -77,30 +59,23 @@ var getNextPageId = function getNextPageId(formType, pages, currentPageId, actio
|
|
|
77
59
|
return p.id === action.page;
|
|
78
60
|
}) ? action.page : undefined;
|
|
79
61
|
}
|
|
80
|
-
|
|
81
62
|
if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
|
|
82
63
|
return formType === _models.FormTypes.HUB ? _models.FormPages.HUB : undefined;
|
|
83
64
|
}
|
|
84
65
|
}
|
|
85
|
-
|
|
86
66
|
switch (formType) {
|
|
87
67
|
case _models.FormTypes.HUB:
|
|
88
68
|
return getNextHubPageId(action);
|
|
89
|
-
|
|
90
69
|
case _models.FormTypes.CYA:
|
|
91
70
|
return getNextCYAPageId(pages, currentPageId, formData);
|
|
92
|
-
|
|
93
71
|
case _models.FormTypes.FORM_WITH_TASK:
|
|
94
72
|
case _models.FormTypes.TASK:
|
|
95
73
|
return getNextHubPageId(action, currentPageId, pages, formData, formType);
|
|
96
|
-
|
|
97
74
|
case _models.FormTypes.WIZARD:
|
|
98
75
|
return getNextWizardPageId(pages, currentPageId, formData);
|
|
99
|
-
|
|
100
76
|
default:
|
|
101
77
|
return getNextFormPageId(pages);
|
|
102
78
|
}
|
|
103
79
|
};
|
|
104
|
-
|
|
105
80
|
var _default = getNextPageId;
|
|
106
81
|
exports.default = _default;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _models = require("../../../models");
|
|
4
|
-
|
|
5
4
|
var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
|
|
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 () {
|
|
@@ -48,7 +46,6 @@ describe('components', function () {
|
|
|
48
46
|
var FORM_DATA = {
|
|
49
47
|
radios: OPTIONS[0].value
|
|
50
48
|
}; // 'romeo'
|
|
51
|
-
|
|
52
49
|
var PAGES = [{
|
|
53
50
|
id: 'alpha'
|
|
54
51
|
}, {
|
|
@@ -4,9 +4,7 @@ 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
|
// Local imports
|
|
11
9
|
|
|
12
10
|
/**
|
|
@@ -21,14 +19,11 @@ var getPage = function getPage(pageId, pages, hub) {
|
|
|
21
19
|
if (pageId === _models.FormPages.HUB) {
|
|
22
20
|
return hub === _models.HubFormats.CYA || hub === _models.HubFormats.TASK ? undefined : hub;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
return pages.find(function (p) {
|
|
26
23
|
return p.id === pageId;
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
return undefined;
|
|
31
27
|
};
|
|
32
|
-
|
|
33
28
|
var _default = getPage;
|
|
34
29
|
exports.default = _default;
|
|
@@ -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 () {
|