mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-07 16:44:16 +01:00
Fix:Library collapsed series to respect ignore prefixes setting #866
This commit is contained in:
parent
377ae7ab19
commit
06b8d1194c
@ -249,11 +249,9 @@ export default {
|
||||
},
|
||||
displayTitle() {
|
||||
if (this.recentEpisode) return this.recentEpisode.title
|
||||
if (this.collapsedSeries) return this.collapsedSeries.name
|
||||
if (this.orderBy === 'media.metadata.title' && this.sortingIgnorePrefix) {
|
||||
return this.mediaMetadata.titleIgnorePrefix
|
||||
}
|
||||
return this.title
|
||||
const ignorePrefix = this.orderBy === 'media.metadata.title' && this.sortingIgnorePrefix
|
||||
if (this.collapsedSeries) return ignorePrefix ? this.collapsedSeries.nameIgnorePrefix : this.collapsedSeries.name
|
||||
return ignorePrefix ? this.mediaMetadata.titleIgnorePrefix : this.title
|
||||
},
|
||||
displayLineTwo() {
|
||||
if (this.recentEpisode) return this.title
|
||||
|
@ -69,6 +69,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
clickedOutside(evt) {
|
||||
if (!this.show) return
|
||||
if (evt) {
|
||||
evt.stopPropagation()
|
||||
evt.preventDefault()
|
||||
|
@ -190,7 +190,7 @@ class LibraryController {
|
||||
// When collapsing by series and sorting by title use the series name instead of the book title
|
||||
if (payload.mediaType === 'book' && payload.collapseseries && li.media.metadata.seriesName) {
|
||||
if (sortByTitle) {
|
||||
return li.media.metadata.seriesName
|
||||
return this.db.serverSettings.sortingIgnorePrefix ? li.media.metadata.seriesNameIgnorePrefix : li.media.metadata.seriesName
|
||||
} else {
|
||||
// When not sorting by title always show the collapsed series at the end
|
||||
return direction === 'desc' ? -1 : 'zzzz'
|
||||
|
@ -1,5 +1,5 @@
|
||||
const Logger = require('../../Logger')
|
||||
const { areEquivalent, copyValue, cleanStringForSearch } = require('../../utils/index')
|
||||
const { areEquivalent, copyValue, cleanStringForSearch, getTitleIgnorePrefix } = require('../../utils/index')
|
||||
const parseNameString = require('../../utils/parsers/parseNameString')
|
||||
class BookMetadata {
|
||||
constructor(metadata) {
|
||||
@ -109,15 +109,7 @@ class BookMetadata {
|
||||
}
|
||||
|
||||
get titleIgnorePrefix() {
|
||||
if (!this.title) return ''
|
||||
var prefixesToIgnore = global.ServerSettings.sortingPrefixes || []
|
||||
for (const prefix of prefixesToIgnore) {
|
||||
// e.g. for prefix "the". If title is "The Book Title" return "Book Title, The"
|
||||
if (this.title.toLowerCase().startsWith(`${prefix} `)) {
|
||||
return this.title.substr(prefix.length + 1) + `, ${prefix.substr(0, 1).toUpperCase() + prefix.substr(1)}`
|
||||
}
|
||||
}
|
||||
return this.title
|
||||
return getTitleIgnorePrefix(this.title)
|
||||
}
|
||||
get authorName() {
|
||||
if (!this.authors.length) return ''
|
||||
@ -134,6 +126,13 @@ class BookMetadata {
|
||||
return `${se.name} #${se.sequence}`
|
||||
}).join(', ')
|
||||
}
|
||||
get seriesNameIgnorePrefix() {
|
||||
if (!this.series.length) return ''
|
||||
return this.series.map(se => {
|
||||
if (!se.sequence) return getTitleIgnorePrefix(se.name)
|
||||
return `${getTitleIgnorePrefix(se.name)} #${se.sequence}`
|
||||
}).join(', ')
|
||||
}
|
||||
get narratorName() {
|
||||
return this.narrators.join(', ')
|
||||
}
|
||||
|
@ -135,4 +135,16 @@ module.exports.cleanStringForSearch = (str) => {
|
||||
if (!str) return ''
|
||||
// Remove ' . ` " ,
|
||||
return str.toLowerCase().replace(/[\'\.\`\",]/g, '').trim()
|
||||
}
|
||||
|
||||
module.exports.getTitleIgnorePrefix = (title) => {
|
||||
if (!title) return ''
|
||||
var prefixesToIgnore = global.ServerSettings.sortingPrefixes || []
|
||||
for (const prefix of prefixesToIgnore) {
|
||||
// e.g. for prefix "the". If title is "The Book" return "Book, The"
|
||||
if (title.toLowerCase().startsWith(`${prefix} `)) {
|
||||
return title.substr(prefix.length + 1) + `, ${prefix.substr(0, 1).toUpperCase() + prefix.substr(1)}`
|
||||
}
|
||||
}
|
||||
return title
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
const { sort, createNewSortInstance } = require('../libs/fastSort')
|
||||
const { getTitleIgnorePrefix } = require('../utils/index')
|
||||
const Logger = require('../Logger')
|
||||
const naturalSort = createNewSortInstance({
|
||||
comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare
|
||||
@ -228,6 +229,7 @@ module.exports = {
|
||||
libraryItemJson.collapsedSeries = {
|
||||
id: seriesToUse[li.id].id,
|
||||
name: seriesToUse[li.id].name,
|
||||
nameIgnorePrefix: getTitleIgnorePrefix(seriesToUse[li.id].name),
|
||||
numBooks: seriesToUse[li.id].books.length
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user