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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user