fix: don't replace the last edited task with the one currently editing

This commit is contained in:
kolaente 2022-08-02 15:27:24 +02:00
parent e82a83c8cf
commit ad7ed86d36
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 4 additions and 17 deletions

View file

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

View file

@ -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) {