Changes
This commit is contained in:
@@ -20,37 +20,46 @@ const emailAccounts = ref([])
|
||||
const preloadedContent = ref("")
|
||||
const loadedDocuments = ref([])
|
||||
const loaded = ref(false)
|
||||
const noAccountsPresent = ref(false)
|
||||
const setupPage = async () => {
|
||||
emailAccounts.value = await useSupabaseSelect("emailAccounts")
|
||||
emailData.value.account = emailAccounts.value[0].id
|
||||
|
||||
preloadedContent.value = `<p></p><p></p><p></p>${dataStore.activeProfile.emailSignature}`
|
||||
if(emailAccounts.value.length === 0) {
|
||||
noAccountsPresent.value = true
|
||||
} else {
|
||||
emailData.value.account = emailAccounts.value[0].id
|
||||
|
||||
//Check Query
|
||||
if(route.query.to) emailData.value.to = route.query.to
|
||||
if(route.query.cc) emailData.value.cc = route.query.cc
|
||||
if(route.query.bcc) emailData.value.bcc = route.query.bcc
|
||||
if(route.query.subject) emailData.value.to = route.query.subject
|
||||
preloadedContent.value = `<p></p><p></p><p></p>${dataStore.activeProfile.emailSignature}`
|
||||
|
||||
//Check Query
|
||||
if(route.query.to) emailData.value.to = route.query.to
|
||||
if(route.query.cc) emailData.value.cc = route.query.cc
|
||||
if(route.query.bcc) emailData.value.bcc = route.query.bcc
|
||||
if(route.query.subject) emailData.value.to = route.query.subject
|
||||
|
||||
|
||||
if(route.query.loadDocuments) {
|
||||
//console.log(JSON.parse(route.query.loadDocuments))
|
||||
const {data,error} = await supabase.from("documents").select('*, createdDocument(id,documentNumber,title,contact(email))').in('id',JSON.parse(route.query.loadDocuments))
|
||||
if(route.query.loadDocuments) {
|
||||
//console.log(JSON.parse(route.query.loadDocuments))
|
||||
const {data,error} = await supabase.from("documents").select('*, createdDocument(id,documentNumber,title,contact(email))').in('id',JSON.parse(route.query.loadDocuments))
|
||||
|
||||
if(error) console.log(error)
|
||||
if(data) loadedDocuments.value = data
|
||||
if(error) console.log(error)
|
||||
if(data) loadedDocuments.value = data
|
||||
|
||||
//console.log(loadedDocuments.value)
|
||||
//console.log(loadedDocuments.value)
|
||||
|
||||
if(loadedDocuments.value.length > 0) {
|
||||
emailData.value.subject = loadedDocuments.value[0].createdDocument.title
|
||||
emailData.value.to = loadedDocuments.value[0].createdDocument.contact ? loadedDocuments.value[0].createdDocument.contact.email : ""
|
||||
if(loadedDocuments.value.length > 0) {
|
||||
emailData.value.subject = loadedDocuments.value[0].createdDocument.title
|
||||
emailData.value.to = loadedDocuments.value[0].createdDocument.contact ? loadedDocuments.value[0].createdDocument.contact.email : ""
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
loaded.value = true
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -142,98 +151,112 @@ const sendEmail = async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UProgress animation="carousel" v-if="!loaded" class="mt-5 w-2/3 mx-auto"/>
|
||||
|
||||
<div v-else>
|
||||
<UDashboardNavbar
|
||||
title="Neue E-Mail"
|
||||
<div v-if="noAccountsPresent" class="mx-auto mt-5 flex flex-col justify-center">
|
||||
<span class="font-bold text-2xl">Keine E-Mail Konten vorhanden</span>
|
||||
<UButton
|
||||
@click="router.push(`/settings/emailAccounts`)"
|
||||
class="mx-auto mt-5"
|
||||
>
|
||||
<template #right>
|
||||
<UButton
|
||||
@click="sendEmail"
|
||||
:disabled="!emailData.to || !emailData.subject"
|
||||
>
|
||||
Senden
|
||||
</UButton>
|
||||
</template>
|
||||
|
||||
</UDashboardNavbar>
|
||||
<UDashboardToolbar>
|
||||
<div class="flex-col flex w-full">
|
||||
<UFormGroup
|
||||
label="Absender"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="emailAccounts"
|
||||
option-attribute="emailAddress"
|
||||
value-attribute="id"
|
||||
v-model="emailData.account"
|
||||
/>
|
||||
</UFormGroup>
|
||||
|
||||
<UInput
|
||||
class="w-full my-1"
|
||||
placeholder="Empfänger"
|
||||
variant="ghost"
|
||||
v-model="emailData.to"
|
||||
/>
|
||||
<UInput
|
||||
class="w-full my-1"
|
||||
placeholder="Kopie"
|
||||
variant="ghost"
|
||||
v-model="emailData.cc"
|
||||
/>
|
||||
<UInput
|
||||
class="w-full my-1"
|
||||
placeholder="Blindkopie"
|
||||
variant="ghost"
|
||||
v-model="emailData.bcc"
|
||||
/>
|
||||
<UInput
|
||||
placeholder="Betreff"
|
||||
class="w-full my-1"
|
||||
variant="ghost"
|
||||
v-model="emailData.subject"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</UDashboardToolbar>
|
||||
|
||||
<UDashboardPanelContent>
|
||||
<div id="parentAttachments" class="flex flex-col justify-center">
|
||||
<span class="font-medium mb-2 text-xl">Anhänge</span>
|
||||
<!-- <UIcon
|
||||
name="i-heroicons-paper-clip"
|
||||
class="mx-auto w-10 h-10"
|
||||
/>
|
||||
<span class="text-center text-2xl">Anhänge hochladen</span>-->
|
||||
<input
|
||||
id="inputAttachments"
|
||||
type="file"
|
||||
multiple
|
||||
@change="renderAttachments"
|
||||
/>
|
||||
<ul class="mx-5 mt-3">
|
||||
<li
|
||||
class="list-disc"
|
||||
v-for="file in selectedAttachments"
|
||||
> Datei - {{file.filename}}</li>
|
||||
<li
|
||||
class="list-disc"
|
||||
v-for="doc in loadedDocuments"
|
||||
>
|
||||
<span v-if="doc.createdDocument">Dokument - {{doc.createdDocument.documentNumber}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<Tiptap
|
||||
@updateContent="contentChanged"
|
||||
:preloadedContent="preloadedContent"
|
||||
/>
|
||||
</UDashboardPanelContent>
|
||||
+ E-Mail Konto
|
||||
</UButton>
|
||||
</div>
|
||||
<div v-else>
|
||||
<UProgress animation="carousel" v-if="!loaded" class="mt-5 w-2/3 mx-auto"/>
|
||||
|
||||
<div v-else>
|
||||
<UDashboardNavbar
|
||||
title="Neue E-Mail"
|
||||
>
|
||||
<template #right>
|
||||
<UButton
|
||||
@click="sendEmail"
|
||||
:disabled="!emailData.to || !emailData.subject"
|
||||
>
|
||||
Senden
|
||||
</UButton>
|
||||
</template>
|
||||
|
||||
</UDashboardNavbar>
|
||||
<UDashboardToolbar>
|
||||
<div class="flex-col flex w-full">
|
||||
<UFormGroup
|
||||
label="Absender"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="emailAccounts"
|
||||
option-attribute="emailAddress"
|
||||
value-attribute="id"
|
||||
v-model="emailData.account"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<UDivider class="my-3"/>
|
||||
<UInput
|
||||
class="w-full my-1"
|
||||
placeholder="Empfänger"
|
||||
variant="ghost"
|
||||
v-model="emailData.to"
|
||||
/>
|
||||
<UInput
|
||||
class="w-full my-1"
|
||||
placeholder="Kopie"
|
||||
variant="ghost"
|
||||
v-model="emailData.cc"
|
||||
/>
|
||||
<UInput
|
||||
class="w-full my-1"
|
||||
placeholder="Blindkopie"
|
||||
variant="ghost"
|
||||
v-model="emailData.bcc"
|
||||
/>
|
||||
<UInput
|
||||
placeholder="Betreff"
|
||||
class="w-full my-1"
|
||||
variant="ghost"
|
||||
v-model="emailData.subject"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</UDashboardToolbar>
|
||||
|
||||
<UDashboardPanelContent>
|
||||
<div id="parentAttachments" class="flex flex-col justify-center">
|
||||
<span class="font-medium mb-2 text-xl">Anhänge</span>
|
||||
<!-- <UIcon
|
||||
name="i-heroicons-paper-clip"
|
||||
class="mx-auto w-10 h-10"
|
||||
/>
|
||||
<span class="text-center text-2xl">Anhänge hochladen</span>-->
|
||||
<input
|
||||
id="inputAttachments"
|
||||
type="file"
|
||||
multiple
|
||||
@change="renderAttachments"
|
||||
/>
|
||||
<ul class="mx-5 mt-3">
|
||||
<li
|
||||
class="list-disc"
|
||||
v-for="file in selectedAttachments"
|
||||
> Datei - {{file.filename}}</li>
|
||||
<li
|
||||
class="list-disc"
|
||||
v-for="doc in loadedDocuments"
|
||||
>
|
||||
<span v-if="doc.createdDocument">Dokument - {{doc.createdDocument.documentNumber}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<Tiptap
|
||||
@updateContent="contentChanged"
|
||||
:preloadedContent="preloadedContent"
|
||||
/>
|
||||
</UDashboardPanelContent>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user