fix: drop to itself (close #33
) License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>pull/739/head
parent
7a6397af22
commit
0e7d4ef110
|
@ -116,9 +116,9 @@ function moveCopy (items, copy = false) {
|
||||||
let promises = []
|
let promises = []
|
||||||
|
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
let from = removePrefix(item.from)
|
const from = removePrefix(item.from)
|
||||||
let to = encodeURIComponent(removePrefix(item.to))
|
const to = encodeURIComponent(removePrefix(item.to))
|
||||||
let url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}`
|
const url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}`
|
||||||
promises.push(resourceAction(url, 'PATCH'))
|
promises.push(resourceAction(url, 'PATCH'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,11 +242,6 @@ export default {
|
||||||
for (let item of this.$store.state.clipboard.items) {
|
for (let item of this.$store.state.clipboard.items) {
|
||||||
const from = item.from.endsWith('/') ? item.from.slice(0, -1) : item.from
|
const from = item.from.endsWith('/') ? item.from.slice(0, -1) : item.from
|
||||||
const to = this.$route.path + item.name
|
const to = this.$route.path + item.name
|
||||||
|
|
||||||
if (from === to) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
items.push({ from, to })
|
items.push({ from, to })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,17 @@ export default {
|
||||||
if (this.type === 'audio') return 'volume_up'
|
if (this.type === 'audio') return 'volume_up'
|
||||||
if (this.type === 'video') return 'movie'
|
if (this.type === 'video') return 'movie'
|
||||||
return 'insert_drive_file'
|
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: {
|
methods: {
|
||||||
|
@ -77,7 +88,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dragOver: function (event) {
|
dragOver: function (event) {
|
||||||
if (!this.isDir) return
|
if (!this.canDrop) return
|
||||||
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
let el = event.target
|
let el = event.target
|
||||||
|
@ -91,7 +102,7 @@ export default {
|
||||||
el.style.opacity = 1
|
el.style.opacity = 1
|
||||||
},
|
},
|
||||||
drop: function (event) {
|
drop: function (event) {
|
||||||
if (!this.isDir) return
|
if (!this.canDrop) return
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
if (this.selectedCount === 0) return
|
if (this.selectedCount === 0) return
|
||||||
|
@ -101,7 +112,7 @@ export default {
|
||||||
for (let i of this.selected) {
|
for (let i of this.selected) {
|
||||||
items.push({
|
items.push({
|
||||||
from: this.req.items[i].url,
|
from: this.req.items[i].url,
|
||||||
to: this.url + encodeURIComponent(this.req.items[i].name)
|
to: this.url + this.req.items[i].name
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default {
|
||||||
for (let item of this.selected) {
|
for (let item of this.selected) {
|
||||||
items.push({
|
items.push({
|
||||||
from: this.req.items[item].url,
|
from: this.req.items[item].url,
|
||||||
to: this.dest + encodeURIComponent(this.req.items[item].name)
|
to: this.dest + this.req.items[item].name
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ export default {
|
||||||
for (let item of this.selected) {
|
for (let item of this.selected) {
|
||||||
items.push({
|
items.push({
|
||||||
from: this.req.items[item].url,
|
from: this.req.items[item].url,
|
||||||
to: this.dest + encodeURIComponent(this.req.items[item].name)
|
to: this.dest + this.req.items[item].name
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ export default {
|
||||||
oldLink = this.req.items[this.selected[0]].url
|
oldLink = this.req.items[this.selected[0]].url
|
||||||
}
|
}
|
||||||
|
|
||||||
this.name = encodeURIComponent(this.name)
|
|
||||||
newLink = url.removeLastDir(oldLink) + '/' + this.name
|
newLink = url.removeLastDir(oldLink) + '/' + this.name
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue