Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 0e7d4ef

Browse files
committed
fix: drop to itself (close #33
) License: MIT Signed-off-by: Henrique Dias <[email protected]>
1 parent 7a6397a commit 0e7d4ef

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

src/api/files.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ function moveCopy (items, copy = false) {
116116
let promises = []
117117

118118
for (let item of items) {
119-
let from = removePrefix(item.from)
120-
let to = encodeURIComponent(removePrefix(item.to))
121-
let url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}`
119+
const from = removePrefix(item.from)
120+
const to = encodeURIComponent(removePrefix(item.to))
121+
const url = `${from}?action=${copy ? 'copy' : 'rename'}&destination=${to}`
122122
promises.push(resourceAction(url, 'PATCH'))
123123
}
124124

src/components/files/Listing.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,6 @@ export default {
242242
for (let item of this.$store.state.clipboard.items) {
243243
const from = item.from.endsWith('/') ? item.from.slice(0, -1) : item.from
244244
const to = this.$route.path + item.name
245-
246-
if (from === to) {
247-
return
248-
}
249-
250245
items.push({ from, to })
251246
}
252247

src/components/files/ListingItem.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ export default {
5555
if (this.type === 'audio') return 'volume_up'
5656
if (this.type === 'video') return 'movie'
5757
return 'insert_drive_file'
58+
},
59+
canDrop () {
60+
if (!this.isDir) return false
61+
62+
for (let i of this.selected) {
63+
if (this.req.items[i].url === this.url) {
64+
return false
65+
}
66+
}
67+
68+
return true
5869
}
5970
},
6071
methods: {
@@ -77,7 +88,7 @@ export default {
7788
}
7889
},
7990
dragOver: function (event) {
80-
if (!this.isDir) return
91+
if (!this.canDrop) return
8192
8293
event.preventDefault()
8394
let el = event.target
@@ -91,7 +102,7 @@ export default {
91102
el.style.opacity = 1
92103
},
93104
drop: function (event) {
94-
if (!this.isDir) return
105+
if (!this.canDrop) return
95106
event.preventDefault()
96107
97108
if (this.selectedCount === 0) return
@@ -101,7 +112,7 @@ export default {
101112
for (let i of this.selected) {
102113
items.push({
103114
from: this.req.items[i].url,
104-
to: this.url + encodeURIComponent(this.req.items[i].name)
115+
to: this.url + this.req.items[i].name
105116
})
106117
}
107118

src/components/prompts/Copy.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default {
4949
for (let item of this.selected) {
5050
items.push({
5151
from: this.req.items[item].url,
52-
to: this.dest + encodeURIComponent(this.req.items[item].name)
52+
to: this.dest + this.req.items[item].name
5353
})
5454
}
5555

src/components/prompts/Move.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
for (let item of this.selected) {
4848
items.push({
4949
from: this.req.items[item].url,
50-
to: this.dest + encodeURIComponent(this.req.items[item].name)
50+
to: this.dest + this.req.items[item].name
5151
})
5252
}
5353

src/components/prompts/Rename.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export default {
6868
oldLink = this.req.items[this.selected[0]].url
6969
}
7070
71-
this.name = encodeURIComponent(this.name)
7271
newLink = url.removeLastDir(oldLink) + '/' + this.name
7372
7473
try {

0 commit comments

Comments
 (0)