mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-29 22:29:29 +02:00
Add:Filter for podcast episodes
This commit is contained in:
parent
480df58ce4
commit
1f1b2fe85a
1 changed files with 26 additions and 38 deletions
|
@ -5,7 +5,7 @@
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
<button class="outline:none mx-3 pt-0.5 relative" @click="showFilters">
|
<button class="outline:none mx-3 pt-0.5 relative" @click="showFilters">
|
||||||
<span class="material-icons text-xl text-gray-200">filter_alt</span>
|
<span class="material-icons text-xl text-gray-200">filter_alt</span>
|
||||||
<div v-show="filterKey !== 'all'" class="absolute top-0 right-0 w-1.5 h-1.5 rounded-full bg-success border border-green-300 shadow-sm z-10 pointer-events-none" />
|
<div v-show="filterKey !== 'all' && episodesAreFiltered" class="absolute top-0 right-0 w-1.5 h-1.5 rounded-full bg-success border border-green-300 shadow-sm z-10 pointer-events-none" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="flex items-center border border-white border-opacity-25 rounded px-2" @click="clickSort">
|
<div class="flex items-center border border-white border-opacity-25 rounded px-2" @click="clickSort">
|
||||||
|
@ -14,10 +14,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-for="episode in episodesFiltered">
|
<template v-for="episode in episodesSorted">
|
||||||
<tables-podcast-episode-row :episode="episode" :local-episode="localEpisodeMap[episode.id]" :library-item-id="libraryItemId" :local-library-item-id="localLibraryItemId" :is-local="isLocal" :key="episode.id" />
|
<tables-podcast-episode-row :episode="episode" :local-episode="localEpisodeMap[episode.id]" :library-item-id="libraryItemId" :local-library-item-id="localLibraryItemId" :is-local="isLocal" :key="episode.id" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- What in tarnation is going on here?
|
||||||
|
Without anything below the template it will not re-render -->
|
||||||
|
<p> </p>
|
||||||
|
|
||||||
<modals-dialog v-model="showFiltersModal" title="Episode Filter" :items="filterItems" :selected="filterKey" @action="setFilter" />
|
<modals-dialog v-model="showFiltersModal" title="Episode Filter" :items="filterItems" :selected="filterKey" @action="setFilter" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -43,8 +47,7 @@ export default {
|
||||||
showFiltersModal: false,
|
showFiltersModal: false,
|
||||||
sortKey: 'publishedAt',
|
sortKey: 'publishedAt',
|
||||||
sortDesc: false,
|
sortDesc: false,
|
||||||
filterKey: 'all',
|
filterKey: 'incomplete',
|
||||||
episodesFiltered: [],
|
|
||||||
episodeSortItems: [
|
episodeSortItems: [
|
||||||
{
|
{
|
||||||
text: 'Pub Date',
|
text: 'Pub Date',
|
||||||
|
@ -89,19 +92,28 @@ export default {
|
||||||
handler() {
|
handler() {
|
||||||
this.init()
|
this.init()
|
||||||
}
|
}
|
||||||
},
|
|
||||||
filterKey: {
|
|
||||||
handler() {
|
|
||||||
this.setEpisodesFiltered()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sortKey: {
|
|
||||||
handler() {
|
|
||||||
this.setEpisodesFiltered()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
episodesAreFiltered() {
|
||||||
|
return this.episodesFiltered.length !== this.episodesCopy.length
|
||||||
|
},
|
||||||
|
episodesFiltered() {
|
||||||
|
return this.episodesCopy.filter((ep) => {
|
||||||
|
var mediaProgress = this.getEpisodeProgress(ep)
|
||||||
|
if (this.filterKey === 'incomplete') {
|
||||||
|
return !mediaProgress || !mediaProgress.isFinished
|
||||||
|
} else if (this.filterKey === 'complete') {
|
||||||
|
return mediaProgress && mediaProgress.isFinished
|
||||||
|
} else if (this.filterKey === 'inProgress') {
|
||||||
|
return mediaProgress && !mediaProgress.isFinished
|
||||||
|
} else if (this.filterKey === 'all') {
|
||||||
|
console.log('Filter key is all')
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
},
|
||||||
episodesSorted() {
|
episodesSorted() {
|
||||||
return this.episodesFiltered.sort((a, b) => {
|
return this.episodesFiltered.sort((a, b) => {
|
||||||
if (this.sortDesc) {
|
if (this.sortDesc) {
|
||||||
|
@ -128,29 +140,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setEpisodesFiltered() {
|
|
||||||
this.episodesFiltered = this.episodesCopy
|
|
||||||
.filter((ep) => {
|
|
||||||
var mediaProgress = this.getEpisodeProgress(ep)
|
|
||||||
if (this.filterKey === 'incomplete') {
|
|
||||||
return !mediaProgress || !mediaProgress.isFinished
|
|
||||||
} else if (this.filterKey === 'complete') {
|
|
||||||
return mediaProgress && mediaProgress.isFinished
|
|
||||||
} else if (this.filterKey === 'inProgress') {
|
|
||||||
return mediaProgress && !mediaProgress.isFinished
|
|
||||||
} else if (this.filterKey === 'all') {
|
|
||||||
console.log('Filter key is all')
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
.sort((a, b) => {
|
|
||||||
if (this.sortDesc) {
|
|
||||||
return String(b[this.sortKey]).localeCompare(String(a[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' })
|
|
||||||
}
|
|
||||||
return String(a[this.sortKey]).localeCompare(String(b[this.sortKey]), undefined, { numeric: true, sensitivity: 'base' })
|
|
||||||
})
|
|
||||||
},
|
|
||||||
setFilter(filter) {
|
setFilter(filter) {
|
||||||
this.filterKey = filter
|
this.filterKey = filter
|
||||||
console.log('Set filter', this.filterKey)
|
console.log('Set filter', this.filterKey)
|
||||||
|
@ -170,7 +159,6 @@ export default {
|
||||||
this.episodesCopy = this.episodes.map((ep) => {
|
this.episodesCopy = this.episodes.map((ep) => {
|
||||||
return { ...ep }
|
return { ...ep }
|
||||||
})
|
})
|
||||||
this.setEpisodesFiltered()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue