Browse Source

UI: Liquid level widget minor improvement

pull/9456/head
Dmitriymush 3 years ago
parent
commit
23e0df065e
  1. 13
      ui-ngx/src/app/shared/components/unit-input.component.ts

13
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;

Loading…
Cancel
Save