Skip to content

Commit

Permalink
Merge pull request #452 from KBroichhausen/fix-wildcard
Browse files Browse the repository at this point in the history
Fixed bug with wildcards introduced by version 2.8.2
  • Loading branch information
ebrehault authored Dec 23, 2022
2 parents 821c107 + 55fcf71 commit c2ede28
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions projects/schema-form/src/lib/model/formproperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ export abstract class FormProperty {
return this.__bindConditionalVisiblityChain(visibleIfOf, containsOneOf, containsAllOf);
} else {
// it's a dependency path
return this.__handleDependencyPath(visbilityElement);
const observables = this.__handleDependencyPath(visbilityElement);
return combineLatest(observables, (...values: boolean[]) => values.indexOf(true) !== -1);
}
}

Expand All @@ -380,9 +381,10 @@ export abstract class FormProperty {
* @param dependencyElement An element / object which contains neither a field with oneOf or allOf as name. Handled as dependency path in json
* @returns An oberservable boolean containing the evaluation of the statement, where the statement is the value of the dependency path field
*/
private __handleDependencyPath(dependencyElement: any): Observable<boolean> {
private __handleDependencyPath(dependencyElement: any): Array<Observable<any>> {
const dependencyPath = Object.keys(dependencyElement)[0];

const propertiesBinding = [];
const properties = this.findProperties(this, dependencyPath);
if ((properties || []).length) {
for (const property of properties) {
Expand All @@ -393,14 +395,15 @@ export abstract class FormProperty {
valueCheck = property.valueChanges.pipe(map(_chk));
const visibilityCheck = property._visibilityChanges;
const and = combineLatest([valueCheck, visibilityCheck], (v1, v2) => v1 && v2);
return and;
propertiesBinding.push(and);
}
}
return propertiesBinding;
} else {
this.logger.warn("Can't find property " + dependencyPath + " for visibility check of " + this.path);
this.registerMissingVisibilityBinding(dependencyPath, this);
}
return of(false);
return [of(false)];
}

// A field is visible if AT LEAST ONE of the properties it depends on is visible AND has a value in the list
Expand Down

0 comments on commit c2ede28

Please sign in to comment.