mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
make sp2 work again step2
This commit is contained in:
parent
12bcf98832
commit
151ba4ca90
5 changed files with 130 additions and 94 deletions
|
|
@ -23,6 +23,8 @@
|
|||
"@angular/platform-browser-dynamic": "^6.0.0",
|
||||
"@angular/router": "^6.0.0",
|
||||
"@angular/upgrade": "^6.0.1",
|
||||
"@ngrx/effects": "^5.2.0",
|
||||
"@ngrx/store": "^5.2.0",
|
||||
"angular": "^1.7.0",
|
||||
"core-js": "^2.5.4",
|
||||
"hammerjs": "^2.0.8",
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ import { DurationToStringPipe } from './duration/duration-to-string.pipe';
|
|||
import { DurationFromStringPipe } from './duration/duration-from-string.pipe';
|
||||
import { KeysPipe } from './helper/keys.pipe';
|
||||
import { ToArrayPipe } from './helper/to-array.pipe';
|
||||
import { StoreModule } from '@ngrx/store';
|
||||
import { TaskReducer } from './tasks/task.reducer';
|
||||
import { CurrentTaskReducer } from './tasks/current-task.reducer';
|
||||
import { metaReducers } from './meta.reducer';
|
||||
import { EffectsModule } from '@ngrx/effects';
|
||||
import { TaskEffects } from './tasks/task.effects';
|
||||
|
||||
export const appRoutes: Routes = [
|
||||
{path: 'work-view', component: WorkViewComponent},
|
||||
|
|
@ -93,6 +99,16 @@ export const appRoutes: Routes = [
|
|||
MatDatepickerModule,
|
||||
MatNativeDateModule,
|
||||
|
||||
// store stuff
|
||||
StoreModule.forRoot({
|
||||
TaskReducer,
|
||||
CurrentTaskReducer
|
||||
},
|
||||
{metaReducers}
|
||||
),
|
||||
EffectsModule.forRoot([TaskEffects]),
|
||||
|
||||
|
||||
// other
|
||||
DragulaModule,
|
||||
// MarkdownToHtmlModule.forRoot(),
|
||||
|
|
|
|||
|
|
@ -8,8 +8,19 @@ import { Injectable } from '@angular/core';
|
|||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/operator/withLatestFrom';
|
||||
import { SYNC } from "./task.actions";
|
||||
import { ADD_TASK } from './task.actions';
|
||||
import { UPDATE_TASK } from './task.actions';
|
||||
import { DELETE_TASK } from './task.actions';
|
||||
import { SET_TASK_DONE } from './task.actions';
|
||||
import { SET_TASK_UNDONE } from './task.actions';
|
||||
import { ADD_SUB_TASK } from './task.actions';
|
||||
import { SET_CURRENT_TASK } from './task.actions';
|
||||
import { UNSET_CURRENT_TASK } from './task.actions';
|
||||
|
||||
import { LS_CURRENT_TASK, LS_TASKS } from '../app.constants'
|
||||
import { Effect } from '@ngrx/effects';
|
||||
import { Actions } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
|
||||
// helper fn
|
||||
|
|
@ -24,53 +35,52 @@ function syncToLs(state) {
|
|||
|
||||
@Injectable()
|
||||
export class TaskEffects {
|
||||
constructor(// private actions$: Actions,
|
||||
// private store$: Store<any>
|
||||
) {
|
||||
constructor(private actions$: Actions,
|
||||
private store$: Store<any>) {
|
||||
}
|
||||
|
||||
// @Effect({dispatch: false}) addTask$: any = this.actions$
|
||||
// .ofType(ADD_TASK)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) updateTask$: any = this.actions$
|
||||
// .ofType(UPDATE_TASK)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) deleteTask$: any = this.actions$
|
||||
// .ofType(DELETE_TASK)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) setTaskDone$: any = this.actions$
|
||||
// .ofType(SET_TASK_DONE)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) setTaskUnDone$: any = this.actions$
|
||||
// .ofType(SET_TASK_UNDONE)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) addSubTask$: any = this.actions$
|
||||
// .ofType(ADD_SUB_TASK)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) sync$: any = this.actions$
|
||||
// .ofType(SYNC)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) setCurrentTask$: any = this.actions$
|
||||
// .ofType(SET_CURRENT_TASK)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
//
|
||||
// @Effect({dispatch: false}) unsetCurrentTask$: any = this.actions$
|
||||
// .ofType(UNSET_CURRENT_TASK)
|
||||
// .withLatestFrom(this.store$)
|
||||
// .do(syncToLs);
|
||||
@Effect({dispatch: false}) addTask$: any = this.actions$
|
||||
.ofType(ADD_TASK)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) updateTask$: any = this.actions$
|
||||
.ofType(UPDATE_TASK)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) deleteTask$: any = this.actions$
|
||||
.ofType(DELETE_TASK)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) setTaskDone$: any = this.actions$
|
||||
.ofType(SET_TASK_DONE)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) setTaskUnDone$: any = this.actions$
|
||||
.ofType(SET_TASK_UNDONE)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) addSubTask$: any = this.actions$
|
||||
.ofType(ADD_SUB_TASK)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) sync$: any = this.actions$
|
||||
.ofType(SYNC)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) setCurrentTask$: any = this.actions$
|
||||
.ofType(SET_CURRENT_TASK)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
|
||||
@Effect({dispatch: false}) unsetCurrentTask$: any = this.actions$
|
||||
.ofType(UNSET_CURRENT_TASK)
|
||||
.withLatestFrom(this.store$)
|
||||
.do(syncToLs);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs'
|
||||
import {Task} from './task'
|
||||
// import {Store} from '@ngrx/store';
|
||||
import {Store} from '@ngrx/store';
|
||||
import {
|
||||
ADD_SUB_TASK,
|
||||
ADD_TASK,
|
||||
|
|
@ -22,85 +22,85 @@ export class TaskService {
|
|||
currentTask$: Observable<string>;
|
||||
|
||||
constructor(
|
||||
// private _store: Store<any>
|
||||
private _store: Store<any>
|
||||
) {
|
||||
// this.tasks$ = this._store.select(state => state.TaskReducer);
|
||||
// this.currentTask$ = this._store.select(state => state.CurrentTaskReducer);
|
||||
this.tasks$ = this._store.select(state => state.TaskReducer);
|
||||
this.currentTask$ = this._store.select(state => state.CurrentTaskReducer);
|
||||
this.reloadFromLs();
|
||||
}
|
||||
|
||||
reloadFromLs() {
|
||||
// this._store.dispatch({
|
||||
// type: RELOAD_FROM_LS
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: RELOAD_FROM_LS
|
||||
});
|
||||
}
|
||||
|
||||
sync() {
|
||||
// this._store.dispatch({
|
||||
// type: SYNC
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: SYNC
|
||||
});
|
||||
}
|
||||
|
||||
addTask(title: string) {
|
||||
// this._store.dispatch({
|
||||
// type: ADD_TASK,
|
||||
// payload: {
|
||||
// title,
|
||||
// isDone: false
|
||||
// }
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: ADD_TASK,
|
||||
payload: {
|
||||
title,
|
||||
isDone: false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteTask(taskId: string) {
|
||||
// this._store.dispatch({
|
||||
// type: DELETE_TASK,
|
||||
// payload: taskId
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: DELETE_TASK,
|
||||
payload: taskId
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
updateTask(taskId: string, changedFields: any) {
|
||||
// this._store.dispatch({
|
||||
// type: UPDATE_TASK,
|
||||
// payload: {
|
||||
// id: taskId,
|
||||
// changedFields: changedFields
|
||||
// }
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: UPDATE_TASK,
|
||||
payload: {
|
||||
id: taskId,
|
||||
changedFields: changedFields
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setCurrentTask(taskId: string) {
|
||||
// this._store.dispatch({
|
||||
// type: SET_CURRENT_TASK,
|
||||
// payload: taskId,
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: SET_CURRENT_TASK,
|
||||
payload: taskId,
|
||||
});
|
||||
}
|
||||
|
||||
pauseCurrentTask() {
|
||||
// this._store.dispatch({
|
||||
// type: UNSET_CURRENT_TASK,
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: UNSET_CURRENT_TASK,
|
||||
});
|
||||
}
|
||||
|
||||
setTaskDone(taskId: string) {
|
||||
// this._store.dispatch({
|
||||
// type: SET_TASK_DONE,
|
||||
// payload: taskId,
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: SET_TASK_DONE,
|
||||
payload: taskId,
|
||||
});
|
||||
}
|
||||
|
||||
setTaskUnDone(taskId: string) {
|
||||
// this._store.dispatch({
|
||||
// type: SET_TASK_UNDONE,
|
||||
// payload: taskId,
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: SET_TASK_UNDONE,
|
||||
payload: taskId,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
addSubTask(parentTask: Task) {
|
||||
// this._store.dispatch({
|
||||
// type: ADD_SUB_TASK,
|
||||
// payload: parentTask
|
||||
// });
|
||||
this._store.dispatch({
|
||||
type: ADD_SUB_TASK,
|
||||
payload: parentTask
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -192,6 +192,14 @@
|
|||
dependencies:
|
||||
tslib "^1.9.0"
|
||||
|
||||
"@ngrx/effects@^5.2.0":
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ngrx/effects/-/effects-5.2.0.tgz#aa762b69cb6fd4644d724a1cecd265caa42baf09"
|
||||
|
||||
"@ngrx/store@^5.2.0":
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ngrx/store/-/store-5.2.0.tgz#627ed74c9cd95462930485d912a557117b23903e"
|
||||
|
||||
"@ngtools/webpack@6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@ngtools/webpack/-/webpack-6.0.1.tgz#1a3eee13f7319a5c2b758ae461c386e1b6c80645"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue