Skip to content

Commit 8b5a239

Browse files
committed
fix: TT-117 two-entries-in-progress-bug
1 parent d198dd0 commit 8b5a239

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ describe('TimeEntriesComponent', () => {
245245
description: 'description',
246246
technologies: [],
247247
uri: 'abc',
248-
}, shouldRestartEntry: false
248+
}, shouldRestartEntry: true
249249
};
250250
component.entryId = 'new-entry';
251251
spyOn(injectedToastrService, 'error');
@@ -265,7 +265,7 @@ describe('TimeEntriesComponent', () => {
265265
description: 'description',
266266
technologies: [],
267267
uri: 'abc',
268-
}, shouldRestartEntry: false
268+
}, shouldRestartEntry: true
269269
};
270270
component.entryId = 'new-entry';
271271
spyOn(injectedToastrService, 'error');
@@ -361,7 +361,7 @@ describe('TimeEntriesComponent', () => {
361361
technologies: [],
362362
uri: 'abc',
363363

364-
}, shouldRestartEntry: true
364+
}, shouldRestartEntry: false
365365
};
366366
component.entryId = '123';
367367
spyOn(store, 'dispatch');

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,18 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
104104
}
105105

106106
saveEntry(event: SaveEntryEvent): void {
107-
if (this.activeTimeEntry) {
107+
108+
if (this.activeTimeEntry && this.entryId === this.activeTimeEntry.id) {
108109
const startDateAsLocalDate = new Date(event.entry.start_date);
109110
const endDateAsLocalDate = new Date(event.entry.end_date);
110111
const activeEntryAsLocalDate = new Date(this.activeTimeEntry.start_date);
111-
const isEditingEntryEqualToActiveEntry = this.entryId === this.activeTimeEntry.id;
112112
const isStartDateGreaterThanActiveEntry = startDateAsLocalDate > activeEntryAsLocalDate;
113113
const isEndDateGreaterThanActiveEntry = endDateAsLocalDate > activeEntryAsLocalDate;
114114
const isTimeEntryOverlapping = isStartDateGreaterThanActiveEntry || isEndDateGreaterThanActiveEntry;
115-
if (!isEditingEntryEqualToActiveEntry && isTimeEntryOverlapping) {
115+
116+
if (isTimeEntryOverlapping) {
116117
this.toastrService.error('You are on the clock and this entry overlaps it, try with earlier times.');
117-
} else {
118+
} else {
118119
this.doSave(event);
119120
}
120121
} else {
@@ -145,7 +146,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
145146
if (this.entryId) {
146147
event.entry.id = this.entryId;
147148
this.store.dispatch(new entryActions.UpdateEntry(event.entry));
148-
if (event.shouldRestartEntry) {
149+
if (event.shouldRestartEntry && this.entryId === this.activeTimeEntry.id) {
149150
this.store.dispatch(new entryActions.RestartEntry(event.entry));
150151
}
151152
} else {

0 commit comments

Comments
 (0)