update Kit view to work with url params

This commit is contained in:
axolotle
2021-07-09 14:35:59 +02:00
parent 3accfb5b66
commit 16a1db76fb
4 changed files with 73 additions and 11 deletions
+18 -4
View File
@@ -1,3 +1,6 @@
import router from '@/router'
export default {
state: {
sheet: null
@@ -10,18 +13,29 @@ export default {
},
actions: {
'INIT_KIT' ({ state, commit, dispatch, getters }) {
const ids = dispatch('GET_ALL_NODES_IDS', { variant: 'kit', dataLevel: 'partial' })
async 'INIT_KIT' ({ state, commit, dispatch, getters }) {
const ids = await dispatch('GET_ALL_NODES_IDS', { variant: 'kit', dataLevel: 'partial' })
return dispatch('GET_NODES', { ids, dataLevel: 'partial' })
},
async 'OPEN_KIT_NODE' ({ state, commit, dispatch }, id) {
async 'INIT_KIT_VIEW' ({ state, commit, dispatch, getters }, id) {
await dispatch('INIT_KIT')
const node = await dispatch('GET_NODE', { id, dataLevel: 'full' })
commit('SET_KIT_SHEET', id)
commit('ADD_HISTORY_ENTRIES', [id])
return dispatch('GET_NODE', { id, dataLevel: 'full' })
return node
},
async 'OPEN_KIT_NODE' ({ state, commit, dispatch }, id) {
if (router.currentRoute.name !== 'kit-view') {
router.push({ name: 'kit-view', params: { id } })
} else {
router.push({ params: { id } })
}
},
'CLOSE_KIT_NODE' ({ state, commit }) {
router.push({ name: 'kit' })
commit('SET_KIT_SHEET', null)
}
},