Files
freeplanet/src/store/Modules/GlobalStore.ts
Paolo Arena 818a7a4289 - dialog confirm delete item
- fix: context-menu (right click) declared only once and using twice using:
  @click.native="$refs.popover.$refs.popup.show()"
2019-01-29 23:13:28 +01:00

82 lines
1.5 KiB
TypeScript

import { IGlobalState } from 'model'
import { storeBuilder } from './Store/Store'
const state: IGlobalState = {
conta: 0,
isLoginPage: false,
layoutNeeded: true,
mobileMode: false,
menuCollapse: true,
leftDrawerOpen: true,
posts: [],
listatodo: [
{namecat: 'personal', description: 'personal'},
{namecat: 'work', description: 'work'},
{namecat: 'shopping', description: 'shopping'}
]
}
const b = storeBuilder.module<IGlobalState>('GlobalModule', state)
// Getters
namespace Getters {
const conta = b.read(state => state.conta, 'conta')
const listatodo = b.read(state => state.listatodo, 'listatodo')
export const getters = {
get conta() {
return conta()
},
get listaTodo() {
return listatodo()
}
}
}
namespace Mutations {
function setConta(state: IGlobalState, num: number) {
state.conta = num
}
function setleftDrawerOpen(state: IGlobalState, bool: boolean) {
state.leftDrawerOpen = bool
}
export const mutations = {
setConta: b.commit(setConta),
setleftDrawerOpen: b.commit(setleftDrawerOpen)
}
}
namespace Actions {
async function setConta(context, num: number) {
Mutations.mutations.setConta(num)
}
export const actions = {
setConta: b.dispatch(setConta)
}
}
const stateGetter = b.state()
// Module
const GlobalModule = {
get state() {
return stateGetter()
},
getters: Getters.getters,
mutations: Mutations.mutations,
actions: Actions.actions
}
export default GlobalModule