mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-03 09:44:41 +02:00
Add:Library filter for publishers & link to publisher filter on book page #1813
This commit is contained in:
parent
9439acf300
commit
b108f2241b
5 changed files with 60 additions and 32 deletions
|
@ -24,7 +24,7 @@
|
|||
<span class="text-white text-opacity-60 uppercase text-sm">{{ $strings.LabelPublisher }}</span>
|
||||
</div>
|
||||
<div>
|
||||
{{ publisher }}
|
||||
<nuxt-link :to="`/library/${libraryId}/bookshelf?filter=publishers.${$encode(publisher)}`" class="hover:underline">{{ publisher }}</nuxt-link>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="musicAlbum" class="flex py-0.5">
|
||||
|
|
|
@ -124,6 +124,11 @@ export default {
|
|||
value: 'narrators',
|
||||
sublist: true
|
||||
},
|
||||
{
|
||||
text: this.$strings.LabelPublisher,
|
||||
value: 'publishers',
|
||||
sublist: true
|
||||
},
|
||||
{
|
||||
text: this.$strings.LabelLanguage,
|
||||
value: 'languages',
|
||||
|
@ -167,6 +172,11 @@ export default {
|
|||
value: 'narrators',
|
||||
sublist: true
|
||||
},
|
||||
{
|
||||
text: this.$strings.LabelPublisher,
|
||||
value: 'publishers',
|
||||
sublist: true
|
||||
},
|
||||
{
|
||||
text: this.$strings.LabelLanguage,
|
||||
value: 'languages',
|
||||
|
@ -313,6 +323,9 @@ export default {
|
|||
languages() {
|
||||
return this.filterData.languages || []
|
||||
},
|
||||
publishers() {
|
||||
return this.filterData.publishers || []
|
||||
},
|
||||
progress() {
|
||||
return [
|
||||
{
|
||||
|
|
|
@ -238,21 +238,23 @@ export const mutations = {
|
|||
if (!libraryItem || !state.filterData) return
|
||||
if (state.currentLibraryId !== libraryItem.libraryId) return
|
||||
/*
|
||||
var data = {
|
||||
structure of filterData:
|
||||
{
|
||||
authors: [],
|
||||
genres: [],
|
||||
tags: [],
|
||||
series: [],
|
||||
narrators: [],
|
||||
languages: []
|
||||
languages: [],
|
||||
publishers: []
|
||||
}
|
||||
*/
|
||||
var mediaMetadata = libraryItem.media.metadata
|
||||
const mediaMetadata = libraryItem.media.metadata
|
||||
|
||||
// Add/update book authors
|
||||
if (mediaMetadata.authors && mediaMetadata.authors.length) {
|
||||
if (mediaMetadata.authors?.length) {
|
||||
mediaMetadata.authors.forEach((author) => {
|
||||
var indexOf = state.filterData.authors.findIndex(au => au.id === author.id)
|
||||
const indexOf = state.filterData.authors.findIndex(au => au.id === author.id)
|
||||
if (indexOf >= 0) {
|
||||
state.filterData.authors.splice(indexOf, 1, author)
|
||||
} else {
|
||||
|
@ -263,9 +265,9 @@ export const mutations = {
|
|||
}
|
||||
|
||||
// Add/update series
|
||||
if (mediaMetadata.series && mediaMetadata.series.length) {
|
||||
if (mediaMetadata.series?.length) {
|
||||
mediaMetadata.series.forEach((series) => {
|
||||
var indexOf = state.filterData.series.findIndex(se => se.id === series.id)
|
||||
const indexOf = state.filterData.series.findIndex(se => se.id === series.id)
|
||||
if (indexOf >= 0) {
|
||||
state.filterData.series.splice(indexOf, 1, { id: series.id, name: series.name })
|
||||
} else {
|
||||
|
@ -276,7 +278,7 @@ export const mutations = {
|
|||
}
|
||||
|
||||
// Add genres
|
||||
if (mediaMetadata.genres && mediaMetadata.genres.length) {
|
||||
if (mediaMetadata.genres?.length) {
|
||||
mediaMetadata.genres.forEach((genre) => {
|
||||
if (!state.filterData.genres.includes(genre)) {
|
||||
state.filterData.genres.push(genre)
|
||||
|
@ -286,7 +288,7 @@ export const mutations = {
|
|||
}
|
||||
|
||||
// Add tags
|
||||
if (libraryItem.media.tags && libraryItem.media.tags.length) {
|
||||
if (libraryItem.media.tags?.length) {
|
||||
libraryItem.media.tags.forEach((tag) => {
|
||||
if (!state.filterData.tags.includes(tag)) {
|
||||
state.filterData.tags.push(tag)
|
||||
|
@ -296,7 +298,7 @@ export const mutations = {
|
|||
}
|
||||
|
||||
// Add narrators
|
||||
if (mediaMetadata.narrators && mediaMetadata.narrators.length) {
|
||||
if (mediaMetadata.narrators?.length) {
|
||||
mediaMetadata.narrators.forEach((narrator) => {
|
||||
if (!state.filterData.narrators.includes(narrator)) {
|
||||
state.filterData.narrators.push(narrator)
|
||||
|
@ -305,12 +307,16 @@ export const mutations = {
|
|||
})
|
||||
}
|
||||
|
||||
// Add publishers
|
||||
if (mediaMetadata.publisher && !state.filterData.publishers.includes(mediaMetadata.publisher)) {
|
||||
state.filterData.publishers.push(mediaMetadata.publisher)
|
||||
state.filterData.publishers.sort((a, b) => a.localeCompare(b))
|
||||
}
|
||||
|
||||
// Add language
|
||||
if (mediaMetadata.language) {
|
||||
if (!state.filterData.languages.includes(mediaMetadata.language)) {
|
||||
state.filterData.languages.push(mediaMetadata.language)
|
||||
state.filterData.languages.sort((a, b) => a.localeCompare(b))
|
||||
}
|
||||
if (mediaMetadata.language && !state.filterData.languages.includes(mediaMetadata.language)) {
|
||||
state.filterData.languages.push(mediaMetadata.language)
|
||||
state.filterData.languages.sort((a, b) => a.localeCompare(b))
|
||||
}
|
||||
},
|
||||
setCollections(state, collections) {
|
||||
|
|
|
@ -80,7 +80,7 @@ export const actions = {
|
|||
if (state.settings.orderBy == 'media.metadata.publishedYear') {
|
||||
settingsUpdate.orderBy = 'media.metadata.title'
|
||||
}
|
||||
const invalidFilters = ['series', 'authors', 'narrators', 'languages', 'progress', 'issues', 'ebooks', 'abridged']
|
||||
const invalidFilters = ['series', 'authors', 'narrators', 'publishers', 'languages', 'progress', 'issues', 'ebooks', 'abridged']
|
||||
const filterByFirstPart = (state.settings.filterBy || '').split('.').shift()
|
||||
if (invalidFilters.includes(filterByFirstPart)) {
|
||||
settingsUpdate.filterBy = 'all'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue