Skip to content

Commit

Permalink
feat(sharedTaskList): make movement between done & undone work
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Mar 14, 2020
1 parent 5e1874c commit 9a9c94e
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions src/app/features/tasks/store/task-related-model.effects.ts
@@ -1,20 +1,20 @@
import {Injectable} from '@angular/core';
import {Actions, Effect, ofType} from '@ngrx/effects';
import {MoveToOtherProject, TaskActionTypes} from './task.actions';
import {select, Store} from '@ngrx/store';
import {tap, withLatestFrom} from 'rxjs/operators';
import {MoveToOtherProject, TaskActionTypes, UpdateTask} from './task.actions';
import {Store} from '@ngrx/store';
import {filter, map, tap} from 'rxjs/operators';
import {PersistenceService} from '../../../core/persistence/persistence.service';
import {selectCurrentProjectId} from '../../project/store/project.reducer';
import {Task, TaskWithSubTasks} from '../task.model';
import {ReminderService} from '../../reminder/reminder.service';
import {Router} from '@angular/router';
import {ProjectService} from '../../project/project.service';
import {selectTaskFeatureState} from './task.selectors';
import {selectAttachmentByIds} from '../../attachment/store/attachment.reducer';
import {moveTaskInTodayList} from '../../work-context/store/work-context-meta.actions';


@Injectable()
export class TaskRelatedModelEffects {
// EFFECTS ===> EXTERNAL
// ---------------------
@Effect({dispatch: false})
moveToArchive$: any = this._actions$.pipe(
ofType(
Expand All @@ -41,6 +41,39 @@ export class TaskRelatedModelEffects {
tap(this._removeFromArchive.bind(this))
);

// EXTERNAL ===> TASKS
// -------------------
@Effect()
moveTaskToUnDone$: any = this._actions$.pipe(
ofType(
moveTaskInTodayList,
),
filter(({src, target}) => src === 'DONE' && target === 'UNDONE'),
map(({taskId}) => new UpdateTask({
task: {
id: taskId,
changes: {
isDone: false,
}
}
}))
);

@Effect()
moveTaskToDone$: any = this._actions$.pipe(
ofType(
moveTaskInTodayList,
),
filter(({src, target}) => src === 'UNDONE' && target === 'DONE'),
map(({taskId}) => new UpdateTask({
task: {
id: taskId,
changes: {
isDone: true,
}
}
}))
);

constructor(
private _actions$: Actions,
Expand Down

0 comments on commit 9a9c94e

Please sign in to comment.