@oneblink/sdk-core
Advanced tools
Comparing version 0.4.1-beta.4 to 0.4.1-beta.5
@@ -7,2 +7,3 @@ "use strict"; | ||
const evaluateConditionalOptionsPredicate_1 = __importDefault(require("./evaluateConditionalOptionsPredicate")); | ||
const __1 = require(".."); | ||
const conditionallyShowElement_1 = __importDefault(require("./conditionallyShowElement")); | ||
@@ -52,7 +53,4 @@ const handleAttributePredicate = (predicate, model, predicateElement) => { | ||
} | ||
if (predicateElement.type !== 'compliance' && | ||
predicateElement.type !== 'select' && | ||
predicateElement.type !== 'autocomplete' && | ||
predicateElement.type !== 'checkboxes' && | ||
predicateElement.type !== 'radio') { | ||
const optionsPredicateElement = __1.typeCastService.formElements.toOptionsElement(predicateElement); | ||
if (!optionsPredicateElement) { | ||
return false; | ||
@@ -64,11 +62,11 @@ } | ||
// options have not been fetched yet. | ||
if (!Array.isArray(predicateElement.options)) { | ||
return predicateElement.optionsType !== 'DYNAMIC'; | ||
if (!Array.isArray(optionsPredicateElement.options)) { | ||
return optionsPredicateElement.optionsType !== 'DYNAMIC'; | ||
} | ||
const everyOptionIsShowing = predicate.optionIds.every((id) => { | ||
var _a; | ||
const predicateOption = (_a = predicateElement.options) === null || _a === void 0 ? void 0 : _a.find((o) => o.id === id); | ||
const predicateOption = (_a = optionsPredicateElement.options) === null || _a === void 0 ? void 0 : _a.find((o) => o.id === id); | ||
if (!predicateOption) | ||
return false; | ||
return conditionallyShowOption({ model: formElementsCtrl.model, flattenedElements: [] }, predicateElement, predicateOption, elementsEvaluated); | ||
return conditionallyShowOption({ model: formElementsCtrl.model, flattenedElements: [] }, optionsPredicateElement, predicateOption, elementsEvaluated); | ||
}); | ||
@@ -79,3 +77,3 @@ if (!everyOptionIsShowing) { | ||
// Check to see if the model has one of the valid values to show the element | ||
return handleAttributePredicate(predicate, formElementsCtrl.model, predicateElement); | ||
return handleAttributePredicate(predicate, formElementsCtrl.model, optionsPredicateElement); | ||
}; | ||
@@ -82,0 +80,0 @@ const isAttributeFilterValid = (formElementsCtrl, predicate, elementsEvaluated) => { |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const __1 = require(".."); | ||
const typeCastService_1 = require("../typeCastService"); | ||
@@ -86,7 +87,4 @@ const evaluateConditionalOptionsPredicate_1 = __importDefault(require("./evaluateConditionalOptionsPredicate")); | ||
default: { | ||
if (predicateElement.type !== 'select' && | ||
predicateElement.type !== 'autocomplete' && | ||
predicateElement.type !== 'radio' && | ||
predicateElement.type !== 'checkboxes' && | ||
predicateElement.type !== 'compliance') { | ||
const optionsPredicateElement = __1.typeCastService.formElements.toOptionsElement(predicateElement); | ||
if (!optionsPredicateElement) { | ||
return undefined; | ||
@@ -98,4 +96,4 @@ } | ||
// options have not been fetched yet. | ||
if (!Array.isArray(predicateElement.options)) { | ||
return predicateElement.optionsType !== 'DYNAMIC' | ||
if (!Array.isArray(optionsPredicateElement.options)) { | ||
return optionsPredicateElement.optionsType !== 'DYNAMIC' | ||
? predicateElement | ||
@@ -108,3 +106,3 @@ : undefined; | ||
predicateValue, | ||
predicateElement, | ||
predicateElement: optionsPredicateElement, | ||
}) | ||
@@ -111,0 +109,0 @@ ? predicateElement |
@@ -10,2 +10,3 @@ "use strict"; | ||
const conditionallyShowOption_1 = __importDefault(require("./conditionallyShowOption")); | ||
const __1 = require(".."); | ||
const handleConditionallyShowElement = (formElementsCtrl, element, errorCallback) => { | ||
@@ -116,15 +117,8 @@ try { | ||
if (!formElementConditionallyShown.isHidden) { | ||
switch (element.type) { | ||
case 'compliance': | ||
case 'autocomplete': | ||
case 'radio': | ||
case 'checkboxes': | ||
case 'select': { | ||
if (element.conditionallyShowOptions && | ||
Array.isArray(element.options)) { | ||
formElementConditionallyShown.options = | ||
element.options.filter((option) => handleConditionallyShowOption(formElementsCtrl, element, option, errorCallback)); | ||
} | ||
break; | ||
} | ||
const optionsElement = __1.typeCastService.formElements.toOptionsElement(element); | ||
if (optionsElement && | ||
optionsElement.conditionallyShowOptions && | ||
Array.isArray(optionsElement.options)) { | ||
formElementConditionallyShown.options = | ||
optionsElement.options.filter((option) => handleConditionallyShowOption(formElementsCtrl, optionsElement, option, errorCallback)); | ||
} | ||
@@ -131,0 +125,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.flattenFormElements = exports.parseFormElementOptionsSet = exports.findFormElement = exports.forEachFormElementWithOptions = exports.forEachFormElement = void 0; | ||
const _1 = require("."); | ||
/** | ||
@@ -46,8 +47,5 @@ * Iterate over all form elements, also iterating over nested form element (e.g. | ||
findFormElement(elements, (formElement, parentElements) => { | ||
if (formElement.type === 'select' || | ||
formElement.type === 'autocomplete' || | ||
formElement.type === 'checkboxes' || | ||
formElement.type === 'radio' || | ||
formElement.type === 'compliance') { | ||
forEach(formElement, parentElements); | ||
const optionsFormElement = _1.typeCastService.formElements.toOptionsElement(formElement); | ||
if (optionsFormElement) { | ||
forEach(optionsFormElement, parentElements); | ||
} | ||
@@ -54,0 +52,0 @@ return false; |
@@ -6,2 +6,3 @@ "use strict"; | ||
switch (e.type) { | ||
case 'freshdeskDependentField': | ||
case 'select': | ||
@@ -43,2 +44,3 @@ case 'compliance': | ||
switch (e.type) { | ||
case 'freshdeskDependentField': | ||
case 'boolean': | ||
@@ -45,0 +47,0 @@ case 'checkboxes': |
{ | ||
"name": "@oneblink/sdk-core", | ||
"description": "OneBlink SDK for JavaScript (works in Browsers and NodeJS)", | ||
"version": "0.4.1-beta.4", | ||
"version": "0.4.1-beta.5", | ||
"author": "OneBlink <developers@oneblink.io> (https://oneblink.io)", | ||
@@ -6,0 +6,0 @@ "bugs": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
226855
2554