Skip to content
Closed
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
Next Next commit
fix: TTA-206 implement functions tu validate a running activity in cl…
…ockin function
  • Loading branch information
Abigail Cabascango committed Oct 31, 2022
commit 4a692454413105c378ce30a1ed42ab1ab3d4d03c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ import { Project } from 'src/app/modules/shared/models';
import * as actions from '../../../customer-management/components/projects/components/store/project.actions';
import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer';
import * as entryActions from '../../store/entry.actions';

import {
getIsLoading,
getProjects,
getRecentProjects,
} from './../../../customer-management/components/projects/components/store/project.selectors';
import { EntryActionTypes } from './../../store/entry.actions';
import { getActiveTimeEntry } from './../../store/entry.selectors';
import { getActiveTimeEntry, getTimeEntriesDataSource } from './../../store/entry.selectors';
import { Activity, } from '../../../shared/models';
import { LoadActivities } from './../../../activities-management/store/activity-management.actions';
import { allActivities } from 'src/app/modules/activities-management/store/activity-management.selectors';
import { head } from 'lodash';
import { Entry } from '../../../shared/models';

@Component({
selector: 'app-project-list-hover',
Expand All @@ -39,6 +41,7 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
recentProjectsSubscription: Subscription;
activeEntrySubscription: Subscription;
loadActivitiesSubscription: Subscription;
canMarkEntryAsWIP = true;

constructor(
private formBuilder: FormBuilder,
Expand Down Expand Up @@ -113,13 +116,24 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
technologies: [],
activity_id: head(this.activities).id,
};
this.store.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
this.canMarkEntryAsWIP = !this.isThereAnEntryRunning(ds.data);
});
this.store.dispatch(new entryActions.ClockIn(entry));
this.projectsForm.setValue({ project_id: `${customerName} - ${name}` });
setTimeout(() => {
this.store.dispatch(new actions.LoadRecentProjects());
}, 2000);
}

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

updateProject(selectedProject) {
const entry = { id: this.activeEntry.id, project_id: selectedProject };
this.store.dispatch(new entryActions.UpdateEntryRunning(entry));
Expand Down