Update task in list after updating it
All checks were successful
the build was successful

This commit is contained in:
konrad 2019-02-23 15:47:54 +01:00
parent 96660a7357
commit dfde524f79
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 20 additions and 7 deletions

View File

@ -306,18 +306,14 @@
},
editTask(id) {
// Find the selected task and set it to the current object
let theTask = this.list.getTaskByID(id) // Somhow this does not work if we directly assign this to this.taskEditTask
//this.repeatAfter = theTask.getRepeatAfter()
let theTask = this.list.getTaskByID(id) // Somehow this does not work if we directly assign this to this.taskEditTask
this.taskEditTask = theTask
this.isTaskEdit = true
},
editTaskSubmit() {
this.taskService.update(this.taskEditTask)
.then(r => {
// Update the task in the list
// FIXME:
//this.updateTaskByID(this.taskEditTask.id, response.data)
this.list.updateTaskByID(r)
this.$set(this, 'taskEditTask', r)
this.handleSuccess({message: 'The task was successfully updated.'})
})

View File

@ -83,7 +83,24 @@ export default class ListModel extends AbstractModel {
return {} // FIXME: This should probably throw something to make it clear to the user noting was found
}
updateTaskByID(task, id) {
updateTaskByID(task) {
for (const t in this.tasks) {
if (this.tasks[t].id === task.id) {
this.tasks[t] = task
//this.$set(this.list.tasks, t, this.fixStuffComingFromAPI(updatedTask))
break
}
if (this.tasks[t].id === task.parentTaskID) {
for (const s in this.tasks[t].subtasks) {
if (this.tasks[t].subtasks[s].id === task.id) {
this.tasks[t].subtasks[s] = task
//this.$set(this.list.tasks[t].subtasks, s, updatedTask)
break
}
}
}
}
this.sortTasks()
}
}