diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 65418412..252aa91f 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 {