Remove task in kanban state when removing in task detail view
This commit is contained in:
parent
d409957de5
commit
687b8dc824
3 changed files with 32 additions and 1 deletions
|
@ -488,7 +488,7 @@
|
|||
this.$nextTick(() => this.$refs[fieldName].$el.focus())
|
||||
},
|
||||
deleteTask() {
|
||||
this.taskService.delete(this.task)
|
||||
this.$store.dispatch('tasks/delete', this.task)
|
||||
.then(() => {
|
||||
this.success({message: 'The task been deleted successfully.'}, this)
|
||||
router.back()
|
||||
|
|
|
@ -67,6 +67,26 @@ export default {
|
|||
const bi = filterObject(state.buckets, b => b.id === task.bucketId)
|
||||
state.buckets[bi].tasks.push(task)
|
||||
},
|
||||
removeTaskInBucket(state, task) {
|
||||
// If this gets invoked without any tasks actually loaded, we can save the hassle of finding the task
|
||||
if (state.buckets.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
for (const b in state.buckets) {
|
||||
if (state.buckets[b].id === task.bucketId) {
|
||||
for (const t in state.buckets[b].tasks) {
|
||||
if (state.buckets[b].tasks[t].id === task.id) {
|
||||
const bucket = state.buckets[b]
|
||||
bucket.tasks.splice(t, 1)
|
||||
Vue.set(state.buckets, b, bucket)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getTaskById: state => id => {
|
||||
|
|
|
@ -19,6 +19,17 @@ export default {
|
|||
return Promise.reject(e)
|
||||
})
|
||||
},
|
||||
delete(ctx, task) {
|
||||
const taskService = new TaskService()
|
||||
return taskService.delete(task)
|
||||
.then(t => {
|
||||
ctx.commit('kanban/removeTaskInBucket', task, {root: true})
|
||||
return Promise.resolve(t)
|
||||
})
|
||||
.catch(e => {
|
||||
return Promise.reject(e)
|
||||
})
|
||||
},
|
||||
// Adds a task attachment in store.
|
||||
// This is an action to be able to commit other mutations
|
||||
addTaskAttachment(ctx, {taskId, attachment}) {
|
||||
|
|
Loading…
Reference in a new issue