Move everything to models and services #17

Merged
konrad merged 82 commits from refactor/models into master 2019-03-02 10:25:10 +00:00
2 changed files with 20 additions and 7 deletions
Showing only changes of commit dfde524f79 - Show all commits

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