From 95316cbe8c8ac3dbb28310bc11ec347c0caf699b Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 31 Dec 2019 16:53:35 +0000 Subject: [PATCH] feat: add key shortcuts - 'Ctrl + a' selects all files in listing. - 'Enter' to confirm a prompt. --- frontend/src/components/files/Listing.vue | 15 ++++++++++- frontend/src/components/prompts/Prompts.vue | 29 ++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/files/Listing.vue b/frontend/src/components/files/Listing.vue index 3e4c64c2..4c222285 100644 --- a/frontend/src/components/files/Listing.vue +++ b/frontend/src/components/files/Listing.vue @@ -190,7 +190,7 @@ export default { document.removeEventListener('drop', this.drop) }, methods: { - ...mapMutations([ 'updateUser' ]), + ...mapMutations([ 'updateUser', 'addSelected' ]), base64: function (name) { return window.btoa(unescape(encodeURIComponent(name))) }, @@ -213,6 +213,19 @@ export default { case 'v': this.paste(event) break + case 'a': + event.preventDefault() + for (let file of this.items.files) { + if (this.$store.state.selected.indexOf(file.index) === -1) { + this.addSelected(file.index) + } + } + for (let dir of this.items.dirs) { + if (this.$store.state.selected.indexOf(dir.index) === -1) { + this.addSelected(dir.index) + } + } + break } }, preventDefault (event) { diff --git a/frontend/src/components/prompts/Prompts.vue b/frontend/src/components/prompts/Prompts.vue index 29d4112b..00ed511f 100644 --- a/frontend/src/components/prompts/Prompts.vue +++ b/frontend/src/components/prompts/Prompts.vue @@ -1,6 +1,6 @@ @@ -46,6 +46,33 @@ export default { } } }, + created () { + window.addEventListener('keydown', (event) => { + if (this.show == null) + return + + let prompt = this.$refs.currentComponent; + + // Enter + if (event.keyCode == 13) { + switch (this.show) { + case 'delete': + prompt.submit() + break; + case 'copy': + prompt.copy(event) + break; + case 'move': + prompt.move(event) + break; + case 'replace': + prompt.showConfirm(event) + break; + } + + } + }) + }, computed: { ...mapState(['show', 'plugins']), currentComponent: function () {