2026-05-23 18:09:44 +03:30
|
|
|
import { AbstractDialog } from '@/shared/abstractClasses/abstract-dialog';
|
2026-05-23 20:25:35 +03:30
|
|
|
import { UikitLabelComponent } from '@/uikit';
|
2026-05-23 18:09:44 +03:30
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
|
import { Component, computed, EventEmitter, Input, Output, signal } from '@angular/core';
|
|
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
|
|
import { ButtonDirective, ButtonSeverity } from 'primeng/button';
|
|
|
|
|
import { SharedLightBottomsheetComponent } from '../dialog/light-bottomsheet.component';
|
|
|
|
|
import { FormFooterActionsComponent } from '../formFooterActions/form-footer-actions.component';
|
|
|
|
|
|
|
|
|
|
type SeasonKey = 0 | 1 | 2 | 3;
|
|
|
|
|
|
|
|
|
|
interface SeasonItem {
|
|
|
|
|
key: SeasonKey;
|
|
|
|
|
label: string;
|
|
|
|
|
severity: ButtonSeverity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'season-picker-dialog',
|
|
|
|
|
templateUrl: './season-picker-dialog.component.html',
|
|
|
|
|
imports: [
|
|
|
|
|
CommonModule,
|
|
|
|
|
FormsModule,
|
|
|
|
|
SharedLightBottomsheetComponent,
|
|
|
|
|
FormFooterActionsComponent,
|
|
|
|
|
ButtonDirective,
|
2026-05-23 20:25:35 +03:30
|
|
|
UikitLabelComponent,
|
2026-05-23 18:09:44 +03:30
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
export class SeasonPickerDialogComponent extends AbstractDialog {
|
|
|
|
|
@Input() years: { year: number; value: number }[] = [];
|
|
|
|
|
@Input() selectedYear!: number;
|
|
|
|
|
@Input() selectedSeason!: SeasonKey;
|
|
|
|
|
@Input() seasons: SeasonItem[] = [];
|
|
|
|
|
|
|
|
|
|
@Output() submit = new EventEmitter<{ year: number; season: number }>();
|
|
|
|
|
|
|
|
|
|
selectedYearDraft = signal(this.selectedYear);
|
|
|
|
|
selectedSeasonDraft = signal(this.selectedSeason);
|
|
|
|
|
|
|
|
|
|
isSeasonDisabled = computed(() => this.selectedYear >= this.selectedYearDraft());
|
|
|
|
|
|
|
|
|
|
onSubmit(): void {
|
|
|
|
|
this.submit.emit({
|
|
|
|
|
year: this.selectedYearDraft(),
|
|
|
|
|
season: this.selectedSeasonDraft(),
|
|
|
|
|
});
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnChanges() {
|
|
|
|
|
this.selectedYearDraft.set(this.selectedYear);
|
|
|
|
|
this.selectedSeasonDraft.set(this.selectedSeason);
|
|
|
|
|
}
|
|
|
|
|
}
|