filemanager: Implement clipboard handling

This commit is contained in:
Johannes Zellner
2023-04-25 22:45:22 +02:00
parent 9c5a7eb6bb
commit 8f25c91272
4 changed files with 48 additions and 21 deletions
+15 -1
View File
@@ -54,11 +54,13 @@
:change-owner-handler="changeOwnerHandler"
:copy-handler="copyHandler"
:cut-handler="cutHandler"
:paste-handler="pasteHandler"
:new-file-handler="onNewFile"
:new-folder-handler="onNewFolder"
:upload-file-handler="onUploadFile"
:upload-folder-handler="onUploadFolder"
:items="items"
:clipboard="clipboard"
:owners-model="ownersModel"
/>
</div>
@@ -122,7 +124,10 @@ export default {
activeDirectoryItem: {},
items: [],
selectedItems: [],
clipboard: {},
clipboard: {
action: '', // copy or cut
files: []
},
accessToken: localStorage.token,
apiOrigin: API_ORIGIN || '',
apps: [],
@@ -280,6 +285,15 @@ export default {
files
};
},
async pasteHandler(target) {
if (!this.clipboard.files || !this.clipboard.files.length) return;
const targetPath = target ? sanitize(this.cwd + '/' + target.fileName) : this.cwd;
await this.directoryModel.paste(targetPath, this.clipboard.action, this.clipboard.files);
this.clipboard = {};
await this.loadCwd();
},
async uploadHandler(targetDir, file, progressHandler) {
await this.directoryModel.upload(targetDir, file, progressHandler);
await this.loadCwd();