fix(frontend) : refresh documents locally after upload/delete and improve progress UX

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 18:21:04 +01:00
parent 7bf632c1da
commit 9908f34580
2 changed files with 28 additions and 15 deletions

View File

@@ -375,15 +375,26 @@ watch(() => props.modelValue, async (open) => {
})
const { create, update, remove } = useTaskService()
const { remove: removeDocument } = useTaskDocumentService()
const { remove: removeDocument, getByTask: getDocumentsByTask } = useTaskDocumentService()
const { t } = useI18n()
const authStore = useAuthStore()
const isAdmin = computed(() => authStore.user?.roles?.includes('ROLE_ADMIN') ?? false)
const documents = computed(() => props.task?.documents ?? [])
const localDocuments = ref<TaskDocument[]>([])
const documents = computed(() => localDocuments.value)
const previewDoc = ref<TaskDocument | null>(null)
// Sync documents from task prop when modal opens or task changes
watch(() => props.task?.documents, (docs) => {
localDocuments.value = docs ? [...docs] : []
}, { immediate: true })
async function refreshDocuments() {
if (!props.task) return
localDocuments.value = await getDocumentsByTask(props.task.id)
}
const previewIndex = computed(() => {
if (!previewDoc.value) return -1
return documents.value.findIndex(d => d.id === previewDoc.value!.id)
@@ -408,11 +419,11 @@ function nextPreview() {
async function handleDeleteDocument(doc: TaskDocument) {
if (!confirm(t('taskDocuments.confirmDeleteMessage'))) return
await removeDocument(doc.id)
emit('saved')
await refreshDocuments()
}
function handleDocumentUploaded() {
emit('saved')
async function handleDocumentUploaded() {
await refreshDocuments()
}
async function handleDelete() {