@@ -105,16 +105,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
105
105
const isStartDateGreaterThanActiveEntry = startDateAsLocalDate > activeEntryAsLocalDate ;
106
106
const isEndDateGreaterThanActiveEntry = endDateAsLocalDate > activeEntryAsLocalDate ;
107
107
const isTimeEntryOverlapping = isStartDateGreaterThanActiveEntry || isEndDateGreaterThanActiveEntry ;
108
-
109
- if ( isEditingEntryEqualToActiveEntry ) {
110
- this . store . pipe ( select ( getTimeEntriesDataSource ) ) . subscribe ( ds => {
111
- const overlappingEntry = ds . data . find ( ( item ) => {
112
- const itemEndDate = new Date ( item . end_date ) ;
113
- return startDateAsLocalDate < itemEndDate ;
114
- } ) ;
115
- this . isActiveEntryOverlapping = overlappingEntry ? true : false ;
116
- } ) ;
117
- }
108
+ this . checkIfActiveEntryOverlapping ( isEditingEntryEqualToActiveEntry , startDateAsLocalDate ) ;
118
109
if ( ! isEditingEntryEqualToActiveEntry && isTimeEntryOverlapping || this . isActiveEntryOverlapping ) {
119
110
const message = this . isActiveEntryOverlapping ? 'try another "Time in"' : 'try with earlier times' ;
120
111
this . toastrService . error ( `You are on the clock and this entry overlaps it, ${ message } .` ) ;
@@ -183,4 +174,16 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
183
174
resetDraggablePosition ( event : any ) : void {
184
175
event . source . _dragRef . reset ( ) ;
185
176
}
177
+
178
+ checkIfActiveEntryOverlapping ( isEditingEntryEqualToActiveEntry : boolean , startDateAsLocalDate : Date ) {
179
+ if ( isEditingEntryEqualToActiveEntry ) {
180
+ this . store . pipe ( select ( getTimeEntriesDataSource ) ) . subscribe ( ds => {
181
+ const overlappingEntry = ds . data . find ( ( item ) => {
182
+ const itemEndDate = new Date ( item . end_date ) ;
183
+ return startDateAsLocalDate < itemEndDate ;
184
+ } ) ;
185
+ this . isActiveEntryOverlapping = overlappingEntry ? true : false ;
186
+ } ) ;
187
+ }
188
+ }
186
189
}
0 commit comments