Skip to content

Commit

Permalink
allow multi-select paste to current folder
Browse files Browse the repository at this point in the history
  • Loading branch information
kevodwyer committed Jul 21, 2023
1 parent 7a5ea87 commit 6fa611e
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions src/views/Drive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<DriveHeader
:gridView="isGrid"
:isWritable="isWritable"
:canPaste="isPasteAvailable"
:canPaste="isPasteOptionAvailable"
:path="path"
@switchView="switchView()"
@goBackToLevel="goBackToLevel($event)"
Expand All @@ -34,7 +34,7 @@
@createImageFile="createBlankImageFile()"
@newApp="createNewApp()"
@search="openSearch(false)"
@paste="paste()"
@paste="pasteToFolder($event)"
/>

<AppPrompt
Expand Down Expand Up @@ -837,26 +837,16 @@ module.exports = {
}
return true;
},
isPasteOptionAvailable() {
let singlePasteOption = this.isPasteToFolderAvailable();
let multiPasteOption = this.isPasteToFolderMultiSelectAvailable(this.currentDir);
if (multiPasteOption) {
this.multiSelectTargetFolder = this.currentDir;
}
return singlePasteOption || multiPasteOption;
},
isPasteAvailable() {
if (this.currentDir == null)
return false;
if (typeof (this.clipboard) == undefined || this.clipboard == null || this.clipboard.op == null || typeof (this.clipboard.op) == "undefined")
return false;
if (this.selectedFiles.length > 1)
return false;
var target = this.selectedFiles.length == 1 ? this.selectedFiles[0] : this.currentDir;
if (target == null) {
return false;
}
if (this.clipboard.fileTreeNode != null && this.clipboard.fileTreeNode.samePointer(target)) {
return false;
}
return target.isWritable() && target.isDirectory();
return this.isPasteToFolderAvailable();
},
},
Expand Down Expand Up @@ -1313,7 +1303,6 @@ module.exports = {
that.openFile();
} else {
that.selectedFiles = [];
that.multiSelectTargetFolder = null;
}
if (callback != null) {
callback();
Expand Down Expand Up @@ -2285,6 +2274,35 @@ module.exports = {
}
});
}
},
isPasteToFolderAvailable() {
if (this.currentDir == null)
return false;
if (typeof (this.clipboard) == undefined || this.clipboard == null || this.clipboard.op == null || typeof (this.clipboard.op) == "undefined")
return false;
if (this.selectedFiles.length > 1)
return false;
var target = this.selectedFiles.length == 1 ? this.selectedFiles[0] : this.currentDir;
if (target == null) {
return false;
}
if (this.clipboard.fileTreeNode != null && this.clipboard.fileTreeNode.samePointer(target)) {
return false;
}
return target.isWritable() && target.isDirectory();
},
pasteToFolder(e) {
var target = this.multiSelectTargetFolder;
if (target == null) {
this.paste(e);
} else {
this.pasteMultiSelect(e);
}
},
pasteMultiSelect(e, retrying) {
var target = this.multiSelectTargetFolder;
Expand Down

0 comments on commit 6fa611e

Please sign in to comment.