@@ -140,8 +107,8 @@
import ListModel from '../../models/list'
import EditTask from './edit-task'
import TaskModel from '../../models/task'
- import PriorityLabel from './reusable/priorityLabel'
import TaskCollectionService from '../../services/taskCollection'
+ import SingleTaskInList from './reusable/singleTaskInList'
export default {
data() {
@@ -165,7 +132,7 @@
}
},
components: {
- PriorityLabel,
+ SingleTaskInList,
EditTask,
},
props: {
@@ -267,34 +234,6 @@
}
this.initTasks(page, search)
},
- markAsDone(e) {
- let updateFunc = () => {
- // We get the task, update the 'done' property and then push it to the api.
- let task = this.getTaskByID(e.target.id)
- task.done = e.target.checked
- this.taskService.update(task)
- .then(() => {
- this.sortTasks()
- this.success(
- {message: 'The task was successfully ' + (task.done ? '' : 'un-') + 'marked as done.'},
- this,
- [{
- title: 'Undo',
- callback: () => this.markAsDone({target: {id: e.target.id, checked: !e.target.checked}}),
- }]
- )
- })
- .catch(e => {
- this.error(e, this)
- })
- }
-
- if (e.target.checked) {
- setTimeout(updateFunc(), 300); // Delay it to show the animation when marking a task as done
- } else {
- updateFunc() // Don't delay it when un-marking it as it doesn't have an animation the other way around
- }
- },
editTask(id) {
// Find the selected task and set it to the current object
let theTask = this.getTaskByID(id) // Somehow this does not work if we directly assign this to this.taskEditTask
@@ -326,6 +265,15 @@
return 0
})
},
+ updateTasks(updatedTask) {
+ for (const t in this.tasks) {
+ if (this.tasks[t].id === updatedTask.id) {
+ this.$set(this.tasks, t, updatedTask)
+ break
+ }
+ }
+ this.sortTasks()
+ },
searchTasks() {
if (this.searchTerm === '') {
return
diff --git a/src/components/tasks/ShowTasks.vue b/src/components/tasks/ShowTasks.vue
index 1baad5a8..6cf9a5c7 100644
--- a/src/components/tasks/ShowTasks.vue
+++ b/src/components/tasks/ShowTasks.vue
@@ -8,36 +8,20 @@