Fix dateRange cell

master
Max 4 years ago
parent 2f7b2459a5
commit 5c5bd4b642

@ -9,7 +9,7 @@
matInput matInput
placeholder="Startdatum" placeholder="Startdatum"
[matDatepicker]="fromPicker" [matDatepicker]="fromPicker"
[value]="from" [value]="stringToDate(from)"
disabled disabled
formControlName="from" formControlName="from"
(dateChange)="startDateChange($event)" (dateChange)="startDateChange($event)"
@ -33,7 +33,7 @@
matInput matInput
placeholder="Enddatum" placeholder="Enddatum"
[matDatepicker]="toPicker" [matDatepicker]="toPicker"
[value]="to" [value]="stringToDate(to)"
disabled disabled
formControlName="to" formControlName="to"
(dateChange)="endDateChange($event)" (dateChange)="endDateChange($event)"

@ -64,11 +64,11 @@ export class DateRangeCellComponent implements OnInit {
} }
checkIfDateRangeIsValid() { checkIfDateRangeIsValid() {
if (this.required && this.from == null) { if (this.required && !this.from) {
this.setRangeError(true); this.setRangeError(true);
return; return;
} }
if (this.to == null || this.from == null) { if (!this.to || !this.from) {
this.setRangeError(false); this.setRangeError(false);
return; return;
} }
@ -97,4 +97,9 @@ export class DateRangeCellComponent implements OnInit {
} }
return new Date(date).toLocaleDateString(); return new Date(date).toLocaleDateString();
} }
stringToDate(dateString: string): Date {
if (!dateString) return null;
return new Date(dateString) || null;
}
} }

Loading…
Cancel
Save