diff --git a/src/store/index.js b/src/store/index.js index 95933e4..1435d4c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -3,12 +3,14 @@ import Vuex from 'vuex' import nodes from './nodes' import library from './modules/library' +import kit from './modules/kit' Vue.use(Vuex) export default new Vuex.Store({ ...nodes, modules: { - library + library, + kit } }) diff --git a/src/store/modules/kit.js b/src/store/modules/kit.js new file mode 100644 index 0000000..6a5dbdb --- /dev/null +++ b/src/store/modules/kit.js @@ -0,0 +1,22 @@ +export default { + state: { + }, + + mutations: { + }, + + 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' }) + } + }, + + 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]) + } + } +} diff --git a/src/store/utils.js b/src/store/utils.js index cf2eb04..7a9428c 100644 --- a/src/store/utils.js +++ b/src/store/utils.js @@ -25,7 +25,7 @@ export const ID_VARIANTS = { } export const VARIANT_IDS = Object.fromEntries( - Object.entries(ID_VARIANTS).map(([key, value]) => [value, key]) + Object.entries(ID_VARIANTS).map(([key, value]) => [value, parseInt(key)]) ) export const SEARCH_KEYS = ['content', 'title', 'preTitle', 'authors']