1234567891011121314151617181920212223242526272829303132333435363738394041 |
- export default {
- state: {
- sheet: null
- },
- mutations: {
- 'SET_KIT_SHEET' (state, id) {
- state.sheet = id
- }
- },
- actions: {
- async 'INIT_KIT' ({ state, commit, dispatch, getters }, payload) {
- const ids = await dispatch('GET_ALL_NODES_IDS', 'kit')
- return dispatch('GET_NODES', { ids, dataLevel: 'partial' })
- },
- async 'OPEN_KIT_NODE' ({ state, commit, dispatch }, id) {
- commit('SET_KIT_SHEET', id)
- commit('ADD_HISTORY_ENTRIES', [id])
- return dispatch('GET_NODE', { id, dataLevel: 'full' })
- },
- 'CLOSE_KIT_NODE' ({ state, commit }) {
- commit('SET_KIT_SHEET', null)
- }
- },
- getters: {
- sheets: (state, getters, rootState) => {
- const kitIds = rootState.ids.kit
- if (kitIds === undefined || rootState.nodes[kitIds[0]] === undefined) return
- return kitIds.map(id => rootState.nodes[id])
- },
- sheet: (state, getters, rootState) => {
- if (state.sheet === undefined || state.sheet === null) return state.sheet
- return rootState.nodes[state.sheet]
- }
- }
- }
|