mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-10 01:15:06 +02:00
Add:Batch append details #848
This commit is contained in:
parent
05d10b73c3
commit
e59351566d
4 changed files with 93 additions and 47 deletions
|
@ -137,16 +137,33 @@ export default {
|
|||
author: (this.details.authors || []).map((au) => au.name).join(', ')
|
||||
}
|
||||
},
|
||||
mapBatchDetails(batchDetails) {
|
||||
mapBatchDetails(batchDetails, mapType = 'overwrite') {
|
||||
for (const key in batchDetails) {
|
||||
if (key === 'tags') {
|
||||
this.newTags = [...batchDetails.tags]
|
||||
} else if (key === 'genres' || key === 'narrators') {
|
||||
this.details[key] = [...batchDetails[key]]
|
||||
} else if (key === 'authors' || key === 'series') {
|
||||
this.details[key] = batchDetails[key].map((i) => ({ ...i }))
|
||||
if (mapType === 'append') {
|
||||
if (key === 'tags') {
|
||||
// Concat and remove dupes
|
||||
this.newTags = [...new Set(this.newTags.concat(batchDetails.tags))]
|
||||
} else if (key === 'genres' || key === 'narrators') {
|
||||
// Concat and remove dupes
|
||||
this.details[key] = [...new Set(this.details[key].concat(batchDetails[key]))]
|
||||
} else if (key === 'authors' || key === 'series') {
|
||||
batchDetails[key].forEach((detail) => {
|
||||
const existingDetail = this.details[key].find((_d) => _d.name.toLowerCase() == detail.name.toLowerCase().trim() || _d.id == detail.id)
|
||||
if (!existingDetail) {
|
||||
this.details[key].push({ ...detail })
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.details[key] = batchDetails[key]
|
||||
if (key === 'tags') {
|
||||
this.newTags = [...batchDetails.tags]
|
||||
} else if (key === 'genres' || key === 'narrators') {
|
||||
this.details[key] = [...batchDetails[key]]
|
||||
} else if (key === 'authors' || key === 'series') {
|
||||
this.details[key] = batchDetails[key].map((i) => ({ ...i }))
|
||||
} else {
|
||||
this.details[key] = batchDetails[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue