From d3a5ac8f978177e3cb69261c01e279e9615da2f4 Mon Sep 17 00:00:00 2001 From: Daan Wijns Date: Fri, 19 Feb 2021 08:46:51 +0100 Subject: [PATCH] feature: select all toggle #161 --- src/views/Dashboard.vue | 59 +++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 6541841268..252aa91f9a 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -100,7 +100,35 @@ - + + + + + + Select All + + + +

Nothing to see here! @@ -228,6 +256,13 @@ export default { }, hasSearchFilter() { return this.input && this.input.length + }, + selectedTorrentsLength() { + return this.$store.state.selected_torrents.length + }, + allTorrentsSelected() { + + return this.selectedTorrentsLength === this.torrents.length } }, watch: { @@ -267,18 +302,20 @@ export default { addModal(name) { this.createModal(name) }, + selectAllTorrents() { + if (this.allTorrentsSelected) { + return (this.$store.state.selected_torrents = []) + } + const hashes = this.torrents.map(t => t.hash) + + return (this.$store.state.selected_torrents = hashes) + }, handleKeyboardShortcut(e) { // 'ctrl + A' => select torrents if (e.keyCode === 65 && e.ctrlKey) { e.preventDefault() - if ( - this.$store.state.selected_torrents.length === this.torrents.length - ) { - return (this.$store.state.selected_torrents = []) - } - const hashes = this.torrents.map(t => t.hash) - - return (this.$store.state.selected_torrents = hashes) + + this.selectAllTorrents() } // 'Delete' => Delete modal @@ -296,8 +333,8 @@ export default {