From e752b4071d0a2062f34167be594c7a99ff86a12c Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 28 Oct 2022 18:10:19 -0500 Subject: [PATCH] Update:Cleanup bookshelf toolbars & fix siderail icon --- client/components/app/Appbar.vue | 6 +- client/components/app/BookShelfRow.vue | 4 +- client/components/app/BookShelfToolbar.vue | 100 ++++++++++-------- client/components/app/LazyBookshelf.vue | 29 +++-- client/components/app/SideRail.vue | 2 +- client/components/cards/LazySeriesCard.vue | 2 +- .../{EpisodeSortSelect.vue => SortSelect.vue} | 26 ++--- .../tables/podcast/EpisodesTable.vue | 22 +++- client/components/widgets/EpisodeSlider.vue | 4 +- client/components/widgets/ItemSlider.vue | 4 +- client/layouts/default.vue | 2 +- client/store/libraries.js | 8 +- 12 files changed, 121 insertions(+), 88 deletions(-) rename client/components/controls/{EpisodeSortSelect.vue => SortSelect.vue} (87%) diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index bd98283b..48ec5f54 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -153,7 +153,7 @@ export default { cancelSelectionMode() { if (this.processingBatchDelete) return this.$store.commit('setSelectedLibraryItems', []) - this.$eventBus.$emit('bookshelf-clear-selection') + this.$eventBus.$emit('bookshelf_clear_selection') this.isAllSelected = false }, toggleBatchRead() { @@ -172,7 +172,7 @@ export default { this.$toast.success('Batch update success!') this.$store.commit('setProcessingBatch', false) this.$store.commit('setSelectedLibraryItems', []) - this.$eventBus.$emit('bookshelf-clear-selection') + this.$eventBus.$emit('bookshelf_clear_selection') }) .catch((error) => { this.$toast.error('Batch update failed') @@ -195,7 +195,7 @@ export default { this.processingBatchDelete = false this.$store.commit('setProcessingBatch', false) this.$store.commit('setSelectedLibraryItems', []) - this.$eventBus.$emit('bookshelf-clear-selection') + this.$eventBus.$emit('bookshelf_clear_selection') }) .catch((error) => { this.$toast.error('Batch delete failed') diff --git a/client/components/app/BookShelfRow.vue b/client/components/app/BookShelfRow.vue index 8a1a0166..29003f3d 100644 --- a/client/components/app/BookShelfRow.vue +++ b/client/components/app/BookShelfRow.vue @@ -188,11 +188,11 @@ export default { } }, mounted() { - this.$eventBus.$on('bookshelf-clear-selection', this.clearSelectedEntities) + this.$eventBus.$on('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$on('item-selected', this.itemSelectedEvt) }, beforeDestroy() { - this.$eventBus.$off('bookshelf-clear-selection', this.clearSelectedEntities) + this.$eventBus.$off('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$off('item-selected', this.itemSelectedEvt) } } diff --git a/client/components/app/BookShelfToolbar.vue b/client/components/app/BookShelfToolbar.vue index 06bb2106..ed575723 100644 --- a/client/components/app/BookShelfToolbar.vue +++ b/client/components/app/BookShelfToolbar.vue @@ -1,16 +1,16 @@ @@ -81,11 +82,29 @@ export default { settings: {}, hasInit: false, totalEntities: 0, - keywordFilter: null, - keywordTimeout: null, processingSeries: false, processingIssues: false, - processingAuthors: false + processingAuthors: false, + seriesSort: 'name', + seriesSortDesc: false, + seriesSortItems: [ + { + text: 'Name', + value: 'name' + }, + { + text: '# of Books', + value: 'numBooks' + }, + { + text: 'Added At', + value: 'addedAt' + }, + { + text: 'Total Duration', + value: 'totalDuration' + } + ] } }, computed: { @@ -98,25 +117,6 @@ export default { userCanUpdate() { return this.$store.getters['user/getUserCanUpdate'] }, - isPodcast() { - return this.$store.getters['libraries/getCurrentLibraryMediaType'] == 'podcast' - }, - showSortFilters() { - return this.page === '' - }, - numShowing() { - return this.totalEntities - }, - entityName() { - if (this.isPodcast) return 'Podcasts' - if (!this.page) return 'Books' - if (this.page === 'series') return 'Series' - if (this.page === 'collections') return 'Collections' - return '' - }, - paramId() { - return this.$route.params ? this.$route.params.id || '' : '' - }, currentLibraryId() { return this.$store.state.libraries.currentLibraryId }, @@ -126,14 +126,30 @@ export default { isPodcastLibrary() { return this.currentLibraryMediaType === 'podcast' }, - homePage() { + isLibraryPage() { + return this.page === '' + }, + isSeriesPage() { + return this.page === 'series' + }, + isCollectionsPage() { + return this.page === 'collections' + }, + isHomePage() { return this.$route.name === 'library-library' }, - libraryBookshelfPage() { - return this.$route.name === 'library-library-bookshelf-id' + isPodcastSearchPage() { + return this.$route.name === 'library-library-podcast-search' }, - showLibrary() { - return this.libraryBookshelfPage && this.paramId === '' && !this.showingIssues + numShowing() { + return this.totalEntities + }, + entityName() { + if (this.isPodcastLibrary) return 'Podcasts' + if (!this.page) return 'Books' + if (this.isSeriesPage) return 'Series' + if (this.isCollectionsPage) return 'Collections' + return '' }, seriesName() { return this.selectedSeries ? this.selectedSeries.name : null @@ -153,9 +169,6 @@ export default { }, isIssuesFilter() { return this.filterBy === 'issues' && this.$route.query.filter === 'issues' - }, - isPodcastSearchPage() { - return this.$route.name === 'library-library-podcast-search' } }, methods: { @@ -235,6 +248,10 @@ export default { updateFilter() { this.saveSettings() }, + updateSeriesSort() { + this.$store.commit('libraries/setSeriesSort', { sort: this.seriesSort, desc: this.seriesSortDesc }) + this.$eventBus.$emit('series-sort-updated') + }, updateCollapseSeries() { this.saveSettings() }, @@ -251,15 +268,6 @@ export default { }, setBookshelfTotalEntities(totalEntities) { this.totalEntities = totalEntities - }, - keywordFilterInput() { - clearTimeout(this.keywordTimeout) - this.keywordTimeout = setTimeout(() => { - this.keywordUpdated(this.keywordFilter) - }, 1000) - }, - keywordUpdated() { - this.$eventBus.$emit('bookshelf-keyword-filter', this.keywordFilter) } }, mounted() { diff --git a/client/components/app/LazyBookshelf.vue b/client/components/app/LazyBookshelf.vue index e0b03022..262b5fba 100644 --- a/client/components/app/LazyBookshelf.vue +++ b/client/components/app/LazyBookshelf.vue @@ -98,6 +98,12 @@ export default { if (!this.page) return 'books' return this.page }, + seriesSortBy() { + return this.$store.state.libraries.seriesSort + }, + seriesSortDesc() { + return this.$store.state.libraries.seriesSortDesc + }, orderBy() { return this.$store.getters['user/getUserSetting']('orderBy') }, @@ -417,12 +423,15 @@ export default { this.$nextTick(this.remountEntities) }, buildSearchParams() { - if (this.page === 'search' || this.page === 'series' || this.page === 'collections') { + if (this.page === 'search' || this.page === 'collections') { return '' } let searchParams = new URLSearchParams() - if (this.page === 'series-books') { + if (this.page === 'series') { + searchParams.set('sort', this.seriesSortBy) + searchParams.set('desc', this.seriesSortDesc ? 1 : 0) + } else if (this.page === 'series-books') { searchParams.set('filter', `series.${this.$encode(this.seriesId)}`) } else { if (this.filterBy && this.filterBy !== 'all') { @@ -458,6 +467,12 @@ export default { return false }, + seriesSortUpdated() { + var wasUpdated = this.checkUpdateSearchParams() + if (wasUpdated) { + this.resetEntities() + } + }, settingsUpdated(settings) { var wasUpdated = this.checkUpdateSearchParams() if (wasUpdated) { @@ -469,10 +484,7 @@ export default { scroll(e) { if (!e || !e.target) return var { scrollTop } = e.target - // clearTimeout(this.scrollTimeout) - // this.scrollTimeout = setTimeout(() => { this.handleScroll(scrollTop) - // }, 250) }, libraryItemAdded(libraryItem) { console.log('libraryItem added', libraryItem) @@ -604,7 +616,8 @@ export default { } }) - this.$eventBus.$on('bookshelf-clear-selection', this.clearSelectedEntities) + this.$eventBus.$on('series-sort-updated', this.seriesSortUpdated) + this.$eventBus.$on('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$on('socket_init', this.socketInit) this.$store.commit('user/addSettingsListener', { id: 'lazy-bookshelf', meth: this.settingsUpdated }) @@ -628,7 +641,9 @@ export default { if (bookshelf) { bookshelf.removeEventListener('scroll', this.scroll) } - this.$eventBus.$off('bookshelf-clear-selection', this.clearSelectedEntities) + + this.$eventBus.$off('series-sort-updated', this.seriesSortUpdated) + this.$eventBus.$off('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$off('socket_init', this.socketInit) this.$store.commit('user/removeSettingsListener', 'lazy-bookshelf') diff --git a/client/components/app/SideRail.vue b/client/components/app/SideRail.vue index c91f5580..9cdbf192 100644 --- a/client/components/app/SideRail.vue +++ b/client/components/app/SideRail.vue @@ -64,7 +64,7 @@ - +

Search

diff --git a/client/components/cards/LazySeriesCard.vue b/client/components/cards/LazySeriesCard.vue index ebe7cc6d..3932646b 100644 --- a/client/components/cards/LazySeriesCard.vue +++ b/client/components/cards/LazySeriesCard.vue @@ -1,5 +1,5 @@

No Episodes

@@ -42,7 +42,25 @@ export default { showPodcastRemoveModal: false, selectedEpisodes: [], episodesToRemove: [], - processing: false + processing: false, + sortItems: [ + { + text: 'Pub Date', + value: 'publishedAt' + }, + { + text: 'Title', + value: 'title' + }, + { + text: 'Season', + value: 'season' + }, + { + text: 'Episode', + value: 'episode' + } + ] } }, watch: { diff --git a/client/components/widgets/EpisodeSlider.vue b/client/components/widgets/EpisodeSlider.vue index cc876119..66fd45f0 100644 --- a/client/components/widgets/EpisodeSlider.vue +++ b/client/components/widgets/EpisodeSlider.vue @@ -150,11 +150,11 @@ export default { this.setScrollVars() }, mounted() { - this.$eventBus.$on('bookshelf-clear-selection', this.clearSelectedEntities) + this.$eventBus.$on('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$on('item-selected', this.itemSelectedEvt) }, beforeDestroy() { - this.$eventBus.$off('bookshelf-clear-selection', this.clearSelectedEntities) + this.$eventBus.$off('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$off('item-selected', this.itemSelectedEvt) } } diff --git a/client/components/widgets/ItemSlider.vue b/client/components/widgets/ItemSlider.vue index 7a0bd352..a74ef5e4 100644 --- a/client/components/widgets/ItemSlider.vue +++ b/client/components/widgets/ItemSlider.vue @@ -130,11 +130,11 @@ export default { this.setScrollVars() }, mounted() { - this.$eventBus.$on('bookshelf-clear-selection', this.clearSelectedEntities) + this.$eventBus.$on('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$on('item-selected', this.itemSelectedEvt) }, beforeDestroy() { - this.$eventBus.$off('bookshelf-clear-selection', this.clearSelectedEntities) + this.$eventBus.$off('bookshelf_clear_selection', this.clearSelectedEntities) this.$eventBus.$off('item-selected', this.itemSelectedEvt) } } diff --git a/client/layouts/default.vue b/client/layouts/default.vue index 826c0cb7..8708468c 100644 --- a/client/layouts/default.vue +++ b/client/layouts/default.vue @@ -474,7 +474,7 @@ export default { if (this.$store.getters['getNumLibraryItemsSelected'] && name === 'Escape') { // ESCAPE key cancels batch selection this.$store.commit('setSelectedLibraryItems', []) - this.$eventBus.$emit('bookshelf-clear-selection') + this.$eventBus.$emit('bookshelf_clear_selection') e.preventDefault() return } diff --git a/client/store/libraries.js b/client/store/libraries.js index f4f8cd74..519ca4a0 100644 --- a/client/store/libraries.js +++ b/client/store/libraries.js @@ -8,7 +8,9 @@ export const state = () => ({ folders: [], issues: 0, folderLastUpdate: 0, - filterData: null + filterData: null, + seriesSort: 'name', + seriesSortDesc: false }) export const getters = { @@ -289,5 +291,9 @@ export const mutations = { state.filterData.languages.sort((a, b) => a.localeCompare(b)) } } + }, + setSeriesSort(state, { sort, desc }) { + state.seriesSort = sort + state.seriesSortDesc = desc } } \ No newline at end of file