diff --git a/src/components/tasks/edit-task.vue b/src/components/tasks/edit-task.vue index 6a6b703a9..54001ce67 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 00a673c91..c94caf301 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) {