Remove task in kanban state when removing in task detail view
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2020-05-11 17:24:51 +02:00
parent d409957de5
commit 687b8dc824
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 32 additions and 1 deletions

View File

@ -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()

View File

@ -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 => {

View File

@ -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}) {