fix: drop to itself (close #33

)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
pull/739/head
Henrique Dias 2019-01-06 12:01:23 +00:00
parent 7a6397af22
commit 0e7d4ef110
6 changed files with 19 additions and 14 deletions

View File

@ -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'))
}

View File

@ -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 })
}

View File

@ -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
})
}

View File

@ -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
})
}

View File

@ -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
})
}

View File

@ -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 {