mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-15 03:45:03 +02:00
New data model for global search input and search page
This commit is contained in:
parent
30f15d3575
commit
ea9ec13845
16 changed files with 241 additions and 88 deletions
|
@ -91,6 +91,13 @@ class BookMetadata {
|
|||
if (!this.authors.length) return ''
|
||||
return this.authors.map(au => au.name).join(', ')
|
||||
}
|
||||
get seriesName() {
|
||||
if (!this.series.length) return ''
|
||||
return this.series.map(se => {
|
||||
if (!se.sequence) return se.name
|
||||
return `${se.name} #${se.sequence}`
|
||||
}).join(', ')
|
||||
}
|
||||
get narratorName() {
|
||||
return this.narrators.join(', ')
|
||||
}
|
||||
|
@ -268,5 +275,24 @@ class BookMetadata {
|
|||
sequence: sequenceTag || ''
|
||||
}]
|
||||
}
|
||||
|
||||
searchSeries(query) {
|
||||
return this.series.filter(se => se.name.toLowerCase().includes(query))
|
||||
}
|
||||
searchAuthors(query) {
|
||||
return this.authors.filter(se => se.name.toLowerCase().includes(query))
|
||||
}
|
||||
searchQuery(query) { // Returns key if match is found
|
||||
var keysToCheck = ['title', 'asin', 'isbn']
|
||||
for (var key of keysToCheck) {
|
||||
if (this[key] && this[key].toLowerCase().includes(query)) {
|
||||
return {
|
||||
matchKey: key,
|
||||
matchText: this[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
module.exports = BookMetadata
|
Loading…
Add table
Add a link
Reference in a new issue