create apiEnum components
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { UikitFieldComponent } from '@/uikit';
|
||||
import { Component, computed, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Select } from 'primeng/select';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AbstractSelectComponent } from '../abstractClasses';
|
||||
import { apiEnumTranslates } from './constants';
|
||||
import { IApiEnumResponse, TEnumApi } from './models';
|
||||
import { EnumsService } from './services';
|
||||
|
||||
@Component({
|
||||
selector: 'app-enum-select',
|
||||
templateUrl: './select.component.html',
|
||||
imports: [UikitFieldComponent, Select, ReactiveFormsModule],
|
||||
})
|
||||
export class EnumSelectComponent extends AbstractSelectComponent<string, IApiEnumResponse[]> {
|
||||
@Input() type!: TEnumApi;
|
||||
@Input() customLabel?: string;
|
||||
|
||||
private readonly service = inject(EnumsService);
|
||||
|
||||
label = computed(() => this.customLabel ?? apiEnumTranslates[this.type]);
|
||||
|
||||
override getDataService(): Observable<IApiEnumResponse[]> {
|
||||
return this.service.getAll(this.type);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.getData();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user