KI-AGENT: Briefpapier-Upload und Dateianzeige korrigieren

This commit is contained in:
2026-05-18 21:10:41 +02:00
parent 454e9ee3c9
commit b7b913035e

View File

@@ -26,8 +26,23 @@ const documentTypeOptions = computed(() =>
const getDocumentTypeLabel = (type) => const getDocumentTypeLabel = (type) =>
dataStore.documentTypesForCreation?.[type]?.label || type dataStore.documentTypesForCreation?.[type]?.label || type
const getFileForLetterhead = (letterhead) => const normalizePath = (path) =>
files.value.find((file) => file.path === letterhead.path) String(path || "").trim().replace(/^\/+/, "")
const getFileForLetterhead = (letterhead) => {
const letterheadPath = normalizePath(letterhead?.path)
if (!letterheadPath) return null
return files.value.find((file) => normalizePath(file.path) === letterheadPath) || null
}
const getFileNameForLetterhead = (letterhead) => {
const file = getFileForLetterhead(letterhead)
if (file?.name) return file.name
const path = normalizePath(letterhead?.path)
return path ? decodeURIComponent(path.split("/").pop()) : null
}
const sortedLetterheads = computed(() => const sortedLetterheads = computed(() =>
[...letterheads.value].sort((a, b) => { [...letterheads.value].sort((a, b) => {
@@ -94,7 +109,7 @@ const uploadLetterheadPdf = async () => {
const formData = new FormData() const formData = new FormData()
formData.append("file", selectedFile.value) formData.append("file", selectedFile.value)
formData.append("meta", JSON.stringify({ type: "Briefpapier" })) formData.append("meta", JSON.stringify({ filename: selectedFile.value.name }))
return await useNuxtApp().$api("/api/files/upload", { return await useNuxtApp().$api("/api/files/upload", {
method: "POST", method: "POST",
@@ -216,9 +231,12 @@ onMounted(refreshData)
variant="ghost" variant="ghost"
@click.stop="downloadLetterhead(row.original)" @click.stop="downloadLetterhead(row.original)"
> >
PDF {{ getFileNameForLetterhead(row.original) || "PDF" }}
</UButton> </UButton>
<span v-else class="text-sm text-gray-500">Nicht zugeordnet</span> <span v-else-if="getFileNameForLetterhead(row.original)" class="text-sm text-gray-700 dark:text-gray-300">
{{ getFileNameForLetterhead(row.original) }}
</span>
<span v-else class="text-sm text-gray-500">Keine Datei hinterlegt</span>
</template> </template>
<template #actions-cell="{ row }"> <template #actions-cell="{ row }">