From 5c92aef04838555f01ed3e2046f033a29cbe42cb Mon Sep 17 00:00:00 2001 From: advplyr Date: Tue, 30 Nov 2021 20:02:40 -0600 Subject: [PATCH] Lazy bookshelf, api routes for categories and filter data --- client/components/app/Appbar.vue | 30 +- .../components/app/BookShelfCategorized.vue | 148 ++++---- client/components/app/BookShelfRow.vue | 18 +- client/components/app/BookShelfToolbar.vue | 42 ++- client/components/app/LazyBookshelf.vue | 343 ++++++++++++------ client/components/cards/BookCard.vue | 4 +- client/components/cards/LazyBookCard.vue | 223 ++++++++++-- .../components/cards/LazyCollectionCard.vue | 87 +++++ client/components/cards/LazySeriesCard.vue | 102 ++++++ client/components/controls/FilterSelect.vue | 18 +- client/components/controls/GlobalSearch.vue | 2 +- client/components/covers/BookCover.vue | 8 +- client/components/covers/GroupCover.vue | 15 +- client/components/modals/EditModal.vue | 4 +- client/components/ui/LibrariesDropdown.vue | 11 +- client/mixins/bookshelfCardsHelpers.js | 82 +++++ .../pages/library/_library/bookshelf/_id.vue | 2 +- client/pages/library/_library/search.vue | 62 ++++ client/store/audiobooks.js | 1 + client/store/globals.js | 1 - client/store/libraries.js | 38 +- client/store/user.js | 2 +- server/ApiController.js | 146 +++++--- server/controllers/LibraryController.js | 163 +++++++-- server/objects/Book.js | 2 + server/utils/libraryHelpers.js | 132 +++++++ 26 files changed, 1354 insertions(+), 332 deletions(-) create mode 100644 client/components/cards/LazyCollectionCard.vue create mode 100644 client/components/cards/LazySeriesCard.vue create mode 100644 client/mixins/bookshelfCardsHelpers.js create mode 100644 client/pages/library/_library/search.vue create mode 100644 server/utils/libraryHelpers.js diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index 70afc10a..ca21bba9 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -40,7 +40,7 @@

{{ numAudiobooksSelected }} Selected

{{ isAllSelected ? 'Select None' : 'Select All' }}({{ audiobooksShowing.length }}){{ isAllSelected ? 'Select None' : 'Select All' }}({{ totalBooks }})
@@ -65,7 +65,9 @@ export default { data() { return { - processingBatchDelete: false + processingBatchDelete: false, + totalBooks: 0, + isAllSelected: false } }, computed: { @@ -96,9 +98,9 @@ export default { selectedAudiobooks() { return this.$store.state.selectedAudiobooks }, - isAllSelected() { - return this.audiobooksShowing.length === this.selectedAudiobooks.length - }, + // isAllSelected() { + // return this.audiobooksShowing.length === this.selectedAudiobooks.length + // }, userAudiobooks() { return this.$store.state.user.user.audiobooks || {} }, @@ -145,13 +147,17 @@ export default { cancelSelectionMode() { if (this.processingBatchDelete) return this.$store.commit('setSelectedAudiobooks', []) + this.$eventBus.$emit('bookshelf-clear-selection') + this.isAllSelected = false }, toggleSelectAll() { if (this.isAllSelected) { this.cancelSelectionMode() } else { - var audiobookIds = this.audiobooksShowing.map((a) => a.id) - this.$store.commit('setSelectedAudiobooks', audiobookIds) + this.$eventBus.$emit('bookshelf-select-all') + this.isAllSelected = true + // var audiobookIds = this.audiobooksShowing.map((a) => a.id) + // this.$store.commit('setSelectedAudiobooks', audiobookIds) } }, toggleBatchRead() { @@ -205,9 +211,17 @@ export default { }, batchAddToCollectionClick() { this.$store.commit('globals/setShowBatchUserCollectionsModal', true) + }, + setBookshelfTotalBooks(totalBooks) { + this.totalBooks = totalBooks } }, - mounted() {} + mounted() { + this.$eventBus.$on('bookshelf-total-books', this.setBookshelfTotalBooks) + }, + beforeDestroy() { + this.$eventBus.$off('bookshelf-total-books', this.setBookshelfTotalBooks) + } } diff --git a/client/components/app/BookShelfCategorized.vue b/client/components/app/BookShelfCategorized.vue index dbddc742..7d7def7f 100644 --- a/client/components/app/BookShelfCategorized.vue +++ b/client/components/app/BookShelfCategorized.vue @@ -13,7 +13,7 @@

Texture

-
+

Your Audiobookshelf is empty!

Configure Scanner @@ -30,89 +30,36 @@ diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index 5a2f0b76..10b96db8 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -2,47 +2,77 @@
+ +
+

{{ emptyMessage }}

+
diff --git a/client/components/cards/BookCard.vue b/client/components/cards/BookCard.vue index 9f944562..5eb7d2b8 100644 --- a/client/components/cards/BookCard.vue +++ b/client/components/cards/BookCard.vue @@ -22,7 +22,7 @@ -