mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-01 00:18:14 +01:00
Add populate from buttons to batch edit
This commit is contained in:
parent
598a93d224
commit
79acc41d16
@ -86,7 +86,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w-full flex items-center justify-end p-4">
|
<div class="w-full flex items-center p-4 space-x-2">
|
||||||
|
<ui-btn small @click.stop="resetMapDetails">{{ $strings.ButtonReset }}</ui-btn>
|
||||||
|
<ui-tooltip direction="bottom" :text="$strings.MessageBatchEditPopulateMapDetailsAllHelp">
|
||||||
|
<ui-btn small :disabled="!hasSelectedBatchUsage" @click.stop="populateFromExisting()">{{ $strings.ButtonBatchEditPopulateFromExisting }}</ui-btn>
|
||||||
|
</ui-tooltip>
|
||||||
|
<div class="flex-grow" />
|
||||||
<ui-btn color="success" :disabled="!hasSelectedBatchUsage" :padding-x="8" small class="text-base" :loading="isProcessing" @click="mapBatchDetails">{{ $strings.ButtonApply }}</ui-btn>
|
<ui-btn color="success" :disabled="!hasSelectedBatchUsage" :padding-x="8" small class="text-base" :loading="isProcessing" @click="mapBatchDetails">{{ $strings.ButtonApply }}</ui-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -97,6 +102,11 @@
|
|||||||
<div class="flex justify-center flex-wrap">
|
<div class="flex justify-center flex-wrap">
|
||||||
<template v-for="libraryItem in libraryItemCopies">
|
<template v-for="libraryItem in libraryItemCopies">
|
||||||
<div :key="libraryItem.id" class="w-full max-w-3xl border border-black-300 p-6 -ml-px -mt-px">
|
<div :key="libraryItem.id" class="w-full max-w-3xl border border-black-300 p-6 -ml-px -mt-px">
|
||||||
|
<div class="flex items-center justify-end">
|
||||||
|
<ui-tooltip direction="bottom" :text="$strings.MessageBatchEditPopulateMapDetailsItemHelp">
|
||||||
|
<ui-btn small :disabled="!hasSelectedBatchUsage" @click="populateFromExisting(libraryItem.id)">{{ $strings.ButtonBatchEditPopulateMapDetails }}</ui-btn>
|
||||||
|
</ui-tooltip>
|
||||||
|
</div>
|
||||||
<widgets-book-details-edit v-if="libraryItem.mediaType === 'book'" :ref="`itemForm-${libraryItem.id}`" :library-item="libraryItem" @change="handleItemChange" />
|
<widgets-book-details-edit v-if="libraryItem.mediaType === 'book'" :ref="`itemForm-${libraryItem.id}`" :library-item="libraryItem" @change="handleItemChange" />
|
||||||
<widgets-podcast-details-edit v-else :ref="`itemForm-${libraryItem.id}`" :library-item="libraryItem" @change="handleItemChange" />
|
<widgets-podcast-details-edit v-else :ref="`itemForm-${libraryItem.id}`" :library-item="libraryItem" @change="handleItemChange" />
|
||||||
</div>
|
</div>
|
||||||
@ -228,6 +238,88 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
resetMapDetails() {
|
||||||
|
this.blurBatchForm()
|
||||||
|
this.batchDetails = {
|
||||||
|
subtitle: null,
|
||||||
|
authors: null,
|
||||||
|
publishedYear: null,
|
||||||
|
series: [],
|
||||||
|
genres: [],
|
||||||
|
tags: [],
|
||||||
|
narrators: [],
|
||||||
|
publisher: null,
|
||||||
|
language: null,
|
||||||
|
explicit: false,
|
||||||
|
abridged: false
|
||||||
|
}
|
||||||
|
this.selectedBatchUsage = {
|
||||||
|
subtitle: false,
|
||||||
|
authors: false,
|
||||||
|
publishedYear: false,
|
||||||
|
series: false,
|
||||||
|
genres: false,
|
||||||
|
tags: false,
|
||||||
|
narrators: false,
|
||||||
|
publisher: false,
|
||||||
|
language: false,
|
||||||
|
explicit: false,
|
||||||
|
abridged: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
populateFromExisting(libraryItemId) {
|
||||||
|
this.blurBatchForm()
|
||||||
|
|
||||||
|
let libraryItemsToMap = this.libraryItemCopies
|
||||||
|
if (libraryItemId) {
|
||||||
|
libraryItemsToMap = this.libraryItemCopies.filter((li) => li.id === libraryItemId)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key in this.selectedBatchUsage) {
|
||||||
|
if (!this.selectedBatchUsage[key]) continue
|
||||||
|
if (this.isMapAppend && !this.appendableKeys.includes(key)) continue
|
||||||
|
|
||||||
|
let existingValues = undefined
|
||||||
|
libraryItemsToMap.forEach((li) => {
|
||||||
|
if (key === 'tags') {
|
||||||
|
if (!existingValues) existingValues = []
|
||||||
|
li.media.tags.forEach((tag) => {
|
||||||
|
if (!existingValues.includes(tag)) {
|
||||||
|
existingValues.push(tag)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (key === 'authors') {
|
||||||
|
if (!existingValues) existingValues = []
|
||||||
|
li.media.metadata[key].forEach((entity) => {
|
||||||
|
if (!existingValues.some((au) => au.id === entity.id)) {
|
||||||
|
existingValues.push({
|
||||||
|
id: entity.id,
|
||||||
|
name: entity.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (key === 'series') {
|
||||||
|
if (!existingValues) existingValues = []
|
||||||
|
li.media.metadata[key].forEach((entity) => {
|
||||||
|
if (!existingValues.includes(entity.name)) {
|
||||||
|
existingValues.push(entity.name)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (key === 'genres' || key === 'narrators') {
|
||||||
|
if (!existingValues) existingValues = []
|
||||||
|
li.media.metadata[key].forEach((item) => {
|
||||||
|
if (!existingValues.includes(item)) {
|
||||||
|
existingValues.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (existingValues === undefined) {
|
||||||
|
existingValues = li.media.metadata[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.batchDetails[key] = existingValues
|
||||||
|
}
|
||||||
|
},
|
||||||
handleItemChange(itemChange) {
|
handleItemChange(itemChange) {
|
||||||
if (!itemChange.hasChanges) {
|
if (!itemChange.hasChanges) {
|
||||||
this.itemsWithChanges = this.itemsWithChanges.filter((id) => id !== itemChange.libraryItemId)
|
this.itemsWithChanges = this.itemsWithChanges.filter((id) => id !== itemChange.libraryItemId)
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
"ButtonApplyChapters": "Apply Chapters",
|
"ButtonApplyChapters": "Apply Chapters",
|
||||||
"ButtonAuthors": "Authors",
|
"ButtonAuthors": "Authors",
|
||||||
"ButtonBack": "Back",
|
"ButtonBack": "Back",
|
||||||
|
"ButtonBatchEditPopulateFromExisting": "Populate from existing",
|
||||||
|
"ButtonBatchEditPopulateMapDetails": "Populate map details",
|
||||||
"ButtonBrowseForFolder": "Browse for Folder",
|
"ButtonBrowseForFolder": "Browse for Folder",
|
||||||
"ButtonCancel": "Cancel",
|
"ButtonCancel": "Cancel",
|
||||||
"ButtonCancelEncode": "Cancel Encode",
|
"ButtonCancelEncode": "Cancel Encode",
|
||||||
@ -705,6 +707,8 @@
|
|||||||
"MessageBackupsLocationNoEditNote": "Note: The backup location is set through an environment variable and cannot be changed here.",
|
"MessageBackupsLocationNoEditNote": "Note: The backup location is set through an environment variable and cannot be changed here.",
|
||||||
"MessageBackupsLocationPathEmpty": "Backup location path cannot be empty",
|
"MessageBackupsLocationPathEmpty": "Backup location path cannot be empty",
|
||||||
"MessageBatchQuickMatchDescription": "Quick Match will attempt to add missing covers and metadata for the selected items. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.",
|
"MessageBatchQuickMatchDescription": "Quick Match will attempt to add missing covers and metadata for the selected items. Enable the options below to allow Quick Match to overwrite existing covers and/or metadata.",
|
||||||
|
"MessageBatchEditPopulateMapDetailsAllHelp": "Populate enabled fields with data from all items. Fields with multiple values will be merged",
|
||||||
|
"MessageBatchEditPopulateMapDetailsItemHelp": "Populate enabled map details fields with data from this item",
|
||||||
"MessageBookshelfNoCollections": "You haven't made any collections yet",
|
"MessageBookshelfNoCollections": "You haven't made any collections yet",
|
||||||
"MessageBookshelfNoRSSFeeds": "No RSS feeds are open",
|
"MessageBookshelfNoRSSFeeds": "No RSS feeds are open",
|
||||||
"MessageBookshelfNoResultsForFilter": "No results for filter \"{0}: {1}\"",
|
"MessageBookshelfNoResultsForFilter": "No results for filter \"{0}: {1}\"",
|
||||||
|
Loading…
Reference in New Issue
Block a user