diff --git a/client/components/ui/MultiSelectQueryInput.vue b/client/components/ui/MultiSelectQueryInput.vue index 38ae937f..4bc8a53d 100644 --- a/client/components/ui/MultiSelectQueryInput.vue +++ b/client/components/ui/MultiSelectQueryInput.vue @@ -113,10 +113,13 @@ export default { if (this.searching) return this.currentSearch = this.textInput this.searching = true - var results = await this.$axios.$get(`/api/${this.endpoint}?q=${this.currentSearch}&limit=15&token=${this.userToken}`).catch((error) => { - console.error('Failed to get search results', error) - return [] - }) + const results = await this.$axios + .$get(`/api/${this.endpoint}?q=${this.currentSearch}&limit=15&token=${this.userToken}`) + .then((res) => res.results || res) + .catch((error) => { + console.error('Failed to get search results', error) + return [] + }) this.items = results || [] this.searching = false }, diff --git a/client/components/widgets/BookDetailsEdit.vue b/client/components/widgets/BookDetailsEdit.vue index f494eeef..5677b563 100644 --- a/client/components/widgets/BookDetailsEdit.vue +++ b/client/components/widgets/BookDetailsEdit.vue @@ -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] + } } } }, diff --git a/client/components/widgets/PodcastDetailsEdit.vue b/client/components/widgets/PodcastDetailsEdit.vue index a8181b48..8030028d 100644 --- a/client/components/widgets/PodcastDetailsEdit.vue +++ b/client/components/widgets/PodcastDetailsEdit.vue @@ -107,14 +107,24 @@ export default { author: this.details.author } }, - mapBatchDetails(batchDetails) { + mapBatchDetails(batchDetails, mapType = 'overwrite') { for (const key in batchDetails) { - if (key === 'tags') { - this.newTags = [...batchDetails.tags] - } else if (key === 'genres') { - this.details[key] = [...batchDetails[key]] + if (mapType === 'append') { + if (key === 'tags') { + // Concat and remove dupes + this.newTags = [...new Set(this.newTags.concat(batchDetails.tags))] + } else if (key === 'genres') { + // Concat and remove dupes + this.details[key] = [...new Set(this.details[key].concat(batchDetails[key]))] + } } else { - this.details[key] = batchDetails[key] + if (key === 'tags') { + this.newTags = [...batchDetails.tags] + } else if (key === 'genres') { + this.details[key] = [...batchDetails[key]] + } else { + this.details[key] = batchDetails[key] + } } } }, diff --git a/client/pages/batch/index.vue b/client/pages/batch/index.vue index fd5f6d89..10cfd1c5 100644 --- a/client/pages/batch/index.vue +++ b/client/pages/batch/index.vue @@ -5,11 +5,22 @@
Map details
+ + + +