api resource refactoring part 2

This commit is contained in:
Peter Papp
2021-08-27 10:05:20 +02:00
parent e0e060e5a1
commit 174f2a2c1f
7 changed files with 61 additions and 24 deletions
@@ -174,15 +174,13 @@
},
dragFinish(data, event) {
if (event.dataTransfer.items.length == 0) {
if (event.dataTransfer.items.length === 0) {
// Prevent to drop on file or image
if (data.data.type !== 'folder' || this.draggingId === data) return
//Prevent move selected folder to folder if in beteewn selected folders
if (this.clipboard.find(item => item === data && this.clipboard.length > 1)) return
// Move folder to new parent
//Move item if is not included in selected items
if (!this.clipboard.includes(this.draggingId)) {
this.$store.dispatch('moveItem', {to_item: data, noSelectedItem: this.draggingId})
@@ -1,9 +1,9 @@
<template>
<div v-if="canBePreview" class="preview">
<img v-if="clipboard[0].type == 'image' && clipboard[0].thumbnail" :src="clipboard[0].thumbnail" :alt="clipboard[0].name" />
<audio v-else-if="clipboard[0].type == 'audio'" :src="clipboard[0].file_url" controlsList="nodownload" controls></audio>
<video v-else-if="clipboard[0].type == 'video'" controlsList="nodownload" disablePictureInPicture playsinline controls>
<source :src="clipboard[0].file_url" type="video/mp4">
<img v-if="singleFile.data.type === 'image' && singleFile.data.attributes.thumbnail" :src="singleFile.data.attributes.thumbnail" :alt="singleFile.data.attributes.name" />
<audio v-else-if="singleFile.data.type === 'audio'" :src="singleFile.data.attributes.file_url" controlsList="nodownload" controls></audio>
<video v-else-if="singleFile.data.type === 'video'" controlsList="nodownload" disablePictureInPicture playsinline controls>
<source :src="singleFile.data.attributes.file_url" type="video/mp4">
</video>
</div>
</template>
@@ -15,11 +15,16 @@
export default {
name: 'FilePreview',
computed: {
...mapGetters(['clipboard']),
...mapGetters([
'clipboard'
]),
singleFile() {
return this.clipboard[0]
},
canBePreview() {
return this.clipboard[0] && ! includes([
return this.singleFile && ! includes([
'folder', 'file'
], this.clipboard[0].type)
], this.singleFile.data.type)
}
},
}