Added File Moving
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
const toast = useToast()
|
||||
const supabase = useSupabaseClient()
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
const modal = useModal()
|
||||
const props = defineProps({
|
||||
documentData: {
|
||||
@@ -17,15 +15,45 @@ const props = defineProps({
|
||||
},
|
||||
returnEmit: {
|
||||
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
|
||||
@@ -42,7 +70,6 @@ const updateDocument = async () => {
|
||||
delete objData.url
|
||||
delete objData.filetags
|
||||
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("files")
|
||||
.update(objData)
|
||||
@@ -55,7 +82,6 @@ const updateDocument = async () => {
|
||||
toast.add({title: "Datei aktualisiert"})
|
||||
//openShowModal.value = false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const archiveDocument = () => {
|
||||
@@ -101,6 +127,22 @@ const updateDocumentAssignment = async () => {
|
||||
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>
|
||||
|
||||
<template>
|
||||
@@ -120,7 +162,7 @@ const updateDocumentAssignment = async () => {
|
||||
|
||||
</template>
|
||||
<div class="flex flex-row">
|
||||
<div class="w-1/2">
|
||||
<div class="w-1/3">
|
||||
<object
|
||||
class="bigPreview"
|
||||
:data="`${props.documentData.url}#toolbar=0&navpanes=0&scrollbar=0`"
|
||||
@@ -135,7 +177,7 @@ const updateDocumentAssignment = async () => {
|
||||
v-else
|
||||
/>
|
||||
</div>
|
||||
<div class="w-1/2 p-5">
|
||||
<div class="w-2/3 p-5">
|
||||
<UButtonGroup>
|
||||
<!-- <UButton
|
||||
@click="archiveDocument"
|
||||
@@ -152,8 +194,8 @@ const updateDocumentAssignment = async () => {
|
||||
</UButton>
|
||||
</UButtonGroup>
|
||||
|
||||
<UDivider class="my-3">Datei zuweisen</UDivider>
|
||||
|
||||
<p>Dokument zuweisen:</p>
|
||||
<UFormGroup
|
||||
label="Resource auswählen"
|
||||
>
|
||||
@@ -180,6 +222,16 @@ const updateDocumentAssignment = async () => {
|
||||
value-attribute="id"
|
||||
@change="updateDocumentAssignment"
|
||||
></USelectMenu>
|
||||
|
||||
<UDivider class="my-5">Datei verschieben</UDivider>
|
||||
|
||||
<USelectMenu
|
||||
v-model="folderToMoveTo"
|
||||
value-attribute="id"
|
||||
option-attribute="name"
|
||||
@change="moveFile"
|
||||
:options="folders"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</UCard>
|
||||
|
||||
Reference in New Issue
Block a user