Skip to content

Commit

Permalink
fix: drop to itself (close #33
Browse files Browse the repository at this point in the history
)
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
  • Loading branch information
hacdias committed Jan 6, 2019
1 parent 7a6397a commit 0e7d4ef
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/api/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
}

Expand Down
5 changes: 0 additions & 5 deletions src/components/files/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand Down
17 changes: 14 additions & 3 deletions src/components/files/ListingItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -77,7 +88,7 @@ export default {
}
},
dragOver: function (event) {
if (!this.isDir) return
if (!this.canDrop) return
event.preventDefault()
let el = event.target
Expand All @@ -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
Expand All @@ -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
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/Copy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/prompts/Move.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
Expand Down
1 change: 0 additions & 1 deletion src/components/prompts/Rename.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0e7d4ef

Please sign in to comment.