5724b98358
Merge branch 'master' into feature/vuex Cleanup Move namespaces handling to store Move fullpage setting to store Move online/offline handling to store Remove debug log Fix loading namepaces Rename errorMsg Handle registering through the store Use store to determine wether or not a user is authenticated on login page Use store in edit team Use store to get the current user's avatar Use store to figure out if the current user belongs to a team Use store to figure out if the current user is list admin Use store to get user info when listing labels Use store to get username on home Use store to figure out if the user is namespace admin Use the store for configuration Use the store to check if a user is authenticated everywhere Only renew token if the user is logged in Fix renewing auth from jwt token Move logout to store Move renew token to store Move log in to store Only show enabled migrators Only show registration button if registration is enabled Put all config information from the backend in the store Remove old config handler Move config state to seperate module Add vuex and get the motd through it Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/126
63 lines
No EOL
1.6 KiB
JavaScript
63 lines
No EOL
1.6 KiB
JavaScript
import Vue from 'vue'
|
|
|
|
import NamespaceService from '../../services/namespace'
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: () => ({
|
|
namespaces: [],
|
|
}),
|
|
mutations: {
|
|
namespaces(state, namespaces) {
|
|
state.namespaces = namespaces
|
|
},
|
|
setNamespaceById(state, namespace) {
|
|
for (const n in state.namespaces) {
|
|
if (state.namespaces[n].id === namespace.id) {
|
|
namespace.lists = state.namespaces[n].lists
|
|
Vue.set(state.namespaces, n, namespace)
|
|
return
|
|
}
|
|
}
|
|
},
|
|
setListInNamespaceById(state, list) {
|
|
for (const n in state.namespaces) {
|
|
// We don't have the namespace id on the list which means we need to loop over all lists until we find it.
|
|
// FIXME: Not ideal at all - we should fix that at the api level.
|
|
for (const l in state.namespaces[n].lists) {
|
|
if (state.namespaces[n].lists[l].id === list.id) {
|
|
const namespace = state.namespaces[n]
|
|
namespace.lists[l] = list
|
|
Vue.set(state.namespaces, n, namespace)
|
|
return
|
|
}
|
|
}
|
|
}
|
|
},
|
|
addNamespace(state, namespace) {
|
|
state.namespaces.push(namespace)
|
|
},
|
|
addListToNamespace(state, list) {
|
|
for (const n in state.namespaces) {
|
|
if (state.namespaces[n].id === list.namespaceId) {
|
|
state.namespaces[n].lists.push(list)
|
|
return
|
|
}
|
|
}
|
|
},
|
|
},
|
|
actions: {
|
|
loadNamespaces(ctx) {
|
|
const namespaceService = new NamespaceService()
|
|
// We always load all namespaces and filter them on the frontend
|
|
return namespaceService.getAll({}, {is_archived: true})
|
|
.then(r => {
|
|
ctx.commit('namespaces', r)
|
|
return Promise.resolve()
|
|
})
|
|
.catch(e => {
|
|
return Promise.reject(e)
|
|
})
|
|
},
|
|
},
|
|
} |