From 23e0df065ed62fabddffc690e2e6f4e24c91dbb8 Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Fri, 20 Oct 2023 15:16:51 +0300 Subject: [PATCH] UI: Liquid level widget minor improvement --- .../app/shared/components/unit-input.component.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ui-ngx/src/app/shared/components/unit-input.component.ts b/ui-ngx/src/app/shared/components/unit-input.component.ts index 35ec683cc6..533df34cc9 100644 --- a/ui-ngx/src/app/shared/components/unit-input.component.ts +++ b/ui-ngx/src/app/shared/components/unit-input.component.ts @@ -23,8 +23,7 @@ import { OnInit, ViewChild, ViewEncapsulation, - Injector, - AfterViewInit + Injector } from '@angular/core'; import { ControlValueAccessor, @@ -52,7 +51,7 @@ import { ResourcesService } from '@core/services/resources.service'; ], encapsulation: ViewEncapsulation.None }) -export class UnitInputComponent implements ControlValueAccessor, OnInit, AfterViewInit { +export class UnitInputComponent implements ControlValueAccessor, OnInit { @HostBinding('style.display') get hostDisplay() {return 'flex';}; @@ -88,7 +87,7 @@ export class UnitInputComponent implements ControlValueAccessor, OnInit, AfterVi } ngOnInit() { - this.unitsFormControl = this.fb.control('', []); + this.unitsFormControl = this.fb.control('', this.required ? [Validators.required] : []); this.filteredUnits = this.unitsFormControl.valueChanges .pipe( tap(value => { @@ -99,12 +98,6 @@ export class UnitInputComponent implements ControlValueAccessor, OnInit, AfterVi ); } - ngAfterViewInit() { - if (this.required) { - this.unitsFormControl.setValidators([Validators.required]); - } - } - writeValue(symbol?: string): void { this.searchText = ''; this.modelValue = symbol;