[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;
if (hasValue(this.dynamicMatchers) || true) {
subscriptions.push(valueChanges.subscribe(() => {
// Iterate each matcher
subscriptions.push(valueChanges.subscribe(() => {
// Iterate each matcher
if (hasValue(this.dynamicMatchers)) {
this.dynamicMatchers.forEach((matcher) => {
// Find the relation
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 (relation !== undefined) {
const hasMatch = this.matchesCondition(relation, matcher);
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.hiddenUpdates = new BehaviorSubject<boolean>(this.hidden);
// Asynchronously hide parent if this is hidden
setTimeout((hidden: boolean) => {
this.hidden = hidden;
const parentModel = this.getRootParent(this);
if (parentModel && isNotUndefined(parentModel.hidden)) {
parentModel.hidden = hidden;
}
}, 0);
// This was a subscription, then an async setTimeout, but it seems unnecessary
const parentModel = this.getRootParent(this);
if (parentModel && isNotUndefined(parentModel.hidden)) {
parentModel.hidden = this.hidden;
}
}
private getRootParent(model: any): DynamicFormControlModel {