axolotle пре 3 година
родитељ
комит
1387bbed69
3 измењених фајлова са 26 додато и 2 уклоњено
  1. 3 1
      src/store/index.js
  2. 22 0
      src/store/modules/kit.js
  3. 1 1
      src/store/utils.js

+ 3 - 1
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
   }
 })

+ 22 - 0
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])
+    }
+  }
+}

+ 1 - 1
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']