fix: don't replace the last edited task with the one currently editing
This commit is contained in:
parent
e82a83c8cf
commit
ad7ed86d36
2 changed files with 4 additions and 17 deletions
|
@ -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())
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue