Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
TT-00 fix: refactor condition
  • Loading branch information
Guido Quezada committed Dec 11, 2020
commit 83955f0e675c7a6702173446b5ea04dc71b783be
10 changes: 5 additions & 5 deletions src/app/modules/time-entries/pages/time-entries.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down