Files
psp_panel/src/app/shared/localEnum/select.component.ts
T

31 lines
982 B
TypeScript
Raw Normal View History

2026-03-29 18:07:10 +03:30
import { UikitFieldComponent } from '@/uikit';
import { Component, computed, Input } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { Select } from 'primeng/select';
import { Observable } from 'rxjs';
import { AbstractSelectComponent, ISelectItem } from '../abstractClasses';
import { LOCAL_ENUMS } from './constants';
import { TLocalEnum } from './models';
@Component({
selector: 'app-enum-select',
templateUrl: './select.component.html',
imports: [UikitFieldComponent, Select, ReactiveFormsModule],
})
export class EnumSelectComponent extends AbstractSelectComponent<ISelectItem, ISelectItem[]> {
@Input() type!: TLocalEnum;
@Input() customLabel?: string;
label = computed(() => this.customLabel ?? LOCAL_ENUMS[this.type].label);
override getDataService() {
return new Observable<ISelectItem[]>((observer) => {
return observer.next(LOCAL_ENUMS[this.type].items);
});
}
ngOnInit() {
this.getData();
}
}