From 83955f0e675c7a6702173446b5ea04dc71b783be Mon Sep 17 00:00:00 2001 From: Guido Quezada Date: Fri, 11 Dec 2020 11:32:32 -0500 Subject: [PATCH] TT-00 fix: refactor condition --- .../time-entries/pages/time-entries.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/modules/time-entries/pages/time-entries.component.ts b/src/app/modules/time-entries/pages/time-entries.component.ts index 95d8270b6..5116b3254 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.ts @@ -105,12 +105,12 @@ export class TimeEntriesComponent implements OnInit, OnDestroy { const endDateAsLocalDate = new Date(event.entry.end_date); const activeEntryAsLocalDate = new Date(this.activeTimeEntry.start_date); const isEditingEntryEqualToActiveEntry = this.entryId === this.activeTimeEntry.id; - const isStartDateLowerThanActiveEntry = startDateAsLocalDate < activeEntryAsLocalDate; - const isEndDateLowerThanActiveEntry = endDateAsLocalDate < activeEntryAsLocalDate; - if(isEditingEntryEqualToActiveEntry && (isStartDateLowerThanActiveEntry || isEndDateLowerThanActiveEntry)){ - this.doSave(event); - } else { + const isStartDateGreaterThanActiveEntry = startDateAsLocalDate > activeEntryAsLocalDate; + const isEndDateGreaterThanActiveEntry = endDateAsLocalDate > activeEntryAsLocalDate; + if(!isEditingEntryEqualToActiveEntry && (isStartDateGreaterThanActiveEntry || isEndDateGreaterThanActiveEntry)){ this.toastrService.error('You are on the clock and this entry overlaps it, try with earlier times.'); + } else { + this.doSave(event); } } else { this.doSave(event);