diff --git a/src/api/files.js b/src/api/files.js index 9ed7b793..917e46ec 100644 --- a/src/api/files.js +++ b/src/api/files.js @@ -116,9 +116,9 @@ function moveCopy (items, copy = false) { let promises = [] for (let item of items) { - let from = removePrefix(item.from) - let to = encodeURIComponent(removePrefix(item.to)) - let url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}` + const from = removePrefix(item.from) + const to = encodeURIComponent(removePrefix(item.to)) + const url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}` promises.push(resourceAction(url, 'PATCH')) } diff --git a/src/components/files/Listing.vue b/src/components/files/Listing.vue index 9d34a533..020d6879 100644 --- a/src/components/files/Listing.vue +++ b/src/components/files/Listing.vue @@ -242,11 +242,6 @@ export default { for (let item of this.$store.state.clipboard.items) { const from = item.from.endsWith('/') ? item.from.slice(0, -1) : item.from const to = this.$route.path + item.name - - if (from === to) { - return - } - items.push({ from, to }) } diff --git a/src/components/files/ListingItem.vue b/src/components/files/ListingItem.vue index 5556666d..2cb03b2b 100644 --- a/src/components/files/ListingItem.vue +++ b/src/components/files/ListingItem.vue @@ -55,6 +55,17 @@ export default { if (this.type === 'audio') return 'volume_up' if (this.type === 'video') return 'movie' return 'insert_drive_file' + }, + canDrop () { + if (!this.isDir) return false + + for (let i of this.selected) { + if (this.req.items[i].url === this.url) { + return false + } + } + + return true } }, methods: { @@ -77,7 +88,7 @@ export default { } }, dragOver: function (event) { - if (!this.isDir) return + if (!this.canDrop) return event.preventDefault() let el = event.target @@ -91,7 +102,7 @@ export default { el.style.opacity = 1 }, drop: function (event) { - if (!this.isDir) return + if (!this.canDrop) return event.preventDefault() if (this.selectedCount === 0) return @@ -101,7 +112,7 @@ export default { for (let i of this.selected) { items.push({ from: this.req.items[i].url, - to: this.url + encodeURIComponent(this.req.items[i].name) + to: this.url + this.req.items[i].name }) } diff --git a/src/components/prompts/Copy.vue b/src/components/prompts/Copy.vue index 91471bf4..42c262bf 100644 --- a/src/components/prompts/Copy.vue +++ b/src/components/prompts/Copy.vue @@ -49,7 +49,7 @@ export default { for (let item of this.selected) { items.push({ from: this.req.items[item].url, - to: this.dest + encodeURIComponent(this.req.items[item].name) + to: this.dest + this.req.items[item].name }) } diff --git a/src/components/prompts/Move.vue b/src/components/prompts/Move.vue index c827ea48..4aa67931 100644 --- a/src/components/prompts/Move.vue +++ b/src/components/prompts/Move.vue @@ -47,7 +47,7 @@ export default { for (let item of this.selected) { items.push({ from: this.req.items[item].url, - to: this.dest + encodeURIComponent(this.req.items[item].name) + to: this.dest + this.req.items[item].name }) } diff --git a/src/components/prompts/Rename.vue b/src/components/prompts/Rename.vue index f452e8df..2c35244e 100644 --- a/src/components/prompts/Rename.vue +++ b/src/components/prompts/Rename.vue @@ -68,7 +68,6 @@ export default { oldLink = this.req.items[this.selected[0]].url } - this.name = encodeURIComponent(this.name) newLink = url.removeLastDir(oldLink) + '/' + this.name try {