New Backend changes

This commit is contained in:
2025-09-02 18:47:12 +02:00
parent 6d76acc0bc
commit 27af6a0953
54 changed files with 485 additions and 684 deletions

View File

@@ -66,18 +66,18 @@ const showFile = (file) => {
<style scoped>
.documentListItem {
display:block;
display: block;
width: 15vw;
aspect-ratio: 1 / 1.414;
padding:1em;
padding: 1em;
margin: 0.7em;
border: 1px solid lightgrey;
border-radius: 15px;
transition: box-shadow 0.2s ease; /* für smooth hover */
}
.documentListItem:hover {
border: 1px solid #69c350;
cursor: pointer;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* sanfter Shadow beim Hover */
}
.previewEmbed {

View File

@@ -1,7 +1,6 @@
<script setup>
const toast = useToast()
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const modal = useModal()
const props = defineProps({
@@ -27,7 +26,7 @@ const filetypes = ref([])
const documentboxes = ref([])
const setup = async () => {
const {data} = await supabase.from("folders").select().eq("tenant",useProfileStore().currentTenant)
const data = await useEntities("folders").select()
data.forEach(folder => {
let name = folder.name
@@ -55,20 +54,12 @@ const setup = async () => {
}
})
filetypes.value = await useSupabaseSelect("filetags")
documentboxes.value = await useSupabaseSelect("documentboxes")
filetypes.value = await useEntities("filetags").select()
documentboxes.value = await useEntities("documentboxes").select()
}
setup()
//Functions
const openDocument = async () => {
//selectedDocument.value = doc
openShowModal.value = true
console.log("open")
}
const updateDocument = async () => {
const {url, ...objData} = props.documentData
delete objData.url
@@ -91,12 +82,7 @@ const updateDocument = async () => {
console.log(objData)
const {data,error} = await supabase
.from("files")
.update(objData)
.eq('id',objData.id)
.select()
const {data,error} = await useEntities("files").update(objData.id, objData)
if(error) {
console.log(error)
@@ -114,13 +100,6 @@ const archiveDocument = async () => {
props.documentData.archived = true
await updateDocument()
const {data,error} = await supabase.from("historyitems").insert({
createdBy: useProfileStore().activeProfile.id,
tenant: useProfileStore().currentTenant,
text: "Datei archiviert",
file: props.documentData.id
})
modal.close()
emit("update")
}
@@ -139,19 +118,19 @@ const itemOptions = ref([])
const idToAssign = ref(null)
const getItemsBySelectedResource = async () => {
if(resourceToAssign.value === "project") {
itemOptions.value = await useSupabaseSelect("projects")
itemOptions.value = await useEntities("projects").select()
} else if(resourceToAssign.value === "customer") {
itemOptions.value = await useSupabaseSelect("customers")
itemOptions.value = await useEntities("customers").select()
} else if(resourceToAssign.value === "vendor") {
itemOptions.value = await useSupabaseSelect("vendors")
itemOptions.value = await useEntities("vendors").select()
} else if(resourceToAssign.value === "vehicle") {
itemOptions.value = await useSupabaseSelect("vehicles")
itemOptions.value = await useEntities("vehicles").select()
} else if(resourceToAssign.value === "product") {
itemOptions.value = await useSupabaseSelect("products")
itemOptions.value = await useEntities("products").select()
} else if(resourceToAssign.value === "plant") {
itemOptions.value = await useSupabaseSelect("plants")
itemOptions.value = await useEntities("plants").select()
} else if(resourceToAssign.value === "contract") {
itemOptions.value = await useSupabaseSelect("contracts")
itemOptions.value = await useEntities("contracts").select()
} else {
itemOptions.value = []
}
@@ -165,20 +144,9 @@ const updateDocumentAssignment = async () => {
const folderToMoveTo = ref(null)
const moveFile = async () => {
console.log(folderToMoveTo.value)
const {data,error} = await supabase
.from("files")
.update({folder: folderToMoveTo.value})
.eq("id",props.documentData.id)
.select()
if(error) {
console.log(error)
toast.add({title: "Fehler beim verschieben", color:"rose"})
} else {
toast.add({title: "Datei verschoben"})
console.log(data)
}
const res = await useEntities("files").update(props.documentData.id, {folder: folderToMoveTo.value})
modal.close()
}

View File

@@ -18,7 +18,7 @@ const uploadInProgress = ref(false)
const availableFiletypes = ref([])
const setup = async () => {
availableFiletypes.value = await useSupabaseSelect("filetags")
availableFiletypes.value = await useEntities("filetags").select()
}
setup()

View File

@@ -18,9 +18,17 @@ const props = defineProps({
},
platform: {
required: true,
},
loading: {
required: true,
type: Boolean,
default: false
}
})
const emit = defineEmits(["sort"]);
const {type} = props
defineShortcuts({
@@ -176,9 +184,11 @@ const filteredRows = computed(() => {
/>
<EntityTable
v-else
@sort="(i) => emit('sort',i)"
:type="props.type"
:columns="columns"
:rows="filteredRows"
:loading="props.loading"
/>
</template>

View File

@@ -158,22 +158,6 @@ const onTabChange = (index) => {
v-else-if="!props.inModal && platform === 'mobile'"
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
>
<!-- <template #left>
<UButton
icon="i-heroicons-chevron-left"
variant="outline"
@click="router.back()/*router.push(`/standardEntity/${type}`)*/"
>
Zurück
</UButton>
<UButton
icon="i-heroicons-chevron-left"
variant="outline"
@click="router.push(`/standardEntity/${type}`)"
>
Übersicht
</UButton>
</template>-->
<template #toggle>
<div></div>
</template>
@@ -217,7 +201,7 @@ const onTabChange = (index) => {
/>
</div>
<!--<EntityShowSubFiles
<EntityShowSubFiles
:item="props.item"
:query-string-data="getAvailableQueryStringData()"
v-else-if="tab.label === 'Dateien'"
@@ -226,6 +210,7 @@ const onTabChange = (index) => {
@updateNeeded="emit('updateNeeded')"
:platform="platform"
/>
<!-- TODO Change Active Phase -->
<EntityShowSubPhases
:item="props.item"
:top-level-type="type"
@@ -259,16 +244,15 @@ const onTabChange = (index) => {
v-else-if="tab.label === 'Zeiten'"
:platform="platform"
/>
<EntityShowSub
:item="props.item"
:query-string-data="getAvailableQueryStringData()"
:tab-label="tab.label"
:top-level-type="type"
:type="tab.key"
v-else
:platform="platform"
/>-->
/>
</template>
</UTabs>
<UDashboardPanelContent v-else style="overflow-x: hidden;">

View File

@@ -27,8 +27,6 @@ const props = defineProps({
let type = ref("")
const dataStore = useDataStore()
const tempStore = useTempStore()
@@ -42,6 +40,7 @@ const columns = computed(() => dataType.templateColumns.filter((column) => !colu
const loaded = ref(false)
const setup = () => {
if(!props.type && props.tabLabel ) {
if(props.tabLabel === "Aufgaben") {
type.value = "tasks"

View File

@@ -61,7 +61,8 @@ const router = useRouter()
const createddocuments = ref([])
const setup = async () => {
createddocuments.value = (await useSupabaseSelect("createddocuments")).filter(i => !i.archived)
//createddocuments.value = (await useSupabaseSelect("createddocuments")).filter(i => !i.archived)
createddocuments.value = (await useEntities("createddocuments").select()).filter(i => !i.archived)
}
setup()
@@ -150,6 +151,7 @@ const selectItem = (item) => {
<span>Ausgangsbelege</span>
</template>
<Toolbar>
<!-- TODO Rendering when Screen is too small -->
<UButton
@click="invoiceDeliveryNotes"
v-if="props.topLevelType === 'projects'"

View File

@@ -31,7 +31,7 @@ const availableFiles = ref([])
const setup = async () => {
if(props.item.files) {
availableFiles.value = await files.selectSomeDocuments(props.item.files.map(i => i.id)) || []
availableFiles.value = (await files.selectSomeDocuments(props.item.files.map(i => i.id))) || []
}
}
@@ -51,12 +51,12 @@ setup()
@uploadFinished="emit('updateNeeded')"
/>
</Toolbar>
<DocumentList
:key="props.item.files.length"
:documents="availableFiles"
v-if="availableFiles.length > 0"
/>
<UAlert
v-else
icon="i-heroicons-x-mark"

View File

@@ -26,7 +26,6 @@
}
}
})
const props = defineProps({
rows: {
type: Array,
@@ -40,9 +39,16 @@
type: {
type: String,
required: true,
},
loading: {
type: Boolean,
required: true,
default: false
}
})
const emit = defineEmits(["sort"]);
const dataStore = useDataStore()
const router = useRouter()
@@ -50,12 +56,20 @@
const dataType = dataStore.dataTypes[props.type]
const selectedItem = ref(0)
const sort = ref({
column: dataType.supabaseSortColumn || "date",
direction: 'desc'
})
</script>
<template>
<UTable
:loading="props.loading"
:loading-state="{ icon: 'i-heroicons-arrow-path-20-solid', label: 'Loading...' }"
sort-mode="manual"
v-model:sort="sort"
@update:sort="emit('sort',{sort_column: sort.column, sort_direction: sort.direction})"
v-if="dataType && columns"
:rows="props.rows"
:columns="props.columns"
@@ -64,11 +78,11 @@
@select="(i) => router.push(`/standardEntity/${type}/show/${i.id}`) "
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: `Keine ${dataType.label} anzuzeigen` }"
>
<template
<!-- <template
v-for="column in dataType.templateColumns.filter(i => !i.disabledInTable)"
v-slot:[`${column.key}-header`]="{row}">
<span class="text-nowrap">{{column.label}}</span>
</template>
</template>-->
<template #name-data="{row}">
<span
v-if="row.id === props.rows[selectedItem].id"

View File

@@ -7,7 +7,7 @@ const {has} = usePermission()
const links = computed(() => {
return [
...auth.profile.pinned_on_navigation.map(pin => {
...(auth.profile?.pinned_on_navigation || []).map(pin => {
if(pin.type === "external") {
return {
label: pin.label,
@@ -92,7 +92,7 @@ const links = computed(() => {
label: "E-Mail",
to: "/email/new",
icon: "i-heroicons-envelope"
}, {
}/*, {
label: "Logbücher",
to: "/communication/historyItems",
icon: "i-heroicons-book-open"
@@ -100,7 +100,7 @@ const links = computed(() => {
label: "Chats",
to: "/chats",
icon: "i-heroicons-chat-bubble-left"
}
}*/
]
},
... (has("customers") || has("vendors") || has("contacts")) ? [{
@@ -152,7 +152,7 @@ const links = computed(() => {
},
]
},
... true ? [{
... [{
label: "Buchhaltung",
defaultOpen: false,
icon: "i-heroicons-chart-bar-square",
@@ -188,7 +188,7 @@ const links = computed(() => {
icon: "i-heroicons-document-text"
},
]
},] : [],
}],
... has("inventory") ? [{
label: "Lager",
icon: "i-heroicons-puzzle-piece",
@@ -345,11 +345,14 @@ const links = computed(() => {
<UButton
:variant="item.pinned ? 'ghost' : 'ghost'"
:color="(item.to && route.path === item.to) || (item.children?.some(c => route.path.includes(c.to))) ? 'primary' : (item.pinned ? 'amber' : 'gray')"
:icon="item.icon"
:icon="item.pinned ? 'i-heroicons-star' : item.icon"
class="w-full"
:to="item.to"
:target="item.target"
>
<UIcon
v-if="item.pinned"
:name="item.icon" class="w-5 h-5 me-2" />
{{ item.label }}
<template v-if="item.children" #trailing>
@@ -363,7 +366,7 @@ const links = computed(() => {
</template>
<template #item="{ item }">
<div class="flex flex-col">
<div class="flex flex-col" v-if="item.children?.length > 0">
<UButton
v-for="child in item.children"
:key="child.label"
@@ -379,55 +382,5 @@ const links = computed(() => {
</div>
</template>
</UAccordion>
<!-- <div
v-for="item in links"
>
<UAccordion
v-if="item.children"
:items="[item]"
>
<template #default="{item,index,open}">
<UButton
variant="ghost"
:color="item.children.find(i => route.path.includes(i.to)) ? 'primary' : 'gray'"
:icon="item.icon"
>
{{item.label}}
<template #trailing>
<UIcon
name="i-heroicons-chevron-right-20-solid"
class="w-5 h-5 ms-auto transform transition-transform duration-200"
:class="[open && 'rotate-90']"
/>
</template>
</UButton>
</template>
<template #item="{item, open}">
<div class="flex flex-col">
<UButton
variant="ghost"
:color="child.to === route.path ? 'primary' : 'gray'"
:icon="child.icon"
v-for="child in item.children"
class="ml-4"
:to="child.to"
:target="child.target"
>
{{child.label}}
</UButton>
</div>
</template>
</UAccordion>
<UButton
v-else
variant="ghost"
:color="item.to === route.path ? 'primary' : 'gray'"
class="w-full"
:icon="item.icon"
:to="item.to"
>
{{item.label}}
</UButton>
</div>-->
</template>

View File

@@ -13,7 +13,7 @@ const props = defineProps({
const incomingInvoices = ref({})
const setupPage = async () => {
incomingInvoices.value = (await supabase.from("incominginvoices").select().eq("tenant", profileStore.currentTenant)).data.filter(i => i.accounts.find(x => x.costCentre === props.item.id))
incomingInvoices.value = (await useEntities("incominginvoices").select()).filter(i => i.accounts.find(x => x.costCentre === props.item.id))
}
setupPage()

View File

@@ -7,9 +7,9 @@ let unallocatedStatements = ref(0)
let bankaccounts = ref([])
const setupPage = async () => {
let bankstatements = (await useSupabaseSelect("bankstatements","*, statementallocations(*)","date",true)).filter(i => !i.archived)
let bankstatements = (await useEntities("bankstatements").select("*, statementallocations(*)","date",true)).filter(i => !i.archived)
unallocatedStatements.value = bankstatements.filter(i => Number(calculateOpenSum(i)) !== 0).length
bankaccounts.value = await useSupabaseSelect("bankaccounts")
bankaccounts.value = await useEntities("bankaccounts").select()
}
setupPage()

View File

@@ -4,21 +4,20 @@ import dayjs from "dayjs";
dayjs.extend(customParseFormat)
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
let incomeData = ref({})
let expenseData = ref({})
const setup = async () => {
let incomeRawData = (await supabase.from("createddocuments").select().eq("tenant",profileStore.currentTenant).eq("state","Gebucht").in('type',['invoices','advanceInvoices','cancellationInvoices'])).data
//let incomeRawData = (await supabase.from("createddocuments").select().eq("tenant",profileStore.currentTenant).eq("state","Gebucht").in('type',['invoices','advanceInvoices','cancellationInvoices'])).data
let incomeRawData = (await useEntities("createddocuments").select()).filter(i => i.state === "Gebucht" && ['invoices','advanceInvoices','cancellationInvoices'].includes(i.type))
console.log(incomeRawData)
let incomeRawFilteredData = incomeRawData.filter(x => x.state === 'Gebucht' && incomeRawData.find(i => i.linkedDocument && i.linkedDocument.id === x.id && i.type === 'cancellationInvoices') && ['invoices','advanceInvoices'].includes(row.type))
let expenseRawData =(await supabase.from("incominginvoices").select().eq("tenant",profileStore.currentTenant)).data
let withoutInvoiceRawData = (await supabase.from("statementallocations").select().eq("tenant",profileStore.currentTenant).not("account","is",null)).data
//let expenseRawData =(await supabase.from("incominginvoices").select().eq("tenant",profileStore.currentTenant)).data
let expenseRawData =(await useEntities("incominginvoices").select())
//let withoutInvoiceRawData = (await supabase.from("statementallocations").select().eq("tenant",profileStore.currentTenant).not("account","is",null)).data
let withoutInvoiceRawData = (await useEntities("statementallocations").select()).filter(i => i.account)
let withoutInvoiceRawDataExpenses = []
let withoutInvoiceRawDataIncomes = []

View File

@@ -3,7 +3,6 @@
import dayjs from "dayjs";
const profileStore = useProfileStore();
const supabase = useSupabaseClient()
let unpaidInvoicesSum = ref(0)
let unpaidInvoicesCount = ref(0)
@@ -15,7 +14,7 @@ let draftInvoicesCount = ref(0)
let countPreparedOpenIncomingInvoices = ref(0)
const setupPage = async () => {
let items = (await useSupabaseSelect("createddocuments","*, statementallocations(*), customer(id,name), linkedDocument(*)")).filter(i => !i.archived)
let items = (await useEntities("createddocuments").select("*, statementallocations(*), customer(id,name), linkedDocument(*)")).filter(i => !i.archived)
let documents = items.filter(i => i.type === "invoices" ||i.type === "advanceInvoices")
let draftDocuments = documents.filter(i => i.state === "Entwurf")

View File

@@ -1,12 +1,12 @@
<script setup>
const openTasks = ref([])
const supabase = useSupabaseClient()
const router = useRouter()
const auth = useAuthStore()
const setupPage = async () => {
openTasks.value = (await supabase.from("tasks").select().eq("tenant",useProfileStore().currentTenant).not("archived","is",true).neq("categorie","Abgeschlossen").eq("profile", useProfileStore().activeProfile.id)).data
//TODO: BACKEND CHANGE Migrate to auth_users for profile
openTasks.value = (await useEntities("tasks").select().filter(i => !i.archived && i.user_id === auth.user.id))
}
setupPage()

View File

@@ -3,7 +3,7 @@
const phasesCounter = ref({})
const setupPage = async () => {
const projects = (await useSupabaseSelect("projects")).filter(i => !i.archived)
const projects = (await useEntities("projects").select()).filter(i => !i.archived)
projects.forEach(project => {
if(project.phases && project.phases.length > 0){

View File

@@ -14,7 +14,7 @@ export const useEntities = (
const select = async (
select: string = "*",
sortColumn: string | null = null,
ascending: boolean = true,
ascending: boolean = false,
noArchivedFiltering: boolean = false
) => {
@@ -23,7 +23,7 @@ export const useEntities = (
params: {
select,
sort: sortColumn || undefined,
asc: ascending ? "true" : "false"
asc: ascending
}
})
@@ -43,7 +43,7 @@ export const useEntities = (
) => {
if (!idToEq) return null
const res = await useNuxtApp().$api(`/api/resource/${relation}/${idToEq}/${withInformation}`, {
const res = await useNuxtApp().$api(withInformation ? `/api/resource/${relation}/${idToEq}/${withInformation}` : `/api/resource/${relation}/${idToEq}`, {
method: "GET",
params: { select }
})

View File

@@ -1,211 +0,0 @@
export const useFiles = () => {
const supabase = useSupabaseClient()
const toast = useToast()
let bucket = "filesdev"
const profileStore = useProfileStore()
const uploadFiles = async (formData, files,tags, upsert) => {
const uploadSingleFile = async (file) => {
//Create File Entry to Get ID for Folder
const {data:createdFileData,error:createdFileError} = await supabase
.from("files")
.insert({
tenant: profileStore.currentTenant,
})
.select()
.single()
if(createdFileError){
console.log(createdFileError)
toast.add({title: "Hochladen fehlgeschlagen", icon: "i-heroicons-x-circle", color: "rose", timeout: 10000})
} else if(createdFileData) {
//Upload File to ID Folder
const {data:uploadData, error: uploadError} = await supabase
.storage
.from(bucket)
.upload(`${profileStore.currentTenant}/filesbyid/${createdFileData.id}/${file.name}`, file, {upsert: upsert})
if(uploadError) {
console.log(uploadError)
console.log(uploadError.statusCode)
if(uploadError.statusCode === '400') {
console.log("is 400")
toast.add({title: "Hochladen fehlgeschlagen", description: "Die Datei enthält ungültige Zeichen", icon: "i-heroicons-x-circle", color: "rose", timeout: 10000})
} else if(uploadError.statusCode === '409') {
console.log("is 409")
toast.add({title: "Hochladen fehlgeschlagen", description: "Es existiert bereits eine Datei mit diesem Namen", icon: "i-heroicons-x-circle", color: "rose", timeout: 10000})
} else {
toast.add({title: "Hochladen fehlgeschlagen", icon: "i-heroicons-x-circle", color: "rose", timeout: 10000})
}
} else if(uploadData) {
//Update File with Corresponding Path
const {data:updateFileData, error:updateFileError} = await supabase
.from("files")
.update({
...formData,
path: uploadData.path,
})
.eq("id", createdFileData.id)
if(updateFileError) {
console.log(updateFileError)
toast.add({title: "Hochladen fehlgeschlagen", icon: "i-heroicons-x-circle", color: "rose", timeout: 10000})
} else {
const {data:tagData, error:tagError} = await supabase
.from("filetagmembers")
.insert(tags.map(tag => {
return {
file_id: createdFileData.id,
tag_id: tag
}
}))
toast.add({title: "Hochladen erfolgreich"})
}
}
}
}
if(files.length === 1) {
await uploadSingleFile(files[0])
} else if( files.length > 1) {
for(let i = 0; i < files.length; i++){
await uploadSingleFile(files[i])
}
}
}
const selectDocuments = async (sortColumn = null, folder = null) => {
let data = []
if(sortColumn !== null ) {
data = (await supabase
.from("files")
.select('*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.eq("tenant", profileStore.currentTenant)
.not("path","is",null)
.not("archived","is",true)
.order(sortColumn, {ascending: true})).data
} else {
data = (await supabase
.from("files")
.select('*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.eq("tenant", profileStore.currentTenant)
.not("path","is",null)
.not("archived","is",true)).data
}
if(data.length > 0){
let paths = []
data.forEach(doc => {
paths.push(doc.path)
})
const {data: supabaseData,error} = await supabase.storage.from(bucket).createSignedUrls(paths,3600)
data = data.map((doc,index) => {
return {
...doc,
url: supabaseData[index].signedUrl
}
})
}
return data
}
const selectSomeDocuments = async (documentIds, sortColumn = null, folder = null) => {
let data = null
if(sortColumn !== null ) {
data = (await supabase
.from("files")
.select('*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.in("id",documentIds)
.eq("tenant", profileStore.currentTenant)
.not("path","is",null)
.not("archived","is",true)
.order(sortColumn, {ascending: true})).data
} else {
data = (await supabase
.from("files")
.select('*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*, customer(*), contact(*)), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.in("id",documentIds)
.not("path","is",null)
.not("archived","is",true)
.eq("tenant", profileStore.currentTenant)).data
}
if(data.length > 0){
let paths = []
data.forEach(doc => {
paths.push(doc.path)
})
const {data: supabaseData,error} = await supabase.storage.from(bucket).createSignedUrls(paths,3600)
data = data.map((doc,index) => {
return {
...doc,
url: supabaseData[index].signedUrl
}
})
}
//console.log(data)
return data
}
const selectDocument = async (id) => {
const {data,error} = await supabase
.from("files")
.select('*')
.eq("id",id)
.single()
const {data: supabaseData,error:supabaseError} = await supabase.storage.from(bucket).createSignedUrl(data.path,3600)
return {
...data,
url: supabaseData.signedUrl
}
/*
if(data.length > 0){
let paths = []
data.forEach(doc => {
paths.push(doc.path)
})
const {data: supabaseData,error} = await supabase.storage.from(bucket).createSignedUrls(paths,3600)
data = data.map((doc,index) => {
return {
...doc,
url: supabaseData[index].signedUrl
}
})
}
//console.log(data)
return data[0]*/
}
return {uploadFiles, selectDocuments, selectSomeDocuments, selectDocument}
}

142
composables/useFiles.ts Normal file
View File

@@ -0,0 +1,142 @@
export const useFiles = () => {
const supabase = useSupabaseClient()
const toast = useToast()
const auth = useAuthStore()
let bucket = "filesdev"
const uploadFiles = async (fileData, files,tags, upsert) => {
const uploadSingleFile = async (file) => {
//Create File Entry to Get ID for Folder
const formData = new FormData()
formData.append("file", file)
formData.append("meta", JSON.stringify(fileData))
const {fileReturn} = await useNuxtApp().$api("/api/files/upload",{
method: "POST",
body: formData
})
}
if(files.length === 1) {
await uploadSingleFile(files[0])
} else if( files.length > 1) {
for(let i = 0; i < files.length; i++){
await uploadSingleFile(files[i])
}
}
}
const selectDocuments = async (sortColumn = null, folder = null) => {
let data = []
data = await useEntities("files").select("*, incominginvoice(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)")
const res = await useNuxtApp().$api("/api/files/presigned",{
method: "POST",
body: {
ids: data.map(i => i.id)
}
})
console.log(res)
return res.files
}
const selectSomeDocuments = async (documentIds, sortColumn = null, folder = null) => {
if(documentIds.length === 0) return []
const res = await useNuxtApp().$api("/api/files/presigned",{
method: "POST",
body: {
ids: documentIds
}
})
console.log(res)
return res.files
}
const selectDocument = async (id) => {
const {data,error} = await supabase
.from("files")
.select('*')
.eq("id",id)
.single()
const {data: supabaseData,error:supabaseError} = await supabase.storage.from(bucket).createSignedUrl(data.path,3600)
return {
...data,
url: supabaseData.signedUrl
}
/*
if(data.length > 0){
let paths = []
data.forEach(doc => {
paths.push(doc.path)
})
const {data: supabaseData,error} = await supabase.storage.from(bucket).createSignedUrls(paths,3600)
data = data.map((doc,index) => {
return {
...doc,
url: supabaseData[index].signedUrl
}
})
}
//console.log(data)
return data[0]*/
}
const downloadFile = async (id?: string, ids?: string[]) => {
const url = id ? `/api/files/download/${id}` : `/api/files/download`
const body = ids ? { ids } : undefined
const res:any = await useNuxtApp().$api.raw(url, {
method: "POST",
body,
responseType: "blob", // wichtig!
})
// Dateiname bestimmen
let filename = "download"
if (id) {
// Einzeldatei → nimm den letzten Teil des Pfads aus Content-Disposition
const contentDisposition = res.headers?.get("content-disposition")
if (contentDisposition) {
const match = contentDisposition.match(/filename="?([^"]+)"?/)
if (match) filename = match[1]
}
} else {
filename = "dateien.zip"
}
// Direkt speichern
const blob = res._data as Blob
const link = document.createElement("a")
link.href = URL.createObjectURL(blob)
link.download = filename
link.click()
URL.revokeObjectURL(link.href)
}
return {uploadFiles, selectDocuments, selectSomeDocuments, selectDocument, downloadFile}
}

View File

@@ -3,10 +3,6 @@
import dayjs from "dayjs";
import {useSupabaseSelect} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
//console.log(searchinput)

View File

@@ -1,9 +1,7 @@
<script setup>
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const route = useRoute()
const supabase = useSupabaseClient()

View File

@@ -2,10 +2,6 @@
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
//console.log(searchinput)

View File

@@ -3,9 +3,7 @@
import dayjs from "dayjs";
import {filter} from "vuedraggable/dist/vuedraggable.common.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {

View File

@@ -7,15 +7,12 @@ import resourceTimelinePlugin from "@fullcalendar/resource-timeline";
import interactionPlugin from "@fullcalendar/interaction";
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
//TODO BACKEND CHANGE COLOR IN TENANT FOR RENDERING
//Config
const route = useRoute()
const router = useRouter()
const mode = ref(route.params.mode || "grid")
const supabase = useSupabaseClient()
const dataStore = useDataStore()
const profileStore = useProfileStore()
@@ -130,13 +127,13 @@ const calendarOptionsTimeline = ref({
const loaded = ref(false)
const setupPage = async () => {
let tempData = (await useSupabaseSelect("events", "*")).filter(i => !i.archived)
let absencerequests = (await useSupabaseSelect("absencerequests", "*, profile(*)")).filter(i => !i.archived)
let projects = (await useSupabaseSelect("projects", "*")).filter(i => !i.archived)
let inventoryitems = (await useSupabaseSelect("inventoryitems", "*")).filter(i => !i.archived)
let inventoryitemgroups = (await useSupabaseSelect("inventoryitemgroups", "*")).filter(i => !i.archived)
let profiles = (await useSupabaseSelect("profiles", "*")).filter(i => !i.archived)
let vehicles = (await useSupabaseSelect("vehicles", "*")).filter(i => !i.archived)
let tempData = (await useEntities("events").select()).filter(i => !i.archived)
let absencerequests = (await useEntities("absencerequests").select("*, profile(*)")).filter(i => !i.archived)
let projects = (await useEntities("projects").select( "*")).filter(i => !i.archived)
let inventoryitems = (await useEntities("inventoryitems").select()).filter(i => !i.archived)
let inventoryitemgroups = (await useEntities("inventoryitemgroups").select()).filter(i => !i.archived)
let profiles = (await useEntities("profiles").select()).filter(i => !i.archived)
let vehicles = (await useEntities("vehicles").select()).filter(i => !i.archived)
calendarOptionsGrid.value.initialEvents = [
...tempData.map(event => {

View File

@@ -1,7 +1,5 @@
<script setup>
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {

View File

@@ -2,9 +2,7 @@
import { format, isToday } from 'date-fns'
import dayjs from "dayjs"
definePageMeta({
middleware: "auth"
})
defineShortcuts({
' ': () => {

View File

@@ -2,9 +2,7 @@
import dayjs from "dayjs";
import {useSupabaseSelectSingle} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {

View File

@@ -8,9 +8,7 @@
<script setup>
import EntityList from "~/components/EntityList.vue";
definePageMeta({
middleware: "auth"
})
const items = ref([])

View File

@@ -13,9 +13,7 @@ const supabase = useSupabaseClient()
const modal = useModal()
definePageMeta({
middleware: "auth"
})
const itemInfo = ref({
@@ -84,23 +82,23 @@ const loaded = ref(false)
const setupPage = async () => {
letterheads.value = (await useSupabaseSelect("letterheads","*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type))
createddocuments.value = (await useSupabaseSelect("createddocuments","*"))
projects.value = (await useSupabaseSelect("projects","*"))
plants.value = (await useSupabaseSelect("plants","*"))
services.value = (await useSupabaseSelect("services","*"))
servicecategories.value = (await useSupabaseSelect("servicecategories","*"))
products.value = (await useSupabaseSelect("products","*"))
productcategories.value = (await useSupabaseSelect("productcategories","*"))
customers.value = (await useSupabaseSelect("customers","*","customerNumber"))
contacts.value = (await useSupabaseSelect("contacts","*"))
texttemplates.value = (await useSupabaseSelect("texttemplates","*"))
letterheads.value = (await useEntities("letterheads").select("*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type))
createddocuments.value = await useEntities("createddocuments").select("*")
projects.value = await useEntities("projects").select("*")
plants.value = await useEntities("plants").select("*")
services.value = await useEntities("services").select("*")
servicecategories.value = await useEntities("servicecategories").select("*")
products.value = await useEntities("products").select("*")
productcategories.value = await useEntities("productcategories").select("*")
customers.value = await useEntities("customers").select("*","customerNumber")
contacts.value = await useEntities("contacts").select("*")
texttemplates.value = await useEntities("texttemplactes").select("*")
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
if(servicecategories.value.length > 0) selectedServicecategorie.value = servicecategories.value[0].id
if(route.params) {
if(route.params.id) {
itemInfo.value = await useSupabaseSelectSingle("createddocuments", route.params.id)
itemInfo.value = await useEntities("createddocuments").selectSingle(route.params.id)
checkCompatibilityWithInputPrice()
}
@@ -213,7 +211,7 @@ const setupPage = async () => {
setCustomerData()
for await (const doc of linkedDocuments.filter(i => i.type === "confirmationOrders")) {
let linkedDocument = await useSupabaseSelectSingle("createddocuments",doc.id)
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
itemInfo.value.rows.push({
mode: "title",
@@ -224,7 +222,7 @@ const setupPage = async () => {
}
for await (const doc of linkedDocuments.filter(i => i.type === "quotes")) {
let linkedDocument = await useSupabaseSelectSingle("createddocuments",doc.id)
let linkedDocument = await useEntities("createddocuments").selectSingle(doc.id)
itemInfo.value.rows.push({
mode: "title",
@@ -277,8 +275,7 @@ const setupPage = async () => {
if(route.query.linkedDocument) {
itemInfo.value.linkedDocument = route.query.linkedDocument
let linkedDocument = await useSupabaseSelectSingle("createddocuments",itemInfo.value.linkedDocument)
let linkedDocument = await useEntities("createddocuments").selectSingle(itemInfo.value.linkedDocument)
if(route.query.optionsToImport) {
//Import only true
@@ -361,7 +358,7 @@ const setupPage = async () => {
if(route.query.project) {
itemInfo.value.project = Number(route.query.project)
let project = await useSupabaseSelectSingle("projects",itemInfo.value.project)
let project = await useEntities("projects").selectSingle(itemInfo.value.project)
if(!itemInfo.value.description){
itemInfo.value.description = project.customerRef
@@ -389,21 +386,6 @@ const setupPage = async () => {
}
setupPage()
const openAdvanceInvoices = ref([])
const checkForOpenAdvanceInvoices = async () => {
console.log("Check for Open Advance Invoices")
const {data} = await supabase.from("createddocuments").select().eq("project", itemInfo.value.project).eq("advanceInvoiceResolved", false).eq("type","advanceInvoices")
const {data: usedAdvanceInvoices} = await supabase.from("createddocuments").select().in("id", itemInfo.value.usedAdvanceInvoices)
console.log(data)
openAdvanceInvoices.value = [...data, ...usedAdvanceInvoices.filter(i => !data.find(x => x.id === i.id))]
}
const addAdvanceInvoiceToInvoice = (advanceInvoice) => {
itemInfo.value.usedAdvanceInvoices.push(advanceInvoice)
}
const setDocumentTypeConfig = (withTexts = false) => {
if(itemInfo.value.type === "invoices" ||itemInfo.value.type === "advanceInvoices" || itemInfo.value.type === "serialInvoices"|| itemInfo.value.type === "cancellationInvoices") {
@@ -467,7 +449,7 @@ const setCustomerData = async (customerId, loadOnlyAdress = false) => {
itemInfo.value.customer = customerId
}
customers.value = await useSupabaseSelect("customers")
customers.value = await useEntities("customers").select()
let customer = customers.value.find(i => i.id === itemInfo.value.customer)
@@ -496,7 +478,7 @@ const setCustomerData = async (customerId, loadOnlyAdress = false) => {
}
const setContactPersonData = async () => {
//console.log(itemInfo.value.contactPerson)
//console.log(itemInfo.value.contactPerson) //TODO Set Profile
let profile = await useSupabaseSelectSingle("profiles",itemInfo.value.contactPerson, '*')
itemInfo.value.contactPersonName = profile.fullName
@@ -1187,32 +1169,9 @@ const uri = ref("")
const generateDocument = async () => {
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
/*const {data,error} = await supabase.functions.invoke('create_pdf',{
body: {
invoiceData: getDocumentData(),
backgroundPath: path,
returnMode: "base64"
}
})*/
uri.value = await useFunctions().useCreatePDF(getDocumentData(), path)
//const {data,error} = await supabase.storage.from("files").download(path)
//console.log(data)
//console.log(error)
//console.log(JSON.stringify(getDocumentData()))
//uri.value = `data:${data.mimeType};base64,${data.base64}`
//uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer())
//alert(uri.value)
showDocument.value = true
//console.log(uri.value)
}
const onChangeTab = (index) => {
@@ -1454,12 +1413,12 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
console.log("Set Row Data")
if(service && service.id) {
row.service = service.id
services.value = await useSupabaseSelect("services","*")
services.value = await useEntities("services").select("*")
}
if(product && product.id) {
row.product = product.id
product.value = await useSupabaseSelect("products","*")
product.value = await useEntities("products").select("*")
}
if(row.service) {

View File

@@ -165,10 +165,6 @@
<script setup>
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
//console.log(searchinput)
@@ -208,7 +204,8 @@ const items = ref([])
const selectedItem = ref(0)
const setupPage = async () => {
items.value = (await useSupabaseSelect("createddocuments","*, customer(id,name), statementallocations(id,amount),linkedDocument(*)","documentNumber")).filter(i => !i.archived)
//items.value = (await useSupabaseSelect("createddocuments","*, customer(id,name), statementallocations(id,amount),linkedDocument(*)","documentNumber")).filter(i => !i.archived)
items.value = (await useEntities("createddocuments").select("*, customer(id,name), statementallocations(id,amount),linkedDocument(*)","documentNumber")).filter(i => !i.archived)
}
setupPage()

View File

@@ -126,7 +126,8 @@ const items = ref([])
const selectedItem = ref(0)
const setupPage = async () => {
items.value = await useSupabaseSelect("createddocuments","*, customer(id,name)","documentDate")
//items.value = await useSupabaseSelect("createddocuments","*, customer(id,name)","documentDate")
items.value = await useEntities("createddocuments").select("*, customer(id,name)","documentDate")
}
const searchString = ref("")

View File

@@ -1,9 +1,7 @@
<script setup>
import CopyCreatedDocumentModal from "~/components/copyCreatedDocumentModal.vue";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {

View File

@@ -2,23 +2,14 @@
import {BlobReader, BlobWriter, ZipWriter} from "@zip.js/zip.js";
import {useSupabaseSelectSingle} from "~/composables/useSupabase.js";
import DocumentDisplayModal from "~/components/DocumentDisplayModal.vue";
import DocumentUploadModal from "~/components/DocumentUploadModal.vue";
import dayjs from "dayjs";
import arraySort from "array-sort";
import {useTempStore} from "~/stores/temp.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
/*'/': () => {
//console.log(searchinput)
//searchinput.value.focus()
document.getElementById("searchinput").focus()
},*/
'+': () => {
//Hochladen
uploadModalOpen.value = true
@@ -30,9 +21,10 @@ defineShortcuts({
if(entry.type === "file") {
showFile(entry.id)
console.log(entry)
} else {
} else if(createFolderModalOpen.value === false && entry.type === "folder") {
changeFolder(currentFolders.value.find(i => i.id === entry.id))
} else if(createFolderModalOpen.value === true) {
createFolder()
}
}
@@ -55,13 +47,11 @@ defineShortcuts({
const dataStore = useDataStore()
const tempStore = useTempStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()
const router = useRouter()
const route = useRoute()
const modal = useModal()
dataStore.fetchDocuments()
const auth = useAuthStore()
const uploadModalOpen = ref(false)
const createFolderModalOpen = ref(false)
@@ -69,7 +59,7 @@ const uploadInProgress = ref(false)
const fileUploadFormData = ref({
tags: ["Eingang"],
path: "",
tenant: profileStore.currentTenant,
tenant: auth.activeTenant,
folder: null
})
@@ -92,15 +82,16 @@ const isDragTarget = ref(false)
const loaded = ref(false)
const setupPage = async () => {
folders.value = await useSupabaseSelect("folders")
folders.value = await useEntities("folders").select()
documents.value = await files.selectDocuments()
filetags.value = await useSupabaseSelect("filetags")
filetags.value = await useEntities("filetags").select()
if(route.query) {
if(route.query.folder) {
currentFolder.value = await useSupabaseSelectSingle("folders", route.query.folder)
currentFolder.value = await useEntities("folders").selectSingle(route.query.folder)
}
}
@@ -118,7 +109,6 @@ const setupPage = async () => {
}
dropZone.ondrop = async function (event) {
console.log("files dropped")
event.preventDefault()
}
@@ -213,13 +203,9 @@ const changeFolder = async (newFolder) => {
const createFolderData = ref({})
const createFolder = async () => {
const {data,error} = await supabase
.from("folders")
.insert({
tenant: profileStore.currentTenant,
const res = await useEntities("folders").create({
parent: currentFolder.value ? currentFolder.value.id : undefined,
name: createFolderData.value.name,
})
createFolderModalOpen.value = false
@@ -229,61 +215,14 @@ const createFolder = async () => {
}
const downloadSelected = async () => {
const bucket = "filesdev";
let files = []
files = filteredDocuments.value.filter(i => selectedFiles.value[i.id] === true).map(i => i.path)
// If there are no files in the folder, throw an error
if (!files || !files.length) {
throw new Error("No files to download");
}
const promises = [];
await useFiles().downloadFile(undefined,Object.keys(selectedFiles.value))
// Download each file in the folder
files.forEach((file) => {
promises.push(
supabase.storage.from(bucket).download(`${file}`)
);
});
// Wait for all the files to download
const response = await Promise.allSettled(promises);
// Map the response to an array of objects containing the file name and blob
const downloadedFiles = response.map((result, index) => {
if (result.status === "fulfilled") {
return {
name: files[index].split("/")[files[index].split("/").length -1],
blob: result.value.data,
};
}
});
// Create a new zip file
const zipFileWriter = new BlobWriter("application/zip");
const zipWriter = new ZipWriter(zipFileWriter, { bufferedWrite: true });
// Add each file to the zip file
downloadedFiles.forEach((downloadedFile) => {
if (downloadedFile) {
zipWriter.add(downloadedFile.name, new BlobReader(downloadedFile.blob));
}
});
// Download the zip file
const url = URL.createObjectURL(await zipWriter.close());
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", "dateien.zip");
document.body.appendChild(link);
link.click();
}
const searchString = ref(tempStore.searchStrings["files"] ||'')
@@ -295,7 +234,6 @@ const renderedFileList = computed(() => {
type: "file"
}
})
console.log(currentFolders.value)
arraySort(files, (a,b) => {
let aVal = a.path ? a.path.split("/")[a.path.split("/").length -1] : null
@@ -338,7 +276,6 @@ const renderedFileList = computed(() => {
const selectedFileIndex = ref(0)
const showFile = (fileId) => {
console.log(fileId)
modal.open(DocumentDisplayModal,{
documentData: documents.value.find(i => i.id === fileId),
onUpdatedNeeded: setupPage()
@@ -413,7 +350,10 @@ const clearSearchString = () => {
</USelectMenu>
<UButton @click="modal.open(DocumentUploadModal,{fileData: {folder: currentFolder.id, type: currentFolder.standardFiletype, typeEnabled: currentFolder.standardFiletypeIsOptional}, onUploadFinished: () => {setupPage()}})">+ Datei</UButton>
<UButton
:disabled="!currentFolder"
@click="modal.open(DocumentUploadModal,{fileData: {folder: currentFolder.id, type: currentFolder.standardFiletype, typeEnabled: currentFolder.standardFiletypeIsOptional}, onUploadFinished: () => {setupPage()}})"
>+ Datei</UButton>
<UButton
@click="createFolderModalOpen = true"
variant="outline"

View File

@@ -4,9 +4,7 @@ import dayjs from "dayjs";
import HistoryDisplay from "~/components/HistoryDisplay.vue";
import {useSupabaseSelect} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()

View File

@@ -4,9 +4,7 @@ import dayjs from "dayjs";
import HistoryDisplay from "~/components/HistoryDisplay.vue";
import {useSupabaseSelect} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()

View File

@@ -1,9 +1,7 @@
<script setup>
import dayjs from "dayjs"
import {useSum} from "~/composables/useSum.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
@@ -44,9 +42,14 @@ const sum = useSum()
const items = ref([])
const selectedItem = ref(0)
const sort = ref({
column: 'date',
direction: 'desc'
})
const setupPage = async () => {
items.value = await useSupabaseSelect("incominginvoices","*, vendor(id,name), statementallocations(id,amount)","created_at",false)
//items.value = await useSupabaseSelect("incominginvoices","*, vendor(id,name), statementallocations(id,amount)","created_at",false)
items.value = await useEntities("incominginvoices").select("*, vendor(id,name), statementallocations(id,amount)",sort.value.column,sort.value.direction === "asc")
}
setupPage()
@@ -54,26 +57,29 @@ setupPage()
const templateColumns = [
{
key: 'reference',
label: "Referenz:"
label: "Referenz:",
sortable: true,
}, {
key: 'state',
label: "Status:"
},
{
key: "date",
label: "Datum"
label: "Datum",
sortable: true,
},
{
key: "vendor",
label: "Lieferant"
label: "Lieferant",
},
{
key: "amount",
label: "Betrag"
label: "Betrag",
},
{
key: "dueDate",
label: "Fälligkeitsdatum"
label: "Fälligkeitsdatum",
sortable: true,
},
{
key: "paid",
@@ -81,7 +87,8 @@ const templateColumns = [
},
{
key: "paymentType",
label: "Zahlart"
label: "Zahlart",
sortable: true,
},
{
key: "description",
@@ -92,6 +99,7 @@ const selectedColumns = ref(templateColumns)
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
const searchString = ref(tempStore.searchStrings['incominginvoices'] ||'')
const clearSearchString = () => {
@@ -185,6 +193,9 @@ const selectIncomingInvoice = (invoice) => {
<UDashboardPanelContent>
<UTable
v-model:sort="sort"
sort-mode="manual"
@update:sort="setupPage"
:rows="filteredRows"
:columns="columns"
class="w-full"

View File

@@ -1,9 +1,7 @@
<script setup>
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()

View File

@@ -1,13 +1,13 @@
<template>
<!-- <UDashboardNavbar title="Home">
<UDashboardNavbar title="Home">
<template #right>
<UTooltip text="Notifications" :shortcuts="['N']">
<!-- <UTooltip text="Notifications" :shortcuts="['N']">
<UButton color="gray" variant="ghost" square @click="isNotificationsSlideoverOpen = true">
<UChip :show="unreadMessages" color="primary" inset>
<UIcon name="i-heroicons-bell" class="w-5 h-5" />
</UChip>
</UButton>
</UTooltip>
</UTooltip>-->
</template>
</UDashboardNavbar>
@@ -23,13 +23,11 @@
<UPageGrid>
<UDashboardCard
title="Buchhaltung"
v-if="profileStore.ownTenant.features.accounting"
>
<display-open-balances/>
</UDashboardCard>
<UDashboardCard
title="Bank"
v-if="profileStore.ownTenant.features.accounting"
>
<display-bankaccounts/>
</UDashboardCard>
@@ -38,7 +36,7 @@
>
<display-projects-in-phases/>
</UDashboardCard>
<UDashboardCard
<!--<UDashboardCard
title="Anwesende"
>
<display-present-profiles/>
@@ -52,14 +50,14 @@
title="Anwesenheiten"
>
<display-running-working-time/>
</UDashboardCard>
</UDashboardCard>-->
<UDashboardCard
title="Aufgaben"
>
<display-open-tasks/>
</UDashboardCard>
</UPageGrid>
</UDashboardPanelContent>-->
</UDashboardPanelContent>
</template>
<script setup>

View File

@@ -1,7 +1,5 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()

View File

@@ -63,9 +63,7 @@
<script setup>
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {

View File

@@ -2,9 +2,7 @@
import { v4 as uuidv4 } from 'uuid';
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {

View File

@@ -1,7 +1,5 @@
<script setup>
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {

View File

@@ -4,9 +4,7 @@ import DocumentList from "~/components/DocumentList.vue";
import DocumentUpload from "~/components/DocumentUpload.vue";
import {useSupabaseSelect} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {

View File

@@ -1,7 +1,5 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const items = ref([])
const setup = async () => {

View File

@@ -1,7 +1,5 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()
const supabase = useSupabaseClient()

View File

@@ -48,9 +48,7 @@
<script setup>
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {

View File

@@ -1,7 +1,5 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const supabase = useSupabaseClient()
const dataStore = useDataStore()

View File

@@ -22,7 +22,10 @@ const mode = ref("list")
const items = ref([])
const item = ref({})
const setupPage = async () => {
const setupPage = async (sort_column = null,sort_direction = null) => {
loaded.value = false
if(await useCapacitor().getIsPhone()) {
setPageLayout("mobile")
@@ -32,23 +35,18 @@ const setupPage = async () => {
if(mode.value === "show") {
//Load Data for Show
//item.value = await useSupabaseSelectSingle(type, route.params.id, dataType.supabaseSelectWithInformation || "*")
item.value = await useEntities(type).selectSingle(route.params.id,"*",true)
} else if(mode.value === "edit") {
//Load Data for Edit
//const data = JSON.stringify((await supabase.from(type).select().eq("id", route.params.id).single()).data)
//await useSupabaseSelectSingle(type, route.params.id)
item.value = JSON.stringify(await useEntities(type).selectSingle(route.params.id))
//item.value = data
} else if(mode.value === "create") {
//Load Data for Create
item.value = JSON.stringify({})
console.log(item.value)
} else if(mode.value === "list") {
//Load Data for List
items.value = await useEntities(type).select()
items.value = await useEntities(type).select(dataType.supabaseSelectWithInformation, sort_column || dataType.supabaseSortColumn , sort_direction === "asc")
}
loaded.value = true
@@ -68,17 +66,19 @@ setupPage()
:platform="platform"
/>
<EntityEdit
v-else-if="loaded && (mode === 'edit' || mode === 'create')"
v-else-if="(mode === 'edit' || mode === 'create')"
:type="route.params.type"
:item="item"
:mode="mode"
:platform="platform"
/>
<EntityList
v-else-if="loaded && mode === 'list'"
:loading="!loaded"
v-else-if="mode === 'list'"
:type="type"
:items="items"
:platform="platform"
@sort="(i) => setupPage(i.sort_column, i.sort_direction)"
/>
<UProgress
v-else

15
pages/test.vue Normal file
View File

@@ -0,0 +1,15 @@
<script setup lang="ts">
async function handleSingle() {
await useFiles().downloadFile("f60e8466-7136-4492-ad94-a60603bc3c38") // Einzel-Download
}
async function handleMulti() {
await useFiles().downloadFile(undefined, ["f60e8466-7136-4492-ad94-a60603bc3c38", "f60e8466-7136-4492-ad94-a60603bc3c38"]) // Multi-Download ZIP
}
</script>
<template>
<button @click="handleSingle">Einzeldatei</button>
<button @click="handleMulti">Mehrere als ZIP</button>
</template>

View File

@@ -5,9 +5,7 @@ import '@vuepic/vue-datepicker/dist/main.css'
import {setPageLayout} from "#app";
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()

View File

@@ -4,9 +4,7 @@ import {useSupabaseSelectSingle} from "~/composables/useSupabase.js";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'backspace': () => {

View File

@@ -67,9 +67,7 @@
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {

View File

@@ -7,9 +7,7 @@ import FloatingActionButton from "~/components/mobile/FloatingActionButton.vue";
dayjs.extend(customParseFormat)
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const profileStore = useProfileStore()

View File

@@ -92,14 +92,16 @@ export const useDataStore = defineStore('data', () => {
key: "created_at",
label: "Erstellt am",
component: created_at,
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: "name",
label: "Name",
title: true,
required: true,
inputType: "text",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: "categorie",
label: "Kategorie",
@@ -111,7 +113,8 @@ export const useDataStore = defineStore('data', () => {
{label:"In Bearbeitung"},
{label:"Abgeschlossen"}
],
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: "profile",
label: "Mitarbeiter",
@@ -191,7 +194,8 @@ export const useDataStore = defineStore('data', () => {
label: "Kundennummer",
inputIsNumberRange: true,
inputType: "text",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
}, {
key: "isCompany",
label: "Firmenkunde",
@@ -210,7 +214,8 @@ export const useDataStore = defineStore('data', () => {
showFunction: function (item) {
return item.isCompany
},
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
}, {
key: "nameAddition",
label: "Firmenname Zusatz",
@@ -247,7 +252,8 @@ export const useDataStore = defineStore('data', () => {
showFunction: function (item) {
return !item.isCompany
},
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: "title",
label: "Titel",
@@ -333,17 +339,20 @@ export const useDataStore = defineStore('data', () => {
label: "Aktiv",
component: active,
inputType: "bool",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
}, {
key: "customPaymentDays",
label: "Zahlungsziel in Tagen",
inputType: "number",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
}, {
key: "customSurchargePercentage",
label: "Individueller Aufschlag",
inputType: "number",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
}, {
key: "infoData.street",
label: "Straße + Hausnummer",
@@ -368,14 +377,16 @@ export const useDataStore = defineStore('data', () => {
}
},
disabledInTable: true,
inputColumn: "Kontaktdaten"
inputColumn: "Kontaktdaten",
sortable: true
},
{
key: "infoData.city",
label: "Stadt",
inputType: "text",
disabledInTable: true,
inputColumn: "Kontaktdaten"
inputColumn: "Kontaktdaten",
sortable: true
},
{
key: "infoData.country",
@@ -385,7 +396,8 @@ export const useDataStore = defineStore('data', () => {
selectOptionAttribute: "name",
selectValueAttribute: "name",
disabledInTable: true,
inputColumn: "Kontaktdaten"
inputColumn: "Kontaktdaten",
sortable: true
},
{
key: "address",
@@ -467,13 +479,15 @@ export const useDataStore = defineStore('data', () => {
key: "fullName",
label: "Name",
title: true,
sortable: true
},{
key: "salutation",
label: "Anrede",
inputType: "text",
inputChangeFunction: function (row) {
row.fullName = `${row.firstName} ${row.lastName}`
}
},
sortable: true
},{
key: "title",
label: "Titel",
@@ -501,7 +515,8 @@ export const useDataStore = defineStore('data', () => {
key: "active",
label: "Aktiv",
component: active,
inputType: "bool"
inputType: "bool",
sortable: true
},
{
key: "customer",
@@ -549,6 +564,7 @@ export const useDataStore = defineStore('data', () => {
key: "birthday",
label: "Geburtstag",
inputType: "date",
sortable: true
},
{
key: "notes",
@@ -591,7 +607,8 @@ export const useDataStore = defineStore('data', () => {
label: "Vertragsnummer",
inputIsNumberRange: true,
inputType: "text",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},
{
key: "name",
@@ -599,19 +616,22 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
title: true,
inputType: "text",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: "active",
label: "Aktiv",
component: active,
inputType: "bool",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: "recurring",
label: "Wiederkehrend",
component: recurring,
inputType: "bool",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: 'customer',
label: "Kunde",
@@ -645,7 +665,8 @@ export const useDataStore = defineStore('data', () => {
{label:'36 Monate'},
{label:'48 Monate'},
],
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},{
key: 'invoiceDispatch',
label: "Rechnungsversand",
@@ -655,7 +676,8 @@ export const useDataStore = defineStore('data', () => {
{label:'E-Mail'},
{label:'Post'}
],
inputColumn: "Abrechnung"
inputColumn: "Abrechnung",
sortable: true
},{
key: 'paymentType',
label: "Zahlungsart",
@@ -671,19 +693,22 @@ export const useDataStore = defineStore('data', () => {
label: "Vertragsstart",
inputType: "date",
inputColumn: "Allgemeines",
component: startDate
component: startDate,
sortable: true
},{
key: 'endDate',
label: "Vertragsende",
inputType: "date",
inputColumn: "Allgemeines",
component: endDate
component: endDate,
sortable: true
},{
key: 'signDate',
label: "Unterschrieben am",
inputType: "date",
inputColumn: "Allgemeines",
component: signDate
component: signDate,
sortable: true
},{
key: 'sepaDate',
label: "SEPA Datum",
@@ -798,13 +823,15 @@ export const useDataStore = defineStore('data', () => {
required: true,
label: "Start",
inputType: "date",
component: startDate
component: startDate,
sortable: true
},{
key: "endDate",
required: true,
label: "Ende",
inputType: "date",
component: endDate
component: endDate,
sortable: true
},{
key: "note",
label: "Notizen",
@@ -820,6 +847,7 @@ export const useDataStore = defineStore('data', () => {
isStandardEntity: true,
redirect:true,
historyItemHolder: "plant",
supabaseSortColumn:"name",
supabaseSelectWithInformation: "*, customer(id,name)",
filters: [{
name: "Archivierte ausblenden",
@@ -838,7 +866,8 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
required: true,
inputType: "text",
title: true
title: true,
sortable: true
},
{
key: "customer",
@@ -1027,7 +1056,8 @@ export const useDataStore = defineStore('data', () => {
templateColumns: [
{
key: "projectNumber",
label: "Projektnummer"
label: "Projektnummer",
sortable: true
},
{
key: "projecttype",
@@ -1040,7 +1070,8 @@ export const useDataStore = defineStore('data', () => {
selectSearchAttributes: ['name'],
inputChangeFunction: function (item,loadedOptions = {}) {
item.phases = loadedOptions.projecttypes.find(i => i.id === item.projecttype).initialPhases
}
},
sortable: true
},{
key: "phase",
label: "Phase",
@@ -1050,7 +1081,8 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
required: true,
title: true,
inputType: "text"
inputType: "text",
sortable: true
},
{
key: "customer",
@@ -1129,6 +1161,7 @@ export const useDataStore = defineStore('data', () => {
isStandardEntity: true,
redirect:true,
historyItemHolder: "vehicle",
supabaseSortColumn:"licensePlate",
supabaseSelectWithInformation: "*, checks(*), files(*)",
filters:[{
name: "Archivierte ausblenden",
@@ -1146,13 +1179,15 @@ export const useDataStore = defineStore('data', () => {
key: 'active',
label: "Aktiv",
component: active,
inputType: "bool"
inputType: "bool",
sortable: true
},{
key: 'licensePlate',
label: "Kennzeichen",
required: true,
inputType: "text",
title: true
title: true,
sortable: true
},{
key: 'vin',
label: "Identifikationnummer",
@@ -1186,7 +1221,8 @@ export const useDataStore = defineStore('data', () => {
key: "towingCapacity",
label: "Anhängelast",
unit: "Kg",
inputType: "number"
inputType: "number",
sortable: true
},
{
key: "color",
@@ -1197,7 +1233,8 @@ export const useDataStore = defineStore('data', () => {
key: "powerInKW",
label: "Leistung",
unit: "kW",
inputType: "number"
inputType: "number",
sortable: true
},
/*{
key: "profiles",
@@ -1252,14 +1289,16 @@ export const useDataStore = defineStore('data', () => {
key: 'vendorNumber',
label: "Lieferantennummer",
inputType: "text",
inputIsNumberRange: true
inputIsNumberRange: true,
sortable: true
},
{
key: "name",
required: true,
label: "Name",
title: true,
inputType: "text"
inputType: "text",
sortable: true
},
{
key: "infoData.streetNumber",
@@ -1404,14 +1443,16 @@ export const useDataStore = defineStore('data', () => {
inputType: "text",
required: true,
title: true,
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},
{
key: 'spaceNumber',
label: "Lagerplatznr.",
inputType: "text",
inputIsNumberRange: true,
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},
{
key: "type",
@@ -1426,7 +1467,8 @@ export const useDataStore = defineStore('data', () => {
{label:"Palettenplatz"},
{label:"Sonstiges"}
],
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},
{
key: "parentSpace",
@@ -1509,6 +1551,18 @@ export const useDataStore = defineStore('data', () => {
labelSingle: "Dokument",
supabaseSelectWithInformation: "*, files(*), statementallocations(*)",
},
files: {
isArchivable: true,
label: "Dateien",
labelSingle: "Datei",
supabaseSelectWithInformation: "*",
},
folders: {
isArchivable: true,
label: "Ordner",
labelSingle: "Ordner",
supabaseSelectWithInformation: "*",
},
incominginvoices: {
label: "Eingangsrechnungen",
labelSingle: "Eingangsrechnung",
@@ -1545,19 +1599,22 @@ export const useDataStore = defineStore('data', () => {
title: true,
required: true,
inputType: "text",
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},
{
key: "usePlanning",
label: "In Plantafel anzeigen",
inputType: "bool",
inputColumn: "Allgemeines",
component: usePlanning
component: usePlanning,
sortable: true
},
{
key: "description",
label: "Beschreibung",
inputType: "textarea",
sortable: true
},
{
key: "currentSpace",
@@ -1574,7 +1631,8 @@ export const useDataStore = defineStore('data', () => {
label: "Artikelnummer",
inputType: "text",
inputIsNumberRange: true,
inputColumn: "Allgemeines"
inputColumn: "Allgemeines",
sortable: true
},
{
key: "serialNumber",
@@ -1586,7 +1644,8 @@ export const useDataStore = defineStore('data', () => {
key: "purchaseDate",
label: "Kaufdatum",
inputType: "date",
inputColumn: "Anschaffung"
inputColumn: "Anschaffung",
sortable: true
},
{
key: "vendor",
@@ -1606,14 +1665,16 @@ export const useDataStore = defineStore('data', () => {
disabledFunction: function (item) {
return item.serialNumber
},
helpComponent: quantity
helpComponent: quantity,
sortable: true
},
{
key: "purchasePrice",
label: "Kaufpreis",
inputType: "number",
inputStepSize: "0.01",
inputColumn: "Anschaffung"
inputColumn: "Anschaffung",
sortable: true
},
{
key: "manufacturer",
@@ -1643,7 +1704,8 @@ export const useDataStore = defineStore('data', () => {
label: "Aktueller Wert",
inputType: "number",
inputStepSize: "0.01",
inputColumn: "Anschaffung"
inputColumn: "Anschaffung",
sortable: true
},
],
@@ -1681,6 +1743,7 @@ export const useDataStore = defineStore('data', () => {
title: true,
required: true,
inputType: "text",
sortable: true
},
{
key: "description",
@@ -1810,7 +1873,8 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
required: true,
title: true,
inputType: "text"
inputType: "text",
sortable: true
},
{
key: "unit",
@@ -1943,19 +2007,22 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
required: true,
title: true,
inputType: "text"
inputType: "text",
sortable: true
},
{
key: "purchasePrice",
label: "Einkauspreis",
inputType: "number",
component: purchasePrice,
sortable: true
},
{
key: "sellingPrice",
label: "Verkaufspreis",
inputType: "number",
component: sellingPrice,
sortable: true
},
],
showTabs: [
@@ -1989,21 +2056,24 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
required: true,
title: true,
inputType: "text"
inputType: "text",
sortable: true
},
{
key: "startDate",
label: "Start",
required: true,
inputType: "datetime",
component: startDateTime
component: startDateTime,
sortable: true
},
{
key: "endDate",
label: "Ende",
required: true,
inputType: "datetime",
component: endDateTime
component: endDateTime,
sortable: true
},/*{
key: "eventtype",
label: "Typ",
@@ -2118,6 +2188,7 @@ export const useDataStore = defineStore('data', () => {
labelSingle: "Artikelkategorie",
isStandardEntity: true,
redirect: true,
supabaseSortColumn: "name",
supabaseSelectWithInformation: "*",
filters: [{
name: "Archivierte ausblenden",
@@ -2136,7 +2207,8 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
required: true,
title: true,
inputType: "text"
inputType: "text",
sortable: true
},
{
key: "description",
@@ -2156,6 +2228,7 @@ export const useDataStore = defineStore('data', () => {
labelSingle: "Leistungskategorie",
isStandardEntity: true,
redirect: true,
supabaseSortColumn: "name",
supabaseSelectWithInformation: "*",
filters: [{
name: "Archivierte ausblenden",
@@ -2174,7 +2247,8 @@ export const useDataStore = defineStore('data', () => {
label: "Name",
required: true,
title: true,
inputType: "text"
inputType: "text",
sortable: true
},
{
key: "description",
@@ -2307,13 +2381,15 @@ export const useDataStore = defineStore('data', () => {
key: 'number',
label: "Nummer",
inputIsNumberRange: true,
inputType: "text"
inputType: "text",
sortable: true
}, {
key: "name",
label: "Name",
required: true,
title: true,
inputType: "text",
sortable: true
},
{
key: "description",
@@ -2384,13 +2460,15 @@ export const useDataStore = defineStore('data', () => {
{
key: 'number',
label: "Nummer",
inputType: "text"
inputType: "text",
sortable: true
}, {
key: "name",
label: "Name",
required: true,
title: true,
inputType: "text",
sortable: true
},
{
key: "description",