[TLC-254] Service tests - small fixes

This commit is contained in:
Kim Shepherd
2022-04-22 15:59:19 +12:00
parent d7afaf9cb8
commit bc62764345
2 changed files with 10 additions and 15 deletions

View File

@@ -199,22 +199,20 @@ export class DsDynamicTypeBindRelationService {
); );
// Build up the subscriptions to watch for changes; // Build up the subscriptions to watch for changes;
if (hasValue(this.dynamicMatchers) || true) { subscriptions.push(valueChanges.subscribe(() => {
subscriptions.push(valueChanges.subscribe(() => { // Iterate each matcher
// Iterate each matcher if (hasValue(this.dynamicMatchers)) {
this.dynamicMatchers.forEach((matcher) => { this.dynamicMatchers.forEach((matcher) => {
// Find the relation // Find the relation
const relation = this.dynamicFormRelationService.findRelationByMatcher((model as any).typeBindRelations, matcher); const relation = this.dynamicFormRelationService.findRelationByMatcher((model as any).typeBindRelations, matcher);
// If the relation is defined, get matchesCondition result and pass it to the onChange event listener // If the relation is defined, get matchesCondition result and pass it to the onChange event listener
if (relation !== undefined) { if (relation !== undefined) {
const hasMatch = this.matchesCondition(relation, matcher); const hasMatch = this.matchesCondition(relation, matcher);
matcher.onChange(hasMatch, model, control, this.injector); matcher.onChange(hasMatch, model, control, this.injector);
} }
}); });
})); }
} }));
} }
}); });

View File

@@ -38,14 +38,11 @@ export class DynamicDsDatePickerModel extends DynamicDateControlModel {
this.typeBindRelations = config.typeBindRelations ? config.typeBindRelations : []; this.typeBindRelations = config.typeBindRelations ? config.typeBindRelations : [];
this.hiddenUpdates = new BehaviorSubject<boolean>(this.hidden); this.hiddenUpdates = new BehaviorSubject<boolean>(this.hidden);
// Asynchronously hide parent if this is hidden // This was a subscription, then an async setTimeout, but it seems unnecessary
setTimeout((hidden: boolean) => { const parentModel = this.getRootParent(this);
this.hidden = hidden; if (parentModel && isNotUndefined(parentModel.hidden)) {
const parentModel = this.getRootParent(this); parentModel.hidden = this.hidden;
if (parentModel && isNotUndefined(parentModel.hidden)) { }
parentModel.hidden = hidden;
}
}, 0);
} }
private getRootParent(model: any): DynamicFormControlModel { private getRootParent(model: any): DynamicFormControlModel {