diff --git a/ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts b/ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts
index 0b074c2205..1311176976 100644
--- a/ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts
+++ b/ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts
@@ -22,6 +22,7 @@ import {
NG_VALUE_ACCESSOR,
ValidationErrors,
Validator,
+ Validators,
} from '@angular/forms';
import {
EntityKeyValueType,
@@ -135,10 +136,24 @@ export class FilterPredicateComponent implements ControlValueAccessor, Validator
writeValue(predicate: KeyFilterPredicateInfo): void {
this.type = predicate.keyFilterPredicate.type;
+ this.updateValidators();
this.filterPredicateFormGroup.patchValue(predicate.keyFilterPredicate, {emitEvent: false});
this.filterPredicateFormGroup.get('userInfo').patchValue(predicate.userInfo, {emitEvent: false});
}
+ private updateValidators(): void {
+ const operationCtrl = this.filterPredicateFormGroup.get('operation');
+ const predicatesCtrl = this.filterPredicateFormGroup.get('predicates');
+ operationCtrl.setValidators([Validators.required]);
+ if (this.type === FilterPredicateType.COMPLEX) {
+ predicatesCtrl.setValidators([Validators.required]);
+ } else {
+ predicatesCtrl.clearValidators();
+ }
+ operationCtrl.updateValueAndValidity({emitEvent: false});
+ predicatesCtrl.updateValueAndValidity({emitEvent: false});
+ }
+
private updateModel() {
let predicate: KeyFilterPredicateInfo = null;
if (this.filterPredicateFormGroup.valid) {
diff --git a/ui-ngx/src/app/modules/home/components/filter/filters-dialog.component.html b/ui-ngx/src/app/modules/home/components/filter/filters-dialog.component.html
index 8fdbaab47e..452045d164 100644
--- a/ui-ngx/src/app/modules/home/components/filter/filters-dialog.component.html
+++ b/ui-ngx/src/app/modules/home/components/filter/filters-dialog.component.html
@@ -41,7 +41,7 @@
-
+