KI-AGENT: Briefpapier-Upload und Dateianzeige korrigieren
This commit is contained in:
@@ -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 }">
|
||||||
|
|||||||
Reference in New Issue
Block a user