Added File Moving

This commit is contained in:
2025-01-05 22:11:42 +01:00
parent 639cdb4c1f
commit 7f23d8efd8
2 changed files with 28 additions and 18 deletions

View File

@@ -26,14 +26,11 @@ const setup = async () => {
data.forEach(folder => { data.forEach(folder => {
let name = folder.name let name = folder.name
console.log(folder) const addParent = (item) => {
name = `${item.name} > ${name}`
const addParent = (folder) => { if(item.parent){
console.log(folder) addParent(data.find(i => i.id === item.parent))
name = `${folder.name} > ${name}`
if(folder.parent){
addParent(folder)
} else { } else {
folders.value.push({ folders.value.push({
id: folder.id, id: folder.id,
@@ -129,16 +126,19 @@ const updateDocumentAssignment = async () => {
const folderToMoveTo = ref(null) const folderToMoveTo = ref(null)
const moveFile = async () => { const moveFile = async () => {
console.log(folderToMoveTo.value)
const {data,error} = await supabase const {data,error} = await supabase
.from("files") .from("files")
.update({folder: folderToMoveTo.value}) .update({folder: folderToMoveTo.value})
.eq("id",props.documentData.id) .eq("id",props.documentData.id)
.select()
if(error) { if(error) {
console.log(error) console.log(error)
toast.add({title: "Fehler beim verschieben", color:"rose"}) toast.add({title: "Fehler beim verschieben", color:"rose"})
} else { } else {
toast.add({title: "Datei verschoben"}) toast.add({title: "Datei verschoben"})
console.log(data)
} }
modal.close() modal.close()
} }
@@ -225,13 +225,21 @@ const moveFile = async () => {
<UDivider class="my-5">Datei verschieben</UDivider> <UDivider class="my-5">Datei verschieben</UDivider>
<USelectMenu <InputGroup class="w-full">
v-model="folderToMoveTo" <USelectMenu
value-attribute="id" class="flex-auto"
option-attribute="name" v-model="folderToMoveTo"
@change="moveFile" value-attribute="id"
:options="folders" option-attribute="name"
/> :options="folders"
/>
<UButton
@click="moveFile"
variant="outline"
>Verschieben</UButton>
</InputGroup>
</div> </div>
</div> </div>
</UCard> </UCard>

View File

@@ -144,7 +144,7 @@ const breadcrumbLinks = computed(() => {
const addParent = (parent) => { const addParent = (parent) => {
parents.push(parent) parents.push(parent)
if(parent.parent) { if(parent.parent) {
addParent(folders.value.find(i => i.id === currentFolder.value.parent)) addParent(folders.value.find(i => i.id === parent.parent))
} }
} }
@@ -167,7 +167,7 @@ const breadcrumbLinks = computed(() => {
}, },
icon: "i-heroicons-folder" icon: "i-heroicons-folder"
} }
}), }).reverse(),
{ {
label: currentFolder.value.name, label: currentFolder.value.name,
click: () => { click: () => {
@@ -403,8 +403,10 @@ const showFile = (fileId) => {
<div v-if="displayMode === 'list'"> <div v-if="displayMode === 'list'">
<table class="w-full"> <table class="w-full">
<thead> <thead>
<td class="font-bold">Name</td> <tr>
<td class="font-bold">Erstellt am</td> <td class="font-bold">Name</td>
<td class="font-bold">Erstellt am</td>
</tr>
</thead> </thead>
<tr v-for="(entry,index) in renderedFileList"> <tr v-for="(entry,index) in renderedFileList">
<td> <td>