mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Merged PR 895: #2254 UI Datepicker ausgewählter Tag
#2254 UI Datepicker ausgewählter Tag Related work items: #2254
This commit is contained in:
committed by
Lorenz Hilpert
parent
02f8f747e1
commit
7b49fbc85c
@@ -90,11 +90,15 @@ export class DateAdapter {
|
||||
return result;
|
||||
}
|
||||
|
||||
parseDate(date: string) {
|
||||
return new Date(date);
|
||||
}
|
||||
|
||||
today(): Date {
|
||||
return new Date(new Date().toJSON().slice(0, 10).replace(/-/g, '/'));
|
||||
}
|
||||
|
||||
isValid(date: Date): boolean {
|
||||
isValid(date: any): date is Date {
|
||||
return date instanceof Date && !isNaN(date.getDate());
|
||||
}
|
||||
|
||||
|
||||
@@ -87,16 +87,20 @@ export abstract class Datepicker {
|
||||
this.setDisplayed(this.dateAdapter.addCalendarMonths(this.displayed, -1));
|
||||
}
|
||||
|
||||
setSelected(date: Date, { emit: emitChanged }: SetPropertyOptions = { emit: true }) {
|
||||
if (!this.dateAdapter.isValid(date)) {
|
||||
setSelected(date: Date | string, { emit: emitChanged }: SetPropertyOptions = { emit: true }) {
|
||||
let _date: Date;
|
||||
if (this.dateAdapter.isValid(date)) {
|
||||
_date = date;
|
||||
} else if (typeof date === 'string') {
|
||||
_date = this.dateAdapter.parseDate(date);
|
||||
} else {
|
||||
this.selectedSubject.next(undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dateAdapter.compareDate(this.selected, date) !== 0) {
|
||||
this.selectedSubject.next(date);
|
||||
if (this.dateAdapter.compareDate(this.selected, _date) !== 0) {
|
||||
this.selectedSubject.next(_date);
|
||||
if (emitChanged) {
|
||||
this.selectedChange.emit(date);
|
||||
this.selectedChange.emit(_date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user