Browse Source

Merge pull request #12931 from ChantsovaEkaterina/bug/fixed-date-time-period-validation

Fixed date time period start/end values check
pull/12936/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
7ae15fb349
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 20
      ui-ngx/src/app/shared/components/time/datetime-period.component.ts

20
ui-ngx/src/app/shared/components/time/datetime-period.component.ts

@ -160,22 +160,26 @@ export class DatetimePeriodComponent implements ControlValueAccessor {
private onStartDateChange(startDate: Date) { private onStartDateChange(startDate: Date) {
if (startDate) { if (startDate) {
if (startDate.getTime() > this.maxStartTs) { let startDateTs = startDate.getTime();
this.dateTimePeriodFormGroup.get('startDate').patchValue(new Date(this.maxStartTs), { emitEvent: false }); if (startDateTs > this.maxStartTs) {
startDateTs = this.maxStartTs;
this.dateTimePeriodFormGroup.get('startDate').patchValue(new Date(startDateTs), { emitEvent: false });
} }
if (startDate.getTime() > this.maxStartDateTs) { if (startDateTs > this.maxStartDateTs) {
this.dateTimePeriodFormGroup.get('endDate').patchValue(new Date(startDate.getTime() + this.timeShiftMs), { emitEvent: false }); this.dateTimePeriodFormGroup.get('endDate').patchValue(new Date(startDateTs + this.timeShiftMs), { emitEvent: false });
} }
} }
} }
private onEndDateChange(endDate: Date) { private onEndDateChange(endDate: Date) {
if (endDate) { if (endDate) {
if (endDate.getTime() > this.maxEndTs) { let endDateTs = endDate.getTime();
this.dateTimePeriodFormGroup.get('endDate').patchValue(new Date(this.maxEndTs), { emitEvent: false }); if (endDateTs > this.maxEndTs) {
endDateTs = this.maxEndTs;
this.dateTimePeriodFormGroup.get('endDate').patchValue(new Date(endDateTs), { emitEvent: false });
} }
if (endDate.getTime() < this.minEndDateTs) { if (endDateTs < this.minEndDateTs) {
this.dateTimePeriodFormGroup.get('startDate').patchValue(new Date(endDate.getTime() - this.timeShiftMs), { emitEvent: false }); this.dateTimePeriodFormGroup.get('startDate').patchValue(new Date(endDateTs - this.timeShiftMs), { emitEvent: false });
} }
} }
} }

Loading…
Cancel
Save