Updated in Files and Archiving

This commit is contained in:
2025-01-07 12:42:00 +01:00
parent af38afc5b5
commit 0bab558c75
5 changed files with 151 additions and 286 deletions

View File

@@ -18,6 +18,7 @@ const {color,variant} = props
const showModal = ref(false) const showModal = ref(false)
const emitConfirm = () => { const emitConfirm = () => {
showModal.value = false
emit('confirmed') emit('confirmed')
} }
</script> </script>
@@ -38,19 +39,22 @@ const emitConfirm = () => {
<slot/> <slot/>
<template #footer> <template #footer>
<div class="text-right"> <div class="text-right">
<UButton <UButtonGroup>
color="rose" <UButton
variant="outline" color="rose"
@click="showModal = false" variant="outline"
> @click="showModal = false"
Abbrechen >
</UButton> Abbrechen
<UButton </UButton>
@click="emitConfirm" <UButton
class="ml-2" @click="emitConfirm"
> class="ml-2"
Bestätigen >
</UButton> Bestätigen
</UButton>
</UButtonGroup>
</div> </div>
</template> </template>
</UCard> </UCard>

View File

@@ -1,8 +1,11 @@
<script setup> <script setup>
import DocumentDisplayModal from "~/components/DocumentDisplayModal.vue";
const toast = useToast() const toast = useToast()
const supabase = useSupabaseClient() const supabase = useSupabaseClient()
const dataStore = useDataStore() const dataStore = useDataStore()
const modal = useModal()
const profileStore = useProfileStore() const profileStore = useProfileStore()
const router = useRouter() const router = useRouter()
const props = defineProps({ const props = defineProps({
@@ -20,89 +23,22 @@ const props = defineProps({
}) })
let {documentData, openShowModal:openShowModalProp, returnEmit } = props; let {documentData, returnEmit } = props;
const tags = dataStore.getDocumentTags
const openShowModal = ref(false)
const showFile = (file) => {
console.log(file)
//Functions modal.open(DocumentDisplayModal,{
const openDocument = async () => { documentData: file
//selectedDocument.value = doc })
openShowModal.value = true
console.log("open")
} }
const updateDocument = async () => {
console.log("Update")
const {url, ...objData} = documentData
delete objData.url
const {data,error} = await supabase
.from("documents")
.update(objData)
.eq('id',objData.id)
.select()
if(error) {
console.log(error)
} else {
toast.add({title: "Dokument aktualisiert"})
//openShowModal.value = false
}
}
const archiveDocument = () => {
//documentData.tags.push("Archiviert")
//updateDocument()
}
const resourceOptions = ref([
{label: 'Projekt', value: 'project', optionAttr: "name"},
{label: 'Kunde', value: 'customer', optionAttr: "name"},
{label: 'Lieferant', value: 'vendor', optionAttr: "name"},
{label: 'Fahrzeug', value: 'vehicle', optionAttr: "licensePlate"},
{label: 'Objekt', value: 'plant', optionAttr: "name"},
{label: 'Vertrag', value: 'contract', optionAttr: "name"},
{label: 'Produkt', value: 'product', optionAttr: "name"}
])
const resourceToAssign = ref("project")
const itemOptions = ref([])
const idToAssign = ref(null)
const getItemsBySelectedResource = () => {
if(resourceToAssign.value === "project") {
itemOptions.value = dataStore.projects
} else if(resourceToAssign.value === "customer") {
itemOptions.value = dataStore.customers
} else if(resourceToAssign.value === "vendor") {
itemOptions.value = dataStore.vendors
} else if(resourceToAssign.value === "vehicle") {
itemOptions.value = dataStore.vehicles
} else if(resourceToAssign.value === "product") {
itemOptions.value = dataStore.products
} else if(resourceToAssign.value === "plant") {
itemOptions.value = dataStore.plants
} else if(resourceToAssign.value === "contract") {
itemOptions.value = dataStore.contracts
} else {
itemOptions.value = []
}
}
getItemsBySelectedResource()
const updateDocumentAssignment = async () => {
documentData[resourceToAssign.value] = idToAssign.value
await updateDocument()
}
</script> </script>
<template> <template>
<div :id="`docDisplay-${documentData.id}`" class="documentListItem" @click="returnEmit ? $emit('clicked', documentData.id) : openShowModal = true"> <div :id="`docDisplay-${documentData.id}`" class="documentListItem" @click="returnEmit ? $emit('clicked', documentData.id) : showFile(documentData)">
<iframe <iframe
:src="`${documentData.url}#toolbar=0&navpanes=0&scrollbar=0`" :src="`${documentData.url}#toolbar=0&navpanes=0&scrollbar=0`"
class="previewEmbed" class="previewEmbed"
@@ -125,182 +61,7 @@ const updateDocumentAssignment = async () => {
><span class="text-nowrap">{{ tag.name }}</span></UBadge> ><span class="text-nowrap">{{ tag.name }}</span></UBadge>
</InputGroup> </InputGroup>
<!-- <UButton
@click="openDocument"
class="mt-3"
icon=""
>
<UIcon name="i-heroicons-eye-solid" />
</UButton>-->
<!-- <UToggle
v-model="documentData.selected"
class="ml-2"
/>-->
<!-- <UBadge
v-if="documentData.vendorInvoice"
>{{dataStore.incominginvoices.find(item => item.id === documentData.vendorInvoice) ? dataStore.incominginvoices.find(item => item.id === documentData.vendorInvoice).reference : ''}}</UBadge>
<UBadge
v-if="documentData.inDatev"
>DATEV</UBadge>-->
</div> </div>
<USlideover
v-model="openShowModal"
fullscreen
>
<UCard class="flex flex-col flex-1" :ui="{ body: { base: 'flex-1' }, ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }">
<template #header>
<div class="flex flex-row justify-between">
<div class="flex items-center gap-2">
<UBadge
v-for="tag in documentData.filetags"
>
{{tag.name}}
</UBadge>
</div>
<UButton color="gray" variant="ghost" icon="i-heroicons-x-mark-20-solid" class="-my-1" @click="openShowModal = false" />
</div>
</template>
<UContainer class="h-full" :ui="{padding: 'px-1 sm:px-1 lg:px-1'}">
<object
class="bigPreview"
:data="`${documentData.url}#toolbar=0&navpanes=0&scrollbar=0`"
type="application/pdf"
v-if="!documentData.filetags.includes('Bild')"
/>
<img
class=" w-full"
:src="documentData.url"
alt=""
v-else
/>
</UContainer>
<template #footer>
<UButtonGroup>
<!-- <UButton
@click="archiveDocument"
>
Archivieren
</UButton>-->
<UButton
:to="documentData.url"
variant="outline"
icon="i-heroicons-arrow-top-right-on-square"
target="_blank"
>
Öffnen
</UButton>
</UButtonGroup>
<UFormGroup
label="Tags ändern:"
>
<USelectMenu
:options="tags"
v-model="documentData.filetags"
@change="updateDocument"
multiple
>
<template #label>
{{documentData.filetags.length}} ausgewählt
</template>
</USelectMenu>
</UFormGroup>
<p>Dokument zuweisen:</p>
<UFormGroup
label="Resource auswählen"
>
<USelectMenu
:options="resourceOptions"
v-model="resourceToAssign"
value-attribute="value"
option-attribute="label"
@change="getItemsBySelectedResource"
>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Eintrag auswählen:"
>
</UFormGroup>
<USelectMenu
:options="itemOptions"
v-model="idToAssign"
:option-attribute="resourceOptions.find(i => i.value === resourceToAssign)? resourceOptions.find(i => i.value === resourceToAssign).optionAttr : 'name'"
value-attribute="id"
@change="updateDocumentAssignment"
></USelectMenu>
<!-- <UFormGroup
label="Projekt zuweisen:"
>
<USelectMenu
:options="dataStore.projects"
option-attribute="name"
value-attribute="id"
v-model="documentData.project"
@change="updateDocument"
searchable
:search-attributes="['name']"
>
<template #label>
{{dataStore.projects.find(item => item.id === documentData.project) ? dataStore.projects.find(item => item.id === documentData.project).name : "Kein Projekt ausgewählt" }}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Kunde zuweisen:"
>
<USelectMenu
:options="dataStore.customers"
option-attribute="name"
value-attribute="id"
v-model="documentData.customer"
@change="updateDocument"
searchable
:search-attributes="['name']"
>
<template #label>
{{dataStore.customers.find(item => item.id === documentData.customer) ? dataStore.customers.find(item => item.id === documentData.customer).name : "Kein Kunde ausgewählt" }}
</template>
</USelectMenu>
</UFormGroup>-->
</template>
</UCard>
<!-- <UCard class="h-full">
</UCard>-->
</USlideover>
</template> </template>
<style scoped> <style scoped>
@@ -332,13 +93,4 @@ const updateDocumentAssignment = async () => {
display: none; display: none;
} }
.bigPreview {
width: 100%;
aspect-ratio: 1/ 1.414;
}
.previewImg {
object-fit: contain;
}
</style> </style>

View File

@@ -19,6 +19,8 @@ const props = defineProps({
}) })
const emit = defineEmits(["updateNeeded"])
const folders = ref([]) const folders = ref([])
const setup = async () => { const setup = async () => {
const {data} = await supabase.from("folders").select().eq("tenant",useProfileStore().currentTenant) const {data} = await supabase.from("folders").select().eq("tenant",useProfileStore().currentTenant)
@@ -61,12 +63,23 @@ const openDocument = async () => {
} }
const updateDocument = async () => { const updateDocument = async () => {
console.log("Update")
const {url, ...objData} = props.documentData const {url, ...objData} = props.documentData
delete objData.url delete objData.url
delete objData.filetags delete objData.filetags
if(objData.project) objData.project = objData.project.id
if(objData.customer) objData.customer = objData.customer.id
if(objData.contract) objData.contract = objData.contract.id
if(objData.vendor) objData.vendor = objData.vendor.id
if(objData.plant) objData.plant = objData.plant.id
if(objData.createddocument) objData.createddocument = objData.createddocument.id
if(objData.vehicle) objData.vehicle = objData.vehicle.id
if(objData.product) objData.product = objData.product.id
if(objData.profile) objData.profile = objData.profile.id
if(objData.check) objData.check = objData.check.id
if(objData.inventoryitem) objData.inventoryitem = objData.inventoryitem.id
const {data,error} = await supabase const {data,error} = await supabase
.from("files") .from("files")
.update(objData) .update(objData)
@@ -81,9 +94,19 @@ const updateDocument = async () => {
} }
} }
const archiveDocument = () => { const archiveDocument = async () => {
//documentData.tags.push("Archiviert") props.documentData.archived = true
//updateDocument() 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")
} }
const resourceOptions = ref([ const resourceOptions = ref([
@@ -179,11 +202,20 @@ const moveFile = async () => {
</div> </div>
<div class="w-2/3 p-5"> <div class="w-2/3 p-5">
<UButtonGroup> <UButtonGroup>
<!-- <UButton <ButtonWithConfirm
@click="archiveDocument" color="rose"
> variant="outline"
Archivieren @confirmed="archiveDocument"
</UButton>--> >
<template #button>
Archivieren
</template>
<template #header>
<span class="text-md text-black font-bold">Archivieren bestätigen</span>
</template>
Möchten Sie die Datei wirklich archivieren?
</ButtonWithConfirm>
<UButton <UButton
:to="props.documentData.url" :to="props.documentData.url"
variant="outline" variant="outline"
@@ -194,6 +226,77 @@ const moveFile = async () => {
</UButton> </UButton>
</UButtonGroup> </UButtonGroup>
<UDivider>Zuweisungen</UDivider>
<table class="w-full">
<tr v-if="props.documentData.project">
<td>Projekt</td>
<td>
<nuxt-link :to="`/standardEntity/projects/show/${props.documentData.project.id}`">{{props.documentData.project.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.customer">
<td>Kunde</td>
<td>
<nuxt-link :to="`/standardEntity/customers/show/${props.documentData.customer.id}`">{{props.documentData.customer.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.vendor">
<td>Lieferant</td>
<td>
<nuxt-link :to="`/standardEntity/vendors/show/${props.documentData.vendor.id}`">{{props.documentData.vendor.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.createddocument">
<td>Ausgangsbeleg</td>
<td>
<nuxt-link :to="`/createddocuments/show/${props.documentData.createddocument.id}`">{{props.documentData.createddocument.documentNumber}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.plant">
<td>Objekt</td>
<td>
<nuxt-link :to="`/standardEntity/plants/show/${props.documentData.plant.id}`">{{props.documentData.plant.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.contract">
<td>Vertrag</td>
<td>
<nuxt-link :to="`/standardEntity/contracts/show/${props.documentData.contract.id}`">{{props.documentData.contract.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.vehicle">
<td>Fahrzeug</td>
<td>
<nuxt-link :to="`/standardEntity/vehicles/show/${props.documentData.vehicle.id}`">{{props.documentData.vehicle.licensePlate}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.product">
<td>Artikel</td>
<td>
<nuxt-link :to="`/standardEntity/products/show/${props.documentData.product.id}`">{{props.documentData.product.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.inventoryitem">
<td>Inventarartikel</td>
<td>
<nuxt-link :to="`/standardEntity/inventoryitem/show/${props.documentData.inventoryitem.id}`">{{props.documentData.inventoryitem.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.check">
<td>Überprüfung</td>
<td>
<nuxt-link :to="`/standardEntity/checks/show/${props.documentData.check.id}`">{{props.documentData.check.name}}</nuxt-link>
</td>
</tr>
<tr v-if="props.documentData.profile">
<td>Mitarbeiter</td>
<td>
<nuxt-link :to="`/profiles/show/${props.documentData.profile.id}`">{{props.documentData.profile.fullName}}</nuxt-link>
</td>
</tr>
</table>
<UDivider class="my-3">Datei zuweisen</UDivider> <UDivider class="my-3">Datei zuweisen</UDivider>
<UFormGroup <UFormGroup

View File

@@ -10,6 +10,7 @@ const props = defineProps({
}) })
const dataStore = useDataStore() const dataStore = useDataStore()
const emit = defineEmits(["updateNeeded"])
</script> </script>
@@ -21,6 +22,7 @@ const dataStore = useDataStore()
:key="item.id" :key="item.id"
@clicked="(info) => $emit('selectDocument', info)" @clicked="(info) => $emit('selectDocument', info)"
:return-emit="returnDocumentId" :return-emit="returnDocumentId"
@updatedNeeded="emit('updatedNeeded')"
/> />
</div> </div>
</template> </template>

View File

@@ -92,16 +92,18 @@ export const useFiles = () => {
if(sortColumn !== null ) { if(sortColumn !== null ) {
data = (await supabase data = (await supabase
.from("files") .from("files")
.select('*, filetags(*)') .select('*, filetags(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.eq("tenant", profileStore.currentTenant) .eq("tenant", profileStore.currentTenant)
.not("path","is",null) .not("path","is",null)
.not("archived","is",true)
.order(sortColumn, {ascending: true})).data .order(sortColumn, {ascending: true})).data
} else { } else {
data = (await supabase data = (await supabase
.from("files") .from("files")
.select('*, filetags(*)') .select('*, filetags(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.eq("tenant", profileStore.currentTenant) .eq("tenant", profileStore.currentTenant)
.not("path","is",null)).data .not("path","is",null)
.not("archived","is",true)).data
} }
@@ -133,17 +135,19 @@ export const useFiles = () => {
if(sortColumn !== null ) { if(sortColumn !== null ) {
data = (await supabase data = (await supabase
.from("files") .from("files")
.select('*, filetags(*)') .select('*, filetags(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.in("id",documentIds) .in("id",documentIds)
.eq("tenant", profileStore.currentTenant) .eq("tenant", profileStore.currentTenant)
.not("path","is",null) .not("path","is",null)
.not("archived","is",true)
.order(sortColumn, {ascending: true})).data .order(sortColumn, {ascending: true})).data
} else { } else {
data = (await supabase data = (await supabase
.from("files") .from("files")
.select('*, filetags(*)') .select('*, filetags(*), project(*), vendor(*), customer(*), contract(*), plant(*), createddocument(*), vehicle(*), product(*), profile(*), check(*), inventoryitem(*)')
.in("id",documentIds) .in("id",documentIds)
.not("path","is",null) .not("path","is",null)
.not("archived","is",true)
.eq("tenant", profileStore.currentTenant)).data .eq("tenant", profileStore.currentTenant)).data
} }