feat: improve loadTask logic (#2715)
Co-authored-by: Dominik Pschenitschni <mail@celement.de> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/2715 Co-authored-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de> Co-committed-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de>
This commit is contained in:
parent
3aaacf4533
commit
8ef309243d
@ -445,7 +445,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {ref, reactive, toRef, shallowReactive, computed, watch, watchEffect, nextTick, type PropType} from 'vue'
|
import {ref, reactive, toRef, shallowReactive, computed, watch, nextTick, type PropType} from 'vue'
|
||||||
import {useRouter, type RouteLocation} from 'vue-router'
|
import {useRouter, type RouteLocation} from 'vue-router'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {unrefElement} from '@vueuse/core'
|
import {unrefElement} from '@vueuse/core'
|
||||||
@ -590,13 +590,14 @@ async function scrollToHeading() {
|
|||||||
|
|
||||||
const taskService = shallowReactive(new TaskService())
|
const taskService = shallowReactive(new TaskService())
|
||||||
|
|
||||||
async function loadTask(taskId: ITask['id']) {
|
// load task
|
||||||
if (taskId === undefined) {
|
watch(taskId, async (id) => {
|
||||||
|
if (id === undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object.assign(task, await taskService.get({id: taskId}))
|
Object.assign(task, await taskService.get({id}))
|
||||||
attachmentStore.set(task.attachments)
|
attachmentStore.set(task.attachments)
|
||||||
taskColor.value = task.hexColor
|
taskColor.value = task.hexColor
|
||||||
setActiveFields()
|
setActiveFields()
|
||||||
@ -605,9 +606,7 @@ async function loadTask(taskId: ITask['id']) {
|
|||||||
scrollToHeading()
|
scrollToHeading()
|
||||||
visible.value = true
|
visible.value = true
|
||||||
}
|
}
|
||||||
}
|
}, {immediate: true})
|
||||||
|
|
||||||
watchEffect(() => taskId.value !== undefined && loadTask(taskId.value))
|
|
||||||
|
|
||||||
type FieldType =
|
type FieldType =
|
||||||
| 'assignees'
|
| 'assignees'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user