All checks were successful
Build and Push Docker Images / build-frontend (push) Successful in 1m22s
Build and Push Docker Images / build-website (push) Successful in 23s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-backend (push) Successful in 43s
Build and Push Docker Images / build-central-services-admin (push) Successful in 21s
Build and Push Docker Images / build-docs (push) Successful in 21s
82 lines
2.9 KiB
Vue
82 lines
2.9 KiB
Vue
<script setup>
|
|
const dataStore = useDataStore()
|
|
const router = useRouter()
|
|
const toast = useToast()
|
|
const templates = ref([])
|
|
const loading = ref(true)
|
|
|
|
const documentTypeItems = computed(() => dataStore.documentTypesForCreation || {})
|
|
|
|
const refresh = async () => {
|
|
loading.value = true
|
|
try {
|
|
templates.value = await useEntities("documenttemplates").select("*")
|
|
} catch (error) {
|
|
toast.add({ title: "Vorlagen konnten nicht geladen werden", description: error.message, color: "error" })
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
const openNew = () => router.push("/createDocument/edit?mode=template&type=invoices")
|
|
const openTemplate = (template) => router.push(`/createDocument/edit?mode=template&templateId=${template.id}`)
|
|
const archiveTemplate = async (template) => {
|
|
await useEntities("documenttemplates").update(template.id, { archived: true }, true)
|
|
await refresh()
|
|
}
|
|
|
|
const typeLabel = (type) => documentTypeItems.value[type]?.labelSingle || type
|
|
|
|
refresh()
|
|
</script>
|
|
|
|
<template>
|
|
<UDashboardNavbar title="Dokumentenvorlagen">
|
|
<template #right>
|
|
<UButton icon="i-heroicons-plus" @click="openNew">Neue Vorlage</UButton>
|
|
</template>
|
|
</UDashboardNavbar>
|
|
|
|
<UDashboardPanelContent>
|
|
<UAlert
|
|
class="mx-5 mt-2"
|
|
color="primary"
|
|
variant="soft"
|
|
title="Vorlagen für alle Ausgangsdokumente"
|
|
description="Dokumentenvorlagen verwenden denselben Editor wie die Ausgangsbelege. Jede Einstellung wird als Vorlage gespeichert."
|
|
/>
|
|
|
|
<UTable
|
|
class="mt-4"
|
|
:data="templates"
|
|
:loading="loading"
|
|
:columns="normalizeTableColumns([
|
|
{ key: 'name', label: 'Bezeichnung' },
|
|
{ key: 'documentType', label: 'Dokumenttyp' },
|
|
{ key: 'default', label: 'Standard' },
|
|
{ key: 'actions', label: '' }
|
|
])"
|
|
>
|
|
<template #name-cell="{ row }">
|
|
<span class="font-medium text-highlighted">{{ row.original.name }}</span>
|
|
</template>
|
|
<template #documentType-cell="{ row }">
|
|
<UBadge color="neutral" variant="soft">{{ typeLabel(row.original.documentType) }}</UBadge>
|
|
</template>
|
|
<template #default-cell="{ row }">
|
|
<UIcon v-if="row.original.default" name="i-heroicons-check-circle-20-solid" class="text-green-500" />
|
|
<span v-else class="text-muted">-</span>
|
|
</template>
|
|
<template #actions-cell="{ row }">
|
|
<div class="flex justify-end gap-1">
|
|
<UButton icon="i-heroicons-pencil-square" color="neutral" variant="ghost" @click="openTemplate(row.original)" />
|
|
<UButton icon="i-heroicons-archive-box" color="error" variant="ghost" @click="archiveTemplate(row.original)" />
|
|
</div>
|
|
</template>
|
|
<template #empty>
|
|
<TableEmptyState label="Keine Dokumentenvorlagen gefunden" icon="i-heroicons-document-duplicate" />
|
|
</template>
|
|
</UTable>
|
|
</UDashboardPanelContent>
|
|
</template>
|