2026-03-10 20:23:56 +03:30
|
|
|
import { UikitFieldComponent } from '@/uikit';
|
2026-05-13 13:44:33 +03:30
|
|
|
import { DOCUMENT } from '@angular/common';
|
|
|
|
|
import { Component, Inject, computed, inject, Input } from '@angular/core';
|
2026-03-10 20:23:56 +03:30
|
|
|
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[]> {
|
2026-04-13 13:22:40 +03:30
|
|
|
@Input({ required: true }) type!: TEnumApi;
|
2026-04-27 21:53:11 +03:30
|
|
|
@Input() name?: string;
|
2026-03-10 20:23:56 +03:30
|
|
|
@Input() customLabel?: string;
|
|
|
|
|
|
|
|
|
|
private readonly service = inject(EnumsService);
|
2026-05-13 13:44:33 +03:30
|
|
|
constructor(@Inject(DOCUMENT) private readonly document: Document) {
|
|
|
|
|
super();
|
|
|
|
|
}
|
2026-03-10 20:23:56 +03:30
|
|
|
|
|
|
|
|
label = computed(() => this.customLabel ?? apiEnumTranslates[this.type]);
|
|
|
|
|
|
|
|
|
|
override getDataService(): Observable<IApiEnumResponse[]> {
|
|
|
|
|
return this.service.getAll(this.type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.getData();
|
|
|
|
|
}
|
2026-05-13 13:44:33 +03:30
|
|
|
|
|
|
|
|
overlayOptions() {
|
|
|
|
|
return {
|
|
|
|
|
autoZIndex: true,
|
|
|
|
|
baseZIndex: this.overlayBaseZIndex(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
overlayBaseZIndex() {
|
|
|
|
|
const drawers = Array.from(this.document.body.querySelectorAll('.p-drawer,[data-pc-name="drawer"]')) as HTMLElement[];
|
|
|
|
|
const zIndexes = drawers
|
|
|
|
|
.map((drawer) => Number.parseInt(drawer.style.zIndex || '0', 10))
|
|
|
|
|
.filter((zIndex) => Number.isFinite(zIndex) && zIndex > 0);
|
|
|
|
|
|
|
|
|
|
return zIndexes.length ? Math.max(...zIndexes) + 2 : 1000;
|
|
|
|
|
}
|
2026-03-10 20:23:56 +03:30
|
|
|
}
|