31 lines
982 B
TypeScript
31 lines
982 B
TypeScript
|
|
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();
|
||
|
|
}
|
||
|
|
}
|