diff --git a/projects/schema-form/package.json b/projects/schema-form/package.json index d6abf123..a742c667 100644 --- a/projects/schema-form/package.json +++ b/projects/schema-form/package.json @@ -1,6 +1,6 @@ { "name": "ngx-schema-form", - "version": "2.5.8", + "version": "2.5.9", "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 489ebeaf..d47bc653 100644 --- a/projects/schema-form/src/lib/model/formproperty.ts +++ b/projects/schema-form/src/lib/model/formproperty.ts @@ -227,6 +227,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, @@ -260,8 +265,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) @@ -309,7 +314,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 +328,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; }