mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-29 01:58:49 +01:00
Change: Multiple authors are treated separately for filtering and searching #103
This commit is contained in:
parent
d38d4dcd62
commit
2c6cfae6a1
@ -10,7 +10,10 @@
|
|||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
<div class="text-gray-400 flex items-center">
|
<div class="text-gray-400 flex items-center">
|
||||||
<span class="material-icons text-sm">person</span>
|
<span class="material-icons text-sm">person</span>
|
||||||
<p class="text-base hover:underline cursor-pointer pl-2" @click="filterByAuthor">{{ author }}</p>
|
<p v-if="authorFL" class="pl-1.5 text-base">
|
||||||
|
<nuxt-link v-for="(author, index) in authorsList" :key="index" :to="`/library/${libraryId}/bookshelf?filter=authors.${$encode(author)}`" class="hover:underline">{{ author }}<span v-if="index < authorsList.length - 1">, </span></nuxt-link>
|
||||||
|
</p>
|
||||||
|
<p v-else class="text-base cursor-pointer pl-2">Unknown</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-gray-400 flex items-center">
|
<div class="text-gray-400 flex items-center">
|
||||||
@ -83,6 +86,12 @@ export default {
|
|||||||
author() {
|
author() {
|
||||||
return this.book.author || 'Unknown'
|
return this.book.author || 'Unknown'
|
||||||
},
|
},
|
||||||
|
authorFL() {
|
||||||
|
return this.book.authorFL
|
||||||
|
},
|
||||||
|
authorsList() {
|
||||||
|
return this.authorFL ? this.authorFL.split(', ') : []
|
||||||
|
},
|
||||||
streamId() {
|
streamId() {
|
||||||
return this.stream ? this.stream.id : null
|
return this.stream ? this.stream.id : null
|
||||||
},
|
},
|
||||||
|
@ -17,11 +17,10 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<p v-if="subtitle" class="ml-4 text-gray-400 text-2xl">{{ subtitle }}</p>
|
<p v-if="subtitle" class="ml-4 text-gray-400 text-2xl">{{ subtitle }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<p v-if="authorFL" class="mb-2 mt-0.5 text-gray-200 text-xl">
|
||||||
<p class="mb-2 mt-0.5 text-gray-100 text-xl">
|
by <nuxt-link v-for="(author, index) in authorsList" :key="index" :to="`/library/${libraryId}/bookshelf?filter=authors.${$encode(author)}`" class="hover:underline">{{ author }}<span v-if="index < authorsList.length - 1">, </span></nuxt-link>
|
||||||
by <nuxt-link v-if="authorFL" :to="`/library/${libraryId}/bookshelf?filter=authors.${$encode(authorFL)}`" class="hover:underline">{{ authorFL }}</nuxt-link
|
|
||||||
><span v-else>Unknown</span>
|
|
||||||
</p>
|
</p>
|
||||||
|
<p v-else class="mb-2 mt-0.5 text-gray-200 text-xl">by Unknown</p>
|
||||||
<nuxt-link v-if="series" :to="`/library/${libraryId}/bookshelf/series?series=${$encode(series)}`" class="hover:underline font-sans text-gray-300 text-lg leading-7 mb-4"> {{ seriesText }}</nuxt-link>
|
<nuxt-link v-if="series" :to="`/library/${libraryId}/bookshelf/series?series=${$encode(series)}`" class="hover:underline font-sans text-gray-300 text-lg leading-7 mb-4"> {{ seriesText }}</nuxt-link>
|
||||||
|
|
||||||
<div v-if="narrator" class="flex py-0.5">
|
<div v-if="narrator" class="flex py-0.5">
|
||||||
@ -263,6 +262,9 @@ export default {
|
|||||||
authorFL() {
|
authorFL() {
|
||||||
return this.book.authorFL
|
return this.book.authorFL
|
||||||
},
|
},
|
||||||
|
authorsList() {
|
||||||
|
return this.authorFL ? this.authorFL.split(', ') : []
|
||||||
|
},
|
||||||
authorLF() {
|
authorLF() {
|
||||||
return this.book.authorLF
|
return this.book.authorLF
|
||||||
},
|
},
|
||||||
|
@ -59,7 +59,7 @@ export const getters = {
|
|||||||
if (filter === 'No Series') filtered = filtered.filter(ab => ab.book && !ab.book.series)
|
if (filter === 'No Series') filtered = filtered.filter(ab => ab.book && !ab.book.series)
|
||||||
else filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
else filtered = filtered.filter(ab => ab.book && ab.book.series === filter)
|
||||||
}
|
}
|
||||||
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.authorFL === filter)
|
else if (group === 'authors') filtered = filtered.filter(ab => ab.book && ab.book.authorFL && ab.book.authorFL.split(', ').includes(filter))
|
||||||
else if (group === 'narrators') filtered = filtered.filter(ab => ab.book && ab.book.narrator === filter)
|
else if (group === 'narrators') filtered = filtered.filter(ab => ab.book && ab.book.narrator === filter)
|
||||||
else if (group === 'progress') {
|
else if (group === 'progress') {
|
||||||
filtered = filtered.filter(ab => {
|
filtered = filtered.filter(ab => {
|
||||||
@ -132,8 +132,13 @@ export const getters = {
|
|||||||
return seriesArray
|
return seriesArray
|
||||||
},
|
},
|
||||||
getUniqueAuthors: (state) => {
|
getUniqueAuthors: (state) => {
|
||||||
var _authors = state.audiobooks.filter(ab => !!(ab.book && ab.book.authorFL)).map(ab => ab.book.authorFL)
|
var abAuthors = []
|
||||||
return [...new Set(_authors)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
state.audiobooks.forEach((ab) => {
|
||||||
|
if (ab.book && ab.book.authorFL) {
|
||||||
|
abAuthors = abAuthors.concat(ab.book.authorFL.split(', '))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return [...new Set(abAuthors)].sort((a, b) => a.toLowerCase() < b.toLowerCase() ? -1 : 1)
|
||||||
},
|
},
|
||||||
getUniqueNarrators: (state) => {
|
getUniqueNarrators: (state) => {
|
||||||
var _narrators = state.audiobooks.filter(ab => !!(ab.book && ab.book.narrator)).map(ab => ab.book.narrator)
|
var _narrators = state.audiobooks.filter(ab => !!(ab.book && ab.book.narrator)).map(ab => ab.book.narrator)
|
||||||
|
@ -174,10 +174,14 @@ class ApiController {
|
|||||||
}
|
}
|
||||||
bookMatches.push(bookMatchObj)
|
bookMatches.push(bookMatchObj)
|
||||||
}
|
}
|
||||||
if (queryResult.author && !authorMatches[queryResult.author]) {
|
if (queryResult.authors) {
|
||||||
authorMatches[queryResult.author] = {
|
queryResult.authors.forEach((author) => {
|
||||||
author: queryResult.author
|
if (!authorMatches[author]) {
|
||||||
}
|
authorMatches[author] = {
|
||||||
|
author: author
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
if (queryResult.series) {
|
if (queryResult.series) {
|
||||||
if (!seriesMatches[queryResult.series]) {
|
if (!seriesMatches[queryResult.series]) {
|
||||||
|
@ -37,6 +37,7 @@ class Book {
|
|||||||
get _narrator() { return this.narrator || '' }
|
get _narrator() { return this.narrator || '' }
|
||||||
get _author() { return this.authorFL || '' }
|
get _author() { return this.authorFL || '' }
|
||||||
get _series() { return this.series || '' }
|
get _series() { return this.series || '' }
|
||||||
|
get _authorsList() { return this._author.split(', ') }
|
||||||
|
|
||||||
get shouldSearchForCover() {
|
get shouldSearchForCover() {
|
||||||
if (this.authorFL !== this.lastCoverSearchAuthor || this.title !== this.lastCoverSearchTitle || !this.lastCoverSearch) return true
|
if (this.authorFL !== this.lastCoverSearchAuthor || this.title !== this.lastCoverSearchTitle || !this.lastCoverSearch) return true
|
||||||
@ -225,15 +226,18 @@ class Book {
|
|||||||
getQueryMatches(search) {
|
getQueryMatches(search) {
|
||||||
var titleMatch = this._title.toLowerCase().includes(search)
|
var titleMatch = this._title.toLowerCase().includes(search)
|
||||||
var subtitleMatch = this._subtitle.toLowerCase().includes(search)
|
var subtitleMatch = this._subtitle.toLowerCase().includes(search)
|
||||||
var authorMatch = this._author.toLowerCase().includes(search)
|
|
||||||
|
var authorsMatched = this._authorsList.filter(auth => auth.toLowerCase().includes(search))
|
||||||
|
|
||||||
|
// var authorMatch = this._author.toLowerCase().includes(search)
|
||||||
var seriesMatch = this._series.toLowerCase().includes(search)
|
var seriesMatch = this._series.toLowerCase().includes(search)
|
||||||
|
|
||||||
var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorMatch ? 'authorFL' : seriesMatch ? 'series' : false
|
var bookMatchKey = titleMatch ? 'title' : subtitleMatch ? 'subtitle' : authorsMatched.length ? 'authorFL' : seriesMatch ? 'series' : false
|
||||||
var bookMatchText = bookMatchKey ? this[bookMatchKey] : ''
|
var bookMatchText = bookMatchKey ? this[bookMatchKey] : ''
|
||||||
return {
|
return {
|
||||||
book: bookMatchKey,
|
book: bookMatchKey,
|
||||||
bookMatchText,
|
bookMatchText,
|
||||||
author: authorMatch ? this._author : false,
|
authors: authorsMatched.length ? authorsMatched : false,
|
||||||
series: seriesMatch ? this._series : false
|
series: seriesMatch ? this._series : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user