1
0

Add list title in overview page

This commit is contained in:
kolaente
2020-05-11 16:52:58 +02:00
parent b85f66140b
commit 995dec33ea
7 changed files with 62 additions and 14 deletions

View File

@ -0,0 +1,25 @@
import Vue from 'vue'
export default {
namespaced: true,
// The state is an object which has the list ids as keys.
state: () => ({}),
mutations: {
addList(state, list) {
Vue.set(state, list.id, list)
},
addLists(state, lists) {
lists.forEach(l => {
Vue.set(state, l.id, l)
})
},
},
getters: {
getListById: state => id => {
if(typeof state[id] !== 'undefined') {
return state[id]
}
return null
},
},
}

View File

@ -47,16 +47,6 @@ export default {
},
},
getters: {
getListById: state => id => {
for (const n in state.namespaces) {
for (const l in state.namespaces[n].lists) {
if (state.namespaces[n].lists[l].id === id) {
return state.namespaces[n].lists[l]
}
}
}
return null
},
getListAndNamespaceById: state => listId => {
for (const n in state.namespaces) {
for (const l in state.namespaces[n].lists) {
@ -78,6 +68,17 @@ export default {
return namespaceService.getAll({}, {is_archived: true})
.then(r => {
ctx.commit('namespaces', r)
// Put all lists in the list state
const lists = []
r.forEach(n => {
n.lists.forEach(l => {
lists.push(l)
})
})
ctx.commit('lists/addLists', lists, {root:true})
return Promise.resolve()
})
.catch(e => {