Added File Moving

This commit is contained in:
2025-01-05 21:59:04 +01:00
parent 3a4b1a7a56
commit 639cdb4c1f
2 changed files with 63 additions and 11 deletions

View File

@@ -3,8 +3,6 @@
const toast = useToast() const toast = useToast()
const supabase = useSupabaseClient() const supabase = useSupabaseClient()
const dataStore = useDataStore() const dataStore = useDataStore()
const profileStore = useProfileStore()
const router = useRouter()
const modal = useModal() const modal = useModal()
const props = defineProps({ const props = defineProps({
documentData: { documentData: {
@@ -17,15 +15,45 @@ const props = defineProps({
}, },
returnEmit: { returnEmit: {
type: Boolean type: Boolean
} },
}) })
const emits = defineEmits("close") const folders = ref([])
const setup = async () => {
const {data} = await supabase.from("folders").select().eq("tenant",useProfileStore().currentTenant)
const showSlideover = ref(props.openShowModal) data.forEach(folder => {
let name = folder.name
console.log(folder)
const addParent = (folder) => {
console.log(folder)
name = `${folder.name} > ${name}`
if(folder.parent){
addParent(folder)
} else {
folders.value.push({
id: folder.id,
name: name,
})
}
}
if(folder.parent) {
addParent(data.find(i => i.id === folder.parent))
} else {
folders.value.push({
id: folder.id,
name: folder.name,
})
}
})
}
setup()
//Functions //Functions
@@ -42,7 +70,6 @@ const updateDocument = async () => {
delete objData.url delete objData.url
delete objData.filetags delete objData.filetags
const {data,error} = await supabase const {data,error} = await supabase
.from("files") .from("files")
.update(objData) .update(objData)
@@ -55,7 +82,6 @@ const updateDocument = async () => {
toast.add({title: "Datei aktualisiert"}) toast.add({title: "Datei aktualisiert"})
//openShowModal.value = false //openShowModal.value = false
} }
} }
const archiveDocument = () => { const archiveDocument = () => {
@@ -101,6 +127,22 @@ const updateDocumentAssignment = async () => {
await updateDocument() await updateDocument()
} }
const folderToMoveTo = ref(null)
const moveFile = async () => {
const {data,error} = await supabase
.from("files")
.update({folder: folderToMoveTo.value})
.eq("id",props.documentData.id)
if(error) {
console.log(error)
toast.add({title: "Fehler beim verschieben", color:"rose"})
} else {
toast.add({title: "Datei verschoben"})
}
modal.close()
}
</script> </script>
<template> <template>
@@ -120,7 +162,7 @@ const updateDocumentAssignment = async () => {
</template> </template>
<div class="flex flex-row"> <div class="flex flex-row">
<div class="w-1/2"> <div class="w-1/3">
<object <object
class="bigPreview" class="bigPreview"
:data="`${props.documentData.url}#toolbar=0&navpanes=0&scrollbar=0`" :data="`${props.documentData.url}#toolbar=0&navpanes=0&scrollbar=0`"
@@ -135,7 +177,7 @@ const updateDocumentAssignment = async () => {
v-else v-else
/> />
</div> </div>
<div class="w-1/2 p-5"> <div class="w-2/3 p-5">
<UButtonGroup> <UButtonGroup>
<!-- <UButton <!-- <UButton
@click="archiveDocument" @click="archiveDocument"
@@ -152,8 +194,8 @@ const updateDocumentAssignment = async () => {
</UButton> </UButton>
</UButtonGroup> </UButtonGroup>
<UDivider class="my-3">Datei zuweisen</UDivider>
<p>Dokument zuweisen:</p>
<UFormGroup <UFormGroup
label="Resource auswählen" label="Resource auswählen"
> >
@@ -180,6 +222,16 @@ const updateDocumentAssignment = async () => {
value-attribute="id" value-attribute="id"
@change="updateDocumentAssignment" @change="updateDocumentAssignment"
></USelectMenu> ></USelectMenu>
<UDivider class="my-5">Datei verschieben</UDivider>
<USelectMenu
v-model="folderToMoveTo"
value-attribute="id"
option-attribute="name"
@change="moveFile"
:options="folders"
/>
</div> </div>
</div> </div>
</UCard> </UCard>

View File

@@ -408,7 +408,7 @@ const showFile = (fileId) => {
</thead> </thead>
<tr v-for="(entry,index) in renderedFileList"> <tr v-for="(entry,index) in renderedFileList">
<td> <td>
<UIcon :name="entry.type === 'folder' ? 'i-heroicons-folder' : 'i-heroicons-document'"/> <UIcon class="mr-1" :name="entry.type === 'folder' ? 'i-heroicons-folder' : 'i-heroicons-document'"/>
<a <a
:class="[...index === selectedFileIndex ? ['text-primary'] : ['dark:text-white','text-black']]" :class="[...index === selectedFileIndex ? ['text-primary'] : ['dark:text-white','text-black']]"
@click="entry.type === 'folder' ? changeFolder(currentFolders.find(i => i.id === entry.id)) : showFile(entry.id)" @click="entry.type === 'folder' ? changeFolder(currentFolders.find(i => i.id === entry.id)) : showFile(entry.id)"