Create list through store to make sure it is updated everywhere
This commit is contained in:
parent
2d70c1aabd
commit
3677ffd585
2 changed files with 17 additions and 5 deletions
|
@ -52,5 +52,19 @@ export default {
|
||||||
return Promise.reject(e)
|
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)
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
|
@ -64,12 +64,10 @@ export default {
|
||||||
this.showError = false
|
this.showError = false
|
||||||
|
|
||||||
this.list.namespaceId = this.$route.params.id
|
this.list.namespaceId = this.$route.params.id
|
||||||
this.listService.create(this.list)
|
this.$store.dispatch('lists/createList', this.list)
|
||||||
.then(response => {
|
.then(r => {
|
||||||
response.namespaceId = this.list.namespaceId
|
|
||||||
this.$store.commit('namespaces/addListToNamespace', response)
|
|
||||||
this.success({message: 'The list was successfully created.'}, this)
|
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 => {
|
.catch(e => {
|
||||||
this.error(e, this)
|
this.error(e, this)
|
||||||
|
|
Loading…
Reference in a new issue