Add list title in overview page
This commit is contained in:
@ -2,12 +2,13 @@ import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
Vue.use(Vuex)
|
||||
|
||||
import {CURRENT_LIST, ERROR_MESSAGE, IS_FULLPAGE, LOADING, ONLINE} from './mutation-types'
|
||||
import config from './modules/config'
|
||||
import auth from './modules/auth'
|
||||
import namespaces from './modules/namespaces'
|
||||
import kanban from './modules/kanban'
|
||||
import tasks from './modules/tasks'
|
||||
import {CURRENT_LIST, ERROR_MESSAGE, IS_FULLPAGE, LOADING, ONLINE} from './mutation-types'
|
||||
import lists from './modules/lists'
|
||||
|
||||
export const store = new Vuex.Store({
|
||||
modules: {
|
||||
@ -16,6 +17,7 @@ export const store = new Vuex.Store({
|
||||
namespaces,
|
||||
kanban,
|
||||
tasks,
|
||||
lists,
|
||||
},
|
||||
state: {
|
||||
loading: false,
|
||||
|
25
src/store/modules/lists.js
Normal file
25
src/store/modules/lists.js
Normal 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
|
||||
},
|
||||
},
|
||||
}
|
@ -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 => {
|
||||
|
Reference in New Issue
Block a user