Many Changes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script setup>
|
||||
import dayjs from "dayjs";
|
||||
import HistoryDisplay from "~/components/HistoryDisplay.vue";
|
||||
import DocumentUpload from "~/components/DocumentUpload.vue";
|
||||
import DocumentList from "~/components/DocumentList.vue";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
@@ -94,10 +96,7 @@ const itemInfo = ref({
|
||||
const uploadModalOpen = ref(false)
|
||||
const fileUploadFormData = ref({
|
||||
tags: ["Dokument"],
|
||||
folder: "Projekte",
|
||||
usedInResource: {
|
||||
type: "Projekt",
|
||||
}
|
||||
project: null
|
||||
})
|
||||
const tags = dataStore.getDocumentTags
|
||||
|
||||
@@ -153,39 +152,13 @@ const updateItem = async () => {
|
||||
dataStore.fetchProjects()
|
||||
}
|
||||
|
||||
const uploadFile = async () => {
|
||||
const file = document.getElementById("fileUploadInput").files[0]
|
||||
const uploadFiles = async () => {
|
||||
//uploadInProgress.value = true;
|
||||
|
||||
const {data,error} = await supabase
|
||||
.storage
|
||||
.from("documents")
|
||||
.upload(`${user.value.app_metadata.tenant}/${fileUploadFormData.value.folder}/${currentProject.id}/${file.name}`,file)
|
||||
|
||||
console.log(data)
|
||||
const returnPath = data.path
|
||||
|
||||
if(error) {
|
||||
|
||||
} else {
|
||||
console.log(returnPath)
|
||||
const files = (await supabase.storage.from('documents').list(`${user.value.app_metadata.tenant}/${fileUploadFormData.value.folder}/${currentProject.id}/`, {limit: 100, offset: 0, sortBy: { column: 'name', order: 'asc' }})).data
|
||||
console.log(files)
|
||||
const fileId = files.find(temp => returnPath.includes(temp.name)).id
|
||||
|
||||
fileUploadFormData.value.object = fileId
|
||||
fileUploadFormData.value.path = returnPath
|
||||
fileUploadFormData.value.usedInResource.id = currentProject.id
|
||||
console.log(fileUploadFormData.value)
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("documents")
|
||||
.insert([fileUploadFormData.value])
|
||||
.select()
|
||||
console.log(data)
|
||||
console.log(error)
|
||||
}
|
||||
await dataStore.uploadFiles({...fileUploadFormData.value, project: currentItem.value.id}, document.getElementById("fileUploadInput").files)
|
||||
|
||||
uploadModalOpen.value = false;
|
||||
//uploadInProgress.value = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +168,7 @@ const projectHours = () => {
|
||||
hours += Number(dayjs(item.end).diff(item.start,'hour',true).toFixed(2))
|
||||
})
|
||||
|
||||
return hours
|
||||
return hours.toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +229,7 @@ setupPage()
|
||||
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div v-else-if="item.key === 'forms'" class="space-y-3">
|
||||
<UButton
|
||||
@click="formModalOpen = true"
|
||||
@@ -308,13 +282,13 @@ setupPage()
|
||||
</template>
|
||||
</UAccordion>
|
||||
</div>
|
||||
-->
|
||||
<div v-else-if="item.key === 'documents'" class="space-y-3">
|
||||
<InputGroup>
|
||||
<UButton
|
||||
@click="uploadModalOpen = true"
|
||||
>
|
||||
Hochladen
|
||||
</UButton>
|
||||
<DocumentUpload
|
||||
type="project"
|
||||
:element-id="currentItem.id"
|
||||
/>
|
||||
<UButton
|
||||
@click="router.push(`/createDocument/edit?project=${currentItem.id}&type=quotes&customer=${currentItem.customer}`)"
|
||||
>
|
||||
@@ -327,7 +301,7 @@ setupPage()
|
||||
</UButton>
|
||||
</InputGroup>
|
||||
|
||||
<UModal
|
||||
<!-- <UModal
|
||||
v-model="uploadModalOpen"
|
||||
>
|
||||
<UCard class="p-4">
|
||||
@@ -344,14 +318,14 @@ setupPage()
|
||||
id="fileUploadInput"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<!-- <UFormGroup
|
||||
<!– <UFormGroup
|
||||
label="Name:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
v-model="fileUploadFormData.name"
|
||||
/>
|
||||
</UFormGroup>-->
|
||||
</UFormGroup>–>
|
||||
<UFormGroup
|
||||
label="Tags:"
|
||||
class="mt-3"
|
||||
@@ -364,7 +338,7 @@ setupPage()
|
||||
v-model="fileUploadFormData.tags"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<!--<UFormGroup
|
||||
<!–<UFormGroup
|
||||
label="Ordner:"
|
||||
class="mt-3"
|
||||
>
|
||||
@@ -374,27 +348,22 @@ setupPage()
|
||||
value-attribute="label"
|
||||
|
||||
/>
|
||||
</UFormGroup>-->
|
||||
</UFormGroup>–>
|
||||
|
||||
<template #footer>
|
||||
<UButton
|
||||
class="mt-3"
|
||||
@click="uploadFile"
|
||||
@click="uploadFiles"
|
||||
>Hochladen</UButton>
|
||||
</template>
|
||||
|
||||
|
||||
</UCard>
|
||||
|
||||
</UModal>
|
||||
</UModal>-->
|
||||
|
||||
<DocumentList :documents="dataStore.getDocumentsByProjectId(currentItem.id)"/>
|
||||
|
||||
<div class="documentList">
|
||||
<DocumentDisplay
|
||||
v-for="document in dataStore.getDocumentsByProjectId(currentItem.id)"
|
||||
:document="document"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="item.key === 'timetracking'" class="space-y-3">
|
||||
|
||||
Reference in New Issue
Block a user