Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix: TTA-206 clock in succesfull after clock out
  • Loading branch information
Abigail Cabascango committed Nov 11, 2022
commit 2f2cff2937109d13ec42eadb29e0bd0257f6be3c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import { ActionsSubject, select, Store } from '@ngrx/store';
import { ToastrService } from 'ngx-toastr';
import { Observable, Subscription } from 'rxjs';
import Utils from '../../../time-clock/utils/utils';
import { delay, filter, map } from 'rxjs/operators';
import { Project } from 'src/app/modules/shared/models';
import * as actions from '../../../customer-management/components/projects/components/store/project.actions';
Expand Down Expand Up @@ -118,9 +119,9 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
technologies: [],
activity_id: head(this.activities).id,
};
this.canMarkEntryAsWIP = true;
this.canMarkEntryAsWIP = false;
this.storeEntry.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
this.canMarkEntryAsWIP = this.isThereAnEntryRunning(ds.data);
this.canMarkEntryAsWIP = Utils.isThereAnEntryRunning(ds.data);
});

if (this.canMarkEntryAsWIP){
Expand All @@ -134,16 +135,7 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
}, 2000);
}

private getEntryRunning(entries: Entry[]) {
const runningEntry: Entry = entries.find(entry => entry.running === true);
return runningEntry;
}

private isThereAnEntryRunning(entries: Entry[]) {
return !!this.getEntryRunning(entries);
}

private updateProject(selectedProject) {
updateProject(selectedProject) {
const entry = { id: this.activeEntry.id, project_id: selectedProject };
this.store.dispatch(new entryActions.UpdateEntryRunning(entry));
this.store.dispatch(new entryActions.LoadActiveEntry());
Expand Down
12 changes: 12 additions & 0 deletions src/app/modules/time-clock/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Entry } from '../../shared/models';

export default class Utils {
getEntryRunning(entries: Entry[]) {
const runningEntry: Entry = entries.find(entry => entry.running === true);
return runningEntry;
}

isThereAnEntryRunning(entries: Entry[]) {
return !!this.getEntryRunning(entries);
}
}