mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-14 05:11:45 +00:00
Add season filter
This commit is contained in:
parent
b4eed3bad2
commit
090ba90b37
1 changed files with 30 additions and 0 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
<ui-btn :disabled="processing" small class="ml-2 h-9" @click="clearSelected">{{ $strings.ButtonCancel }}</ui-btn>
|
<ui-btn :disabled="processing" small class="ml-2 h-9" @click="clearSelected">{{ $strings.ButtonCancel }}</ui-btn>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
<controls-filter-select v-model="seasonKey" :items="seasonItems" class="w-36 h-9 md:ml-4" @change="filterSortChanged" />
|
||||||
<controls-filter-select v-model="filterKey" :items="filterItems" class="w-36 h-9 md:ml-4" @change="filterSortChanged" />
|
<controls-filter-select v-model="filterKey" :items="filterItems" class="w-36 h-9 md:ml-4" @change="filterSortChanged" />
|
||||||
<controls-sort-select v-model="sortKey" :descending.sync="sortDesc" :items="sortItems" class="w-44 md:w-48 h-9 ml-1 sm:ml-4" @change="filterSortChanged" />
|
<controls-sort-select v-model="sortKey" :descending.sync="sortDesc" :items="sortItems" class="w-44 md:w-48 h-9 ml-1 sm:ml-4" @change="filterSortChanged" />
|
||||||
<div class="flex-grow md:hidden" />
|
<div class="flex-grow md:hidden" />
|
||||||
|
|
@ -31,6 +32,9 @@
|
||||||
<ui-text-input v-model="search" @input="inputUpdate" type="search" :placeholder="$strings.PlaceholderSearchEpisode" class="flex-grow mr-2 text-sm md:text-base" />
|
<ui-text-input v-model="search" @input="inputUpdate" type="search" :placeholder="$strings.PlaceholderSearchEpisode" class="flex-grow mr-2 text-sm md:text-base" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- <div>-->
|
||||||
|
<!-- <pre>{{ episodesList }}</pre>-->
|
||||||
|
<!-- </div>-->
|
||||||
<div class="relative min-h-[176px]">
|
<div class="relative min-h-[176px]">
|
||||||
<template v-for="episode in totalEpisodes">
|
<template v-for="episode in totalEpisodes">
|
||||||
<div :key="episode" :id="`episode-${episode - 1}`" class="w-full h-44 px-2 py-3 overflow-hidden relative border-b border-white/10">
|
<div :key="episode" :id="`episode-${episode - 1}`" class="w-full h-44 px-2 py-3 overflow-hidden relative border-b border-white/10">
|
||||||
|
|
@ -65,6 +69,7 @@ export default {
|
||||||
episodesCopy: [],
|
episodesCopy: [],
|
||||||
filterKey: 'incomplete',
|
filterKey: 'incomplete',
|
||||||
sortKey: 'publishedAt',
|
sortKey: 'publishedAt',
|
||||||
|
seasonKey: 'allSeasons',
|
||||||
sortDesc: true,
|
sortDesc: true,
|
||||||
selectedEpisode: null,
|
selectedEpisode: null,
|
||||||
showPodcastRemoveModal: false,
|
showPodcastRemoveModal: false,
|
||||||
|
|
@ -145,6 +150,28 @@ export default {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
seasonItems() {
|
||||||
|
const seasonsSet = this.episodesCopy.reduce((acc, episode) => {
|
||||||
|
if (episode.season) {
|
||||||
|
acc.add(episode.season);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, new Set());
|
||||||
|
|
||||||
|
const seasonsArray = Array.from(seasonsSet);
|
||||||
|
|
||||||
|
const seasonItems = seasonsArray.map(season => ({
|
||||||
|
value: season,
|
||||||
|
text: `Season ${season}`
|
||||||
|
}));
|
||||||
|
|
||||||
|
seasonItems.unshift({
|
||||||
|
value: 'allSeasons',
|
||||||
|
text: 'All Seasons'
|
||||||
|
});
|
||||||
|
|
||||||
|
return seasonItems;
|
||||||
|
},
|
||||||
isSelectionMode() {
|
isSelectionMode() {
|
||||||
return this.selectedEpisodes.length > 0
|
return this.selectedEpisodes.length > 0
|
||||||
},
|
},
|
||||||
|
|
@ -163,6 +190,9 @@ export default {
|
||||||
episodesSorted() {
|
episodesSorted() {
|
||||||
return this.episodesCopy
|
return this.episodesCopy
|
||||||
.filter((ep) => {
|
.filter((ep) => {
|
||||||
|
// Filter by season
|
||||||
|
if (this.seasonKey !== 'allSeasons' && ep.season !== this.seasonKey) return false
|
||||||
|
|
||||||
if (this.filterKey === 'all') return true
|
if (this.filterKey === 'all') return true
|
||||||
const episodeProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, ep.id)
|
const episodeProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, ep.id)
|
||||||
if (this.filterKey === 'incomplete') return !episodeProgress || !episodeProgress.isFinished
|
if (this.filterKey === 'incomplete') return !episodeProgress || !episodeProgress.isFinished
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue