Fix removing a namespace not removing it from the list

This commit is contained in:
kolaente 2021-01-08 23:03:40 +01:00
parent 98feedfcd3
commit 35ef66744b
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 10 additions and 1 deletions

View file

@ -41,6 +41,14 @@ export default {
addNamespace(state, namespace) { addNamespace(state, namespace) {
state.namespaces.push(namespace) state.namespaces.push(namespace)
}, },
removeNamespaceById(state, namespaceId) {
for (const n in state.namespaces) {
if (state.namespaces[n].id === namespaceId) {
state.namespaces.splice(n, 1)
return
}
}
},
addListToNamespace(state, list) { addListToNamespace(state, list) {
for (const n in state.namespaces) { for (const n in state.namespaces) {
if (state.namespaces[n].id === list.namespaceId) { if (state.namespaces[n].id === list.namespaceId) {

View file

@ -95,7 +95,7 @@
<modal <modal
@close="showDeleteModal = false" @close="showDeleteModal = false"
v-if="showDeleteModal" v-if="showDeleteModal"
v-on:submit="deleteNamespace()"> @submit="deleteNamespace()">
<span slot="header">Delete the namespace</span> <span slot="header">Delete the namespace</span>
<p slot="text">Are you sure you want to delete this namespace and all of its contents? <p slot="text">Are you sure you want to delete this namespace and all of its contents?
<br/>This includes lists & tasks and <b>CANNOT BE UNDONE!</b></p> <br/>This includes lists & tasks and <b>CANNOT BE UNDONE!</b></p>
@ -192,6 +192,7 @@ export default {
deleteNamespace() { deleteNamespace() {
this.namespaceService.delete(this.namespace) this.namespaceService.delete(this.namespace)
.then(() => { .then(() => {
this.$store.commit('namespaces/removeNamespaceById', this.namespace.id)
this.success({message: 'The namespace was successfully deleted.'}, this) this.success({message: 'The namespace was successfully deleted.'}, this)
router.push({name: 'home'}) router.push({name: 'home'})
}) })