62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
import {Component} from '@angular/core';
|
|
import {MatFormFieldModule} from "@angular/material/form-field";
|
|
import {MatDatepicker, MatDatepickerInput, MatDatepickerToggle} from "@angular/material/datepicker";
|
|
import {FormsModule} from "@angular/forms";
|
|
import {ConfigurationCardComponent} from "@component/admin/configuration-card/configuration-card.component";
|
|
import {MatInput} from "@angular/material/input";
|
|
import {addDays} from "@progress/kendo-date-math";
|
|
import {ScheduleService} from "@api/v1/configuration/schedule.service";
|
|
import {DateOnly} from "@model/dateOnly";
|
|
import {MatDialog} from "@angular/material/dialog";
|
|
import {
|
|
ConfirmDeleteScheduleDialogComponent
|
|
} from "@component/admin/confirm-delete-schedule-dialog/confirm-delete-schedule-dialog.component";
|
|
import {Observable, switchMap} from "rxjs";
|
|
|
|
@Component({
|
|
selector: 'app-term-start-date',
|
|
imports: [
|
|
MatFormFieldModule,
|
|
MatDatepickerToggle,
|
|
FormsModule,
|
|
MatDatepickerInput,
|
|
MatDatepicker,
|
|
ConfigurationCardComponent,
|
|
MatInput
|
|
],
|
|
templateUrl: './term-start-date.component.html',
|
|
providers: [ScheduleService]
|
|
})
|
|
export class TermStartDateComponent {
|
|
protected startDate: Date = new Date();
|
|
protected startDateBefore: Date = new Date();
|
|
|
|
constructor(private api: ScheduleService, private dialog: MatDialog) {
|
|
this.api.getStartTerm().subscribe(data => {
|
|
this.startDate = data.date;
|
|
this.startDateBefore = this.startDate;
|
|
console.log(this.startDate == this.startDateBefore);
|
|
});
|
|
}
|
|
|
|
protected saveFunction() {
|
|
return () => {
|
|
const dialogRef = this.dialog.open(ConfirmDeleteScheduleDialogComponent, {
|
|
data: {startDate: this.startDate}
|
|
});
|
|
|
|
return dialogRef.afterClosed().pipe(switchMap(result => {
|
|
return this.api.postStartTerm(new DateOnly(this.startDate), result);
|
|
}));
|
|
};
|
|
}
|
|
|
|
protected onSave(data: Observable<any>): void {
|
|
data.subscribe(_ => {
|
|
this.startDateBefore = this.startDate;
|
|
});
|
|
}
|
|
|
|
protected ValidMinDate = addDays(new Date(), -180);
|
|
}
|