From ad7ed86d36a9385149ea75eefa8b34f643050345 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 2 Aug 2022 15:27:24 +0200 Subject: [PATCH] fix: don't replace the last edited task with the one currently editing --- src/components/tasks/edit-task.vue | 9 +++------ src/views/list/ListList.vue | 12 +----------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/components/tasks/edit-task.vue b/src/components/tasks/edit-task.vue index 6a6b703a..54001ce6 100644 --- a/src/components/tasks/edit-task.vue +++ b/src/components/tasks/edit-task.vue @@ -93,12 +93,9 @@ import {success} from '@/message' const {t} = useI18n({useScope: 'global'}) const router = useRouter() -const props = defineProps({ - task: { - type: TaskModel, - required: true, - }, -}) +const props = defineProps<{ + task?: TaskModel | null, +}>() const taskService = shallowReactive(new TaskService()) diff --git a/src/views/list/ListList.vue b/src/views/list/ListList.vue index 00a673c9..c94caf30 100644 --- a/src/views/list/ListList.vue +++ b/src/views/list/ListList.vue @@ -288,19 +288,9 @@ export default defineComponent({ this.$store.commit(HAS_TASKS, true) }, 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 - this.taskEditTask = theTask + this.taskEditTask = {...this.tasks.find(t => t.id === parseInt(id))} this.isTaskEdit = true }, - getTaskById(id) { - for (const t in this.tasks) { - if (this.tasks[t].id === parseInt(id)) { - return this.tasks[t] - } - } - return {} // FIXME: This should probably throw something to make it clear to the user noting was found - }, updateTasks(updatedTask) { for (const t in this.tasks) { if (this.tasks[t].id === updatedTask.id) {