Fix dateRange cell

master
Max 4 years ago
parent 2f7b2459a5
commit 5c5bd4b642

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

@ -47,7 +47,7 @@ export class DateRangeCellComponent implements OnInit {
this.dateRangeGroup.controls['to'].markAsTouched();
if (this.editable) {
setTimeout(()=>this.checkIfDateRangeIsValid());
setTimeout(() => this.checkIfDateRangeIsValid());
}
}
@ -64,11 +64,11 @@ export class DateRangeCellComponent implements OnInit {
}
checkIfDateRangeIsValid() {
if (this.required && this.from == null) {
if (this.required && !this.from) {
this.setRangeError(true);
return;
}
if (this.to == null || this.from == null) {
if (!this.to || !this.from) {
this.setRangeError(false);
return;
}
@ -97,4 +97,9 @@ export class DateRangeCellComponent implements OnInit {
}
return new Date(date).toLocaleDateString();
}
stringToDate(dateString: string): Date {
if (!dateString) return null;
return new Date(dateString) || null;
}
}

Loading…
Cancel
Save