Create list through store to make sure it is updated everywhere
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2020-11-12 19:59:32 +01:00
parent 2d70c1aabd
commit 3677ffd585
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 17 additions and 5 deletions

View File

@ -52,5 +52,19 @@ export default {
return Promise.reject(e)
})
},
createList(ctx, list) {
const listService = new ListService()
return listService.create(list)
.then(r => {
r.namespaceId = list.namespaceId
ctx.commit('namespaces/addListToNamespace', r, {root: true})
ctx.commit('addList', r)
return Promise.resolve(r)
})
.catch(e => {
return Promise.reject(e)
})
},
},
}

View File

@ -64,12 +64,10 @@ export default {
this.showError = false
this.list.namespaceId = this.$route.params.id
this.listService.create(this.list)
.then(response => {
response.namespaceId = this.list.namespaceId
this.$store.commit('namespaces/addListToNamespace', response)
this.$store.dispatch('lists/createList', this.list)
.then(r => {
this.success({message: 'The list was successfully created.'}, this)
router.push({name: 'list.index', params: {listId: response.id}})
router.push({name: 'list.index', params: {listId: r.id}})
})
.catch(e => {
this.error(e, this)