@@ -21,6 +21,7 @@ import { LoadActivities } from './../../../activities-management/store/activity-
2121import { allActivities } from 'src/app/modules/activities-management/store/activity-management.selectors' ;
2222import { head } from 'lodash' ;
2323import { Entry } from '../../../shared/models' ;
24+ import { EntryState } from '../../store/entry.reducer' ;
2425
2526@Component ( {
2627 selector : 'app-project-list-hover' ,
@@ -41,10 +42,11 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
4142 recentProjectsSubscription : Subscription ;
4243 activeEntrySubscription : Subscription ;
4344 loadActivitiesSubscription : Subscription ;
44- canMarkEntryAsWIP = true ;
45+ canMarkEntryAsWIP : boolean ;
4546
4647 constructor (
4748 private formBuilder : FormBuilder ,
49+ private storeEntry : Store < EntryState > ,
4850 private store : Store < ProjectState > ,
4951 private actionsSubject$ : ActionsSubject ,
5052 private toastrService : ToastrService
@@ -116,11 +118,13 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
116118 technologies : [ ] ,
117119 activity_id : head ( this . activities ) . id ,
118120 } ;
119- this . store . pipe ( select ( getTimeEntriesDataSource ) ) . subscribe ( ds => {
120- this . canMarkEntryAsWIP = ! this . isThereAnEntryRunning ( ds . data ) ;
121+ this . canMarkEntryAsWIP = true ;
122+ this . storeEntry . pipe ( select ( getTimeEntriesDataSource ) ) . subscribe ( ds => {
123+ this . canMarkEntryAsWIP = this . isThereAnEntryRunning ( ds . data ) ;
121124 } ) ;
122- if ( this . canMarkEntryAsWIP !== false ) {
123- this . toastrService . error ( 'There is an existing time entry running please check your time entries' )
125+
126+ if ( this . canMarkEntryAsWIP === true ) {
127+ this . toastrService . error ( 'There is an existing time entry running please check your time entries' ) ;
124128 return ;
125129 }
126130 this . store . dispatch ( new entryActions . ClockIn ( entry ) ) ;
@@ -134,7 +138,9 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
134138 const runningEntry : Entry = entries . find ( entry => entry . running === true ) ;
135139 return runningEntry ;
136140 }
141+
137142 isThereAnEntryRunning ( entries : Entry [ ] ) {
143+ console . log ( ! ! this . getEntryRunning ( entries ) )
138144 return ! ! this . getEntryRunning ( entries ) ;
139145 }
140146
0 commit comments