workspace-store refactoring

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2020-07-06 11:33:51 +03:00
1 parent a27ce9cf8b
commit d4bbaf4f34
4 files changed
+48 -53

No files matched your search

@@ -55,6 +55,7 @@
<script>
import ClosePageButton from "@/_vue/components/common/ClosePageButton";
import { workspaceStore } from "../../../common/workspace-store"
export default {
name: 'EditWorkspacePage',
@@ -71,7 +72,7 @@ export default {
},
computed: {
workspace: function() {
return this.$store.getters.workspaceById(this.$route.params.id)
return workspaceStore.getById(this.$route.params.id)
}
},
methods: {
+11 -12
View File
@@ -1,5 +1,5 @@
import { MutationTree, ActionTree, GetterTree } from "vuex"
import { workspaceStore, Workspace } from "../../../../common/workspace-store"
import { ActionTree, GetterTree, MutationTree } from "vuex"
import { Workspace, workspaceStore } from "../../../../common/workspace-store"
export interface WorkspaceState {
workspaces: Array<Workspace>;
@@ -7,12 +7,11 @@ export interface WorkspaceState {
}
const state: WorkspaceState = {
workspaces: workspaceStore.getAllWorkspaces(),
currentWorkspace: workspaceStore.getAllWorkspaces().find((w) => w.id === "default")
workspaces: workspaceStore.workspaces,
currentWorkspace: workspaceStore.workspaces.find((w) => w.id === "default")
}
const actions: ActionTree<WorkspaceState, any> = {
}
const actions: ActionTree<WorkspaceState, any> = {}
const getters: GetterTree<WorkspaceState, any> = {
workspaces: state => state.workspaces,
@@ -27,16 +26,16 @@ const mutations: MutationTree<WorkspaceState> = {
state.currentWorkspace = workspace
},
addWorkspace(state, workspace: Workspace) {
workspaceStore.saveWorkspace(workspace)
state.workspaces = workspaceStore.getAllWorkspaces()
workspaceStore.saveWorkspace({ ...workspace })
state.workspaces = workspaceStore.workspaces
},
updateWorkspace(state, workspace: Workspace) {
workspaceStore.saveWorkspace(workspace)
state.workspaces = workspaceStore.getAllWorkspaces()
workspaceStore.saveWorkspace({ ...workspace })
state.workspaces = workspaceStore.workspaces
},
removeWorkspace(state, workspace: Workspace) {
workspaceStore.removeWorkspace(workspace)
state.workspaces = workspaceStore.getAllWorkspaces()
workspaceStore.removeWorkspace(workspace.id)
state.workspaces = workspaceStore.workspaces
}
}