diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition.component.ts index fe0670b4e7..ef539af6f5 100644 --- a/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition.component.ts +++ b/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition.component.ts @@ -142,10 +142,9 @@ export class CfAlarmRuleConditionComponent implements ControlValueAccessor, Vali } ngOnChanges(changes: SimpleChanges) { - if (changes.arguments) { - if (changes.arguments && !changes.arguments.firstChange) { - this.recalculateArgumentValidity(); - } + if (changes.arguments && !changes.arguments.firstChange) { + this.recalculateArgumentValidity(); + this.onValidatorChange(); } } diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule.component.ts index 706477f72a..d9b7f868ac 100644 --- a/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule.component.ts +++ b/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule.component.ts @@ -84,6 +84,7 @@ export class CfAlarmRuleComponent implements ControlValueAccessor, OnInit, Valid }); private propagateChange = (v: any) => { }; + private onValidatorChange = () => { }; constructor(private dialog: MatDialog, private fb: FormBuilder, @@ -97,12 +98,21 @@ export class CfAlarmRuleComponent implements ControlValueAccessor, OnInit, Valid registerOnTouched(fn: any): void { } + registerOnValidatorChange(fn: () => void): void { + this.onValidatorChange = fn; + } + ngOnInit() { this.alarmRuleFormGroup.valueChanges.pipe( takeUntilDestroyed(this.destroyRef) ).subscribe(() => { this.updateModel(); }); + this.alarmRuleFormGroup.statusChanges.pipe( + takeUntilDestroyed(this.destroyRef) + ).subscribe(() => { + this.onValidatorChange(); + }); } setDisabledState(isDisabled: boolean): void { diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/create-cf-alarm-rules.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/create-cf-alarm-rules.component.ts index 4d9884f851..345e155ae1 100644 --- a/ui-ngx/src/app/modules/home/components/alarm-rules/create-cf-alarm-rules.component.ts +++ b/ui-ngx/src/app/modules/home/components/alarm-rules/create-cf-alarm-rules.component.ts @@ -77,12 +77,16 @@ export class CreateCfAlarmRulesComponent implements ControlValueAccessor, Valida private usedSeverities: AlarmSeverity[] = []; private propagateChange = (v: any) => { }; + private onValidatorChange = () => { }; constructor(private fb: FormBuilder, private destroyRef: DestroyRef) { this.createAlarmRulesFormGroup.valueChanges.pipe( takeUntilDestroyed(this.destroyRef) ).subscribe(() => this.updateModel()); + this.createAlarmRulesFormGroup.statusChanges.pipe( + takeUntilDestroyed(this.destroyRef) + ).subscribe(() => this.onValidatorChange()); } registerOnChange(fn: any): void { @@ -92,6 +96,10 @@ export class CreateCfAlarmRulesComponent implements ControlValueAccessor, Valida registerOnTouched(fn: any): void { } + registerOnValidatorChange(fn: () => void): void { + this.onValidatorChange = fn; + } + createAlarmRulesFormArray(): UntypedFormArray { return this.createAlarmRulesFormGroup.get('createAlarmRules') as UntypedFormArray; }