blob: eb8200f6e0cf5355e7eee81f7672f0402515d6c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/**
* Created by ob0695 on 7/17/2018.
*/
import {State, Action, StateContext} from '@ngxs/store';
import {UpdateIsDesigner, UpdateIsViewOnly} from "../actions/workspace.action";
import {Selector} from "@ngxs/store";
export interface WorkspaceStateModel {
isViewOnly: boolean;
isDesigner: boolean;
}
@State<WorkspaceStateModel>({
name: 'workspace',
defaults: {
isViewOnly: false,
isDesigner: true
}
})
export class WorkspaceState {
constructor(){}
@Selector() static isViewOnly(state: WorkspaceStateModel):boolean {
return state.isViewOnly;
}
@Selector() static isDesigner(state: WorkspaceStateModel): boolean {
return state.isDesigner;
}
@Action(UpdateIsViewOnly)
updateIsViewOnly({getState, setState}: StateContext<WorkspaceStateModel>, action:UpdateIsViewOnly) {
const state = getState();
setState({
...state,
isViewOnly: action.isViewOnly
});
}
@Action(UpdateIsDesigner)
updateIsDesigner({getState, patchState}: StateContext<WorkspaceStateModel>, action:UpdateIsDesigner) {
const state = getState();
patchState({
isDesigner: action.isDesigner
});
}
}
|