Skip to content

Commit

Permalink
Merge pull request #371 from guillotinaweb/fix_370_2.4.x
Browse files Browse the repository at this point in the history
Fix 370 2.4.x
  • Loading branch information
ebrehault committed Dec 3, 2020
2 parents 8dfe433 + cb0c749 commit 95b5053
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 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"
Expand Down
14 changes: 9 additions & 5 deletions projects/schema-form/src/lib/model/formproperty.ts
Expand Up @@ -226,6 +226,11 @@ export abstract class FormProperty {

/**
* Making use of the expression compiler for the <code>visibleIf</code> 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,
Expand Down Expand Up @@ -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 : '<no-sourceProperty>')}: `, sourceProperty,
`target - ${(targetProperty ? targetProperty._canonicalPath : '<no-targetProperty>')}: `, targetProperty,
'value:', value,
'expression: ', expression,
'error: ', error)
Expand All @@ -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 {
/**
/**
* <pre>
* "oneOf":[{
Expand Down Expand Up @@ -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
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 95b5053

Please sign in to comment.