Added TextTemplates Page and Function

This commit is contained in:
2024-04-14 21:54:23 +02:00
parent f9d7c93d21
commit 34dfb334ec
4 changed files with 156 additions and 4 deletions

View File

@@ -348,6 +348,10 @@ let links = computed(() => {
label: "Bankkonten",
to: "/settings/banking",
icon: "i-heroicons-clipboard-document-list"
},{
label: "Text Vorlagen",
to: "/settings/texttemplates",
icon: "i-heroicons-clipboard-document-list"
},{
label: "Firmeneinstellungen",
to: "/settings/tenant",

View File

@@ -0,0 +1,136 @@
<script setup>
const dataStore = useDataStore()
defineShortcuts({
'+': () => {
editTemplateModalOpen.value = true
}
})
const editTemplateModalOpen = ref(false)
const itemInfo = ref({})
</script>
<template>
<UDashboardNavbar
title="Text Vorlagen"
>
<template #right>
<UButton
@click="editTemplateModalOpen = true"
>
+ Erstellen
</UButton>
</template>
</UDashboardNavbar>
<UDashboardToolbar>
</UDashboardToolbar>
<UDashboardPanelContent>
<UCard class="mt-5 mx-5">
<template #header>
Variablen
</template>
<table>
<tr>
<th class="text-left">Variable</th>
<th class="text-left">Beschreibung</th>
</tr>
<tr>
<td>vorname</td>
<td>Vorname</td>
</tr>
<tr>
<td>nachname</td>
<td>Nachname</td>
</tr>
<tr>
<td>zahlungsziel_in_tagen</td>
<td>Zahlungsziel in Tagen</td>
</tr>
</table>
</UCard>
<div class="w-3/4 mx-auto mt-5">
<UCard
v-for="template in dataStore.texttemplates"
class="mb-3"
>
<p class="text-2xl">{{dataStore.documentTypesForCreation[template.documentType].label}}</p>
<p class="text-xl">{{template.pos === 'startText' ? 'Einleitung' : 'Ende'}}</p>
<p class="text-justify">{{template.text}}</p>
<UButton
@click="itemInfo = template;
editTemplateModalOpen = true"
icon="i-heroicons-pencil-solid"
variant="outline"
/>
</UCard>
</div>
</UDashboardPanelContent>
<USlideover
v-model="editTemplateModalOpen"
>
<UCard class="h-full">
<template #header>
{{itemInfo.id ? 'Vorlage bearbeiten' : 'Vorlage erstellen'}}
</template>
<UForm class="h-full">
<UFormGroup
label="Dokumententyp:"
>
<USelectMenu
:options="Object.keys(dataStore.documentTypesForCreation).map(i => {
return {
label: dataStore.documentTypesForCreation[i].label,
key: i
}
})"
v-model="itemInfo.documentType"
/>
</UFormGroup>
<UFormGroup
label="Position:"
>
<USelectMenu
:options="[{label:'Einleitung',key: 'startText'},{label:'Ende',key: 'endText'}]"
v-model="itemInfo.pos"
/>
</UFormGroup>
<UFormGroup
label="Text:"
>
<UTextarea
v-model="itemInfo.text"
/>
</UFormGroup>
</UForm>
<template #footer>
<UButton
@click="dataStore.createNewItem('texttemplates',itemInfo);
editTemplateModalOpen = false"
v-if="!itemInfo.id"
>Erstellen</UButton>
<UButton
@click="dataStore.updateItem('texttemplates',itemInfo);
editTemplateModalOpen = false"
v-if="itemInfo.id"
>Speichern</UButton>
</template>
</UCard>
</USlideover>
</template>
<style scoped>
</style>

View File

@@ -131,9 +131,10 @@ setupPage()
>
<template #item="{item}">
<UCard class="mt-5">
<div v-if="item.label === 'Informationen'">
Typ: {{currentItem.type}} <br>
Fahrer: {{dataStore.profiles.find(profile => profile.id === currentItem.driver) ? dataStore.profiles.find(profile => profile.id === currentItem.driver).fullName : 'Kein Fahrer gewählt'}} <br>
<div class="truncate" v-if="item.label === 'Informationen'">
<p>Typ: {{currentItem.type}}</p>
<p>Fahrgestellnummer: {{currentItem.vin}}</p>
<p>Fahrer: {{dataStore.profiles.find(profile => profile.id === currentItem.driver) ? dataStore.profiles.find(profile => profile.id === currentItem.driver).fullName : 'Kein Fahrer gewählt'}}</p>
</div>
<div v-else-if="item.label === 'Eingangsrechnungen'">
<UTable
@@ -199,6 +200,13 @@ setupPage()
v-model="itemInfo.active"
/>
</UFormGroup>
<UFormGroup
label="Fahrgestellnummer:"
>
<UInput
v-model="itemInfo.vin"
/>
</UFormGroup>
<UFormGroup
label="Typ:"
>

View File

@@ -120,6 +120,10 @@ export const useDataStore = defineStore('data', () => {
workingtimes: {
label: "Anwesenheiten",
labelSingle: "Anwesenheit"
},
texttemplates: {
label: "Textvorlagen",
labelSingle: "Textvorlage"
}
}
@@ -1004,7 +1008,7 @@ export const useDataStore = defineStore('data', () => {
}
async function fetchTextTemplates() {
texttemplates.value = (await supabase.from("textTemplates").select().eq('tenant', currentTenant.value)).data
texttemplates.value = (await supabase.from("texttemplates").select().eq('tenant', currentTenant.value)).data
}
async function fetchServices() {