diff --git a/projects/schema-form/package.json b/projects/schema-form/package.json index 9ad3feff..41772ccc 100644 --- a/projects/schema-form/package.json +++ b/projects/schema-form/package.json @@ -1,6 +1,6 @@ { "name": "ngx-schema-form", - "version": "2.4.9", + "version": "2.4.10", "repository": { "type": "git", "url": "git+https://github.com/guillotinaweb/ngx-schema-form" diff --git a/projects/schema-form/src/lib/model/formproperty.ts b/projects/schema-form/src/lib/model/formproperty.ts index e31d5681..c33e8a7e 100644 --- a/projects/schema-form/src/lib/model/formproperty.ts +++ b/projects/schema-form/src/lib/model/formproperty.ts @@ -226,6 +226,11 @@ export abstract class FormProperty { /** * Making use of the expression compiler for the visibleIf condition + * @param sourceProperty The source property where the `visibleIf` condition is set. + * @param targetProperty The target property what provided the `value` on which the `visibleIf` condition will be checked against. May be `null` or `undefined` + * @param dependencyPath The dependency path of the `targetProperty` + * @param value The value of the `targetProperty` to check the `visiblityIf` condintion against. May be `null` or `undefined` + * @param expression The value or expression to check against the `value` for the `targetProperty`. May be `null` or `undefined` */ private __evaluateVisibilityIf( sourceProperty: FormProperty, @@ -259,8 +264,8 @@ export abstract class FormProperty { return valid } catch (error) { this.logger.error('Error processing "VisibileIf" expression for path: ', dependencyPath, - `source - ${sourceProperty._canonicalPath}: `, sourceProperty, - `target - ${targetProperty._canonicalPath}: `, targetProperty, + `source - ${(sourceProperty ? sourceProperty._canonicalPath : '')}: `, sourceProperty, + `target - ${(targetProperty ? targetProperty._canonicalPath : '')}: `, targetProperty, 'value:', value, 'expression: ', expression, 'error: ', error) @@ -272,7 +277,6 @@ export abstract class FormProperty { * @returns `true` if any visibility binding of type `oneOf` or `allOf` has been processed. Otherwise `false`. */ private __bindVisibility_oneOf_or_allOf(): boolean { - /** /** *
      *     "oneOf":[{
@@ -309,7 +313,7 @@ export abstract class FormProperty {
                         for (const item of this.schema.visibleIf.oneOf) {
                           for (const depPath of Object.keys(item)) {
                             const prop = this.searchProperty(depPath);
-                            const propVal = prop.value;
+                            const propVal = prop ? prop.value : null;
                             if (this.__evaluateVisibilityIf(this, prop, dependencyPath, propVal, item[depPath])) {
                               return true
                             }
@@ -323,7 +327,7 @@ export abstract class FormProperty {
                         for (const item of this.schema.visibleIf.allOf) {
                           for (const depPath of Object.keys(item)) {
                             const prop = this.searchProperty(depPath);
-                            const propVal = prop.value;
+                            const propVal = prop ? prop.value : null;
                             if (!this.__evaluateVisibilityIf(this, prop, dependencyPath, propVal, item[depPath])) {
                               return false;
                             }