mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-12 20:31:36 +00:00
Format the season group and add strings
This commit is contained in:
parent
2f97499612
commit
0ced0721db
2 changed files with 64 additions and 30 deletions
|
|
@ -34,18 +34,31 @@
|
||||||
<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>-->
|
|
||||||
<!-- <pre>{{ libraryItem }}</pre>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div class="relative min-h-[176px]">
|
<div class="relative min-h-[176px]">
|
||||||
<template v-for="episode in totalEpisodes">
|
<template v-if="podcastType === 'serial'">
|
||||||
<div :key="episode" :id="`episode-${episode - 1}`" class="w-full h-44 px-2 py-3 overflow-hidden relative border-b border-white/10">
|
<template v-for="group in groupedEpisodesBySeason">
|
||||||
<!-- episode is mounted here -->
|
<div class="w-full my-2">
|
||||||
</div>
|
<div class="w-full bg-primary px-6 py-2 flex items-center">
|
||||||
|
<p class="pr-4">{{ $strings.LabelSeason }} {{ group.season }}</p>
|
||||||
|
<span class="bg-black-400 rounded-xl py-1 px-2 text-sm font-mono">{{ group.episodes.length }}</span>
|
||||||
|
<div class="flex-grow" />
|
||||||
|
</div>
|
||||||
|
<template v-for="episode in group.episodes">
|
||||||
|
<div :key="episode" :id="`episode-${episode}`" class="w-full h-44 px-2 py-3 overflow-hidden relative border-b border-white/10">
|
||||||
|
<!-- episode is mounted here -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<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">
|
||||||
|
<!-- episode is mounted here -->
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div v-if="isSearching" class="w-full h-full absolute inset-0 flex justify-center py-12" :class="{ 'bg-black/50': totalEpisodes }">
|
<div v-if="isSearching" class="w-full h-full absolute inset-0 flex justify-center py-12" :class="{ 'bg-black/50': totalEpisodes }">
|
||||||
<ui-loading-indicator />
|
<ui-loading-indicator />
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -156,26 +169,22 @@ export default {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
seasonItems() {
|
seasonItems() {
|
||||||
const seasonsSet = this.episodesCopy.reduce((acc, episode) => {
|
const seasonsMap = new Map();
|
||||||
if (episode.season) {
|
seasonsMap.set('allSeasons', this.$strings.LabelAllSeasons);
|
||||||
acc.add(episode.season);
|
|
||||||
|
this.episodesCopy.forEach((episode) => {
|
||||||
|
const season = episode.season || 'unknown';
|
||||||
|
if (!seasonsMap.has(season)) {
|
||||||
|
seasonsMap.set(season, `${this.$strings.LabelSeason} ${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;
|
if (seasonsMap.has('unknown')) {
|
||||||
|
seasonsMap.delete('unknown');
|
||||||
|
seasonsMap.set('unknown', this.$strings.LabelSeasonUnknown);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Array.from(seasonsMap, ([value, text]) => ({ value, text }));
|
||||||
},
|
},
|
||||||
isSelectionMode() {
|
isSelectionMode() {
|
||||||
return this.selectedEpisodes.length > 0
|
return this.selectedEpisodes.length > 0
|
||||||
|
|
@ -199,9 +208,11 @@ export default {
|
||||||
return this.episodesCopy
|
return this.episodesCopy
|
||||||
.filter((ep) => {
|
.filter((ep) => {
|
||||||
// Filter by season
|
// Filter by season
|
||||||
if (this.podcastType === 'serial' && this.seasonKey !== 'allSeasons' && ep.season !== this.seasonKey) return false
|
const season = ep.season && ep.season.trim() !== '' ? ep.season : 'unknown';
|
||||||
|
if (this.podcastType === 'serial' && this.seasonKey === 'unknown' && season !== 'unknown') return false;
|
||||||
|
if (this.podcastType === 'serial' && this.seasonKey !== 'allSeasons' && 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
|
||||||
if (this.filterKey === 'complete') return episodeProgress && episodeProgress.isFinished
|
if (this.filterKey === 'complete') return episodeProgress && episodeProgress.isFinished
|
||||||
|
|
@ -247,6 +258,27 @@ export default {
|
||||||
},
|
},
|
||||||
timeFormat() {
|
timeFormat() {
|
||||||
return this.$store.state.serverSettings.timeFormat
|
return this.$store.state.serverSettings.timeFormat
|
||||||
|
},
|
||||||
|
groupedEpisodesBySeason() {
|
||||||
|
if (this.podcastType !== 'serial') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.episodesList.reduce((grouped, episode, index) => {
|
||||||
|
let season = episode.season || 'unknown';
|
||||||
|
const seasonGroup = grouped.find(group => group.season === season);
|
||||||
|
|
||||||
|
if (!seasonGroup) {
|
||||||
|
grouped.push({
|
||||||
|
season,
|
||||||
|
episodes: [index]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
seasonGroup.episodes.push(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return grouped;
|
||||||
|
}, []).sort((a, b) => b.season - a.season);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,7 @@
|
||||||
"LabelAddToPlaylistBatch": "Add {0} Items to Playlist",
|
"LabelAddToPlaylistBatch": "Add {0} Items to Playlist",
|
||||||
"LabelAdminUsersOnly": "Admin users only",
|
"LabelAdminUsersOnly": "Admin users only",
|
||||||
"LabelAll": "All",
|
"LabelAll": "All",
|
||||||
|
"LabelAllSeasons": "All Seasons",
|
||||||
"LabelAllUsers": "All Users",
|
"LabelAllUsers": "All Users",
|
||||||
"LabelAllUsersExcludingGuests": "All users excluding guests",
|
"LabelAllUsersExcludingGuests": "All users excluding guests",
|
||||||
"LabelAllUsersIncludingGuests": "All users including guests",
|
"LabelAllUsersIncludingGuests": "All users including guests",
|
||||||
|
|
@ -436,6 +437,7 @@
|
||||||
"LabelSearchTitle": "Search Title",
|
"LabelSearchTitle": "Search Title",
|
||||||
"LabelSearchTitleOrASIN": "Search Title or ASIN",
|
"LabelSearchTitleOrASIN": "Search Title or ASIN",
|
||||||
"LabelSeason": "Season",
|
"LabelSeason": "Season",
|
||||||
|
"LabelSeasonUnknown": "Season Unknown",
|
||||||
"LabelSelectAllEpisodes": "Select all episodes",
|
"LabelSelectAllEpisodes": "Select all episodes",
|
||||||
"LabelSelectEpisodesShowing": "Select {0} episodes showing",
|
"LabelSelectEpisodesShowing": "Select {0} episodes showing",
|
||||||
"LabelSelectUsers": "Select users",
|
"LabelSelectUsers": "Select users",
|
||||||
|
|
@ -776,4 +778,4 @@
|
||||||
"ToastSocketFailedToConnect": "Socket failed to connect",
|
"ToastSocketFailedToConnect": "Socket failed to connect",
|
||||||
"ToastUserDeleteFailed": "Failed to delete user",
|
"ToastUserDeleteFailed": "Failed to delete user",
|
||||||
"ToastUserDeleteSuccess": "User deleted"
|
"ToastUserDeleteSuccess": "User deleted"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue