mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
Allow items to be moved between libraries
This commit is contained in:
parent
a627dd5009
commit
37626b8d60
9 changed files with 450 additions and 1 deletions
|
|
@ -601,6 +601,10 @@ export default {
|
|||
}
|
||||
|
||||
if (this.userCanDelete) {
|
||||
items.push({
|
||||
func: 'openMoveToLibraryModal',
|
||||
text: this.$strings.ButtonMoveToLibrary
|
||||
})
|
||||
items.push({
|
||||
func: 'deleteLibraryItem',
|
||||
text: this.$strings.ButtonDelete
|
||||
|
|
@ -904,6 +908,10 @@ export default {
|
|||
this.store.commit('setSelectedLibraryItem', this.libraryItem)
|
||||
this.store.commit('globals/setShareModal', this.mediaItemShare)
|
||||
},
|
||||
openMoveToLibraryModal() {
|
||||
this.store.commit('setSelectedLibraryItem', this.libraryItem)
|
||||
this.store.commit('globals/setShowMoveToLibraryModal', true)
|
||||
},
|
||||
deleteLibraryItem() {
|
||||
const payload = {
|
||||
message: this.$strings.MessageConfirmDeleteLibraryItem,
|
||||
|
|
|
|||
152
client/components/modals/item/MoveToLibraryModal.vue
Normal file
152
client/components/modals/item/MoveToLibraryModal.vue
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
<template>
|
||||
<modals-modal ref="modal" v-model="show" name="move-to-library" :width="400" :height="'unset'" :processing="processing">
|
||||
<template #outer>
|
||||
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
||||
<p class="text-3xl text-white truncate">{{ $strings.LabelMoveToLibrary }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<div class="px-6 py-8 w-full text-sm rounded-lg bg-bg shadow-lg border border-black-300 overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
|
||||
<template v-if="libraryItem">
|
||||
<div class="w-full mb-4">
|
||||
<p class="text-gray-300 mb-2">{{ $strings.LabelMovingItem }}:</p>
|
||||
<p class="text-lg font-semibold text-white">{{ itemTitle }}</p>
|
||||
</div>
|
||||
|
||||
<template v-if="targetLibraries.length">
|
||||
<div class="w-full mb-4">
|
||||
<label class="px-1 text-sm font-semibold block mb-1">{{ $strings.LabelSelectTargetLibrary }}</label>
|
||||
<ui-dropdown v-model="selectedLibraryId" :items="libraryOptions" />
|
||||
</div>
|
||||
|
||||
<div v-if="selectedLibraryFolders.length > 1" class="w-full mb-4">
|
||||
<label class="px-1 text-sm font-semibold block mb-1">{{ $strings.LabelSelectTargetFolder }}</label>
|
||||
<ui-dropdown v-model="selectedFolderId" :items="folderOptions" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="w-full py-4">
|
||||
<p class="text-warning text-center">{{ $strings.MessageNoCompatibleLibraries }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<div class="flex items-center pt-4">
|
||||
<div class="grow" />
|
||||
<ui-btn v-if="targetLibraries.length" color="success" :disabled="!selectedLibraryId" small @click="moveItem">{{ $strings.ButtonMove }}</ui-btn>
|
||||
</div>
|
||||
</div>
|
||||
</modals-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
processing: false,
|
||||
selectedLibraryId: null,
|
||||
selectedFolderId: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show: {
|
||||
handler(newVal) {
|
||||
if (newVal) {
|
||||
this.init()
|
||||
}
|
||||
}
|
||||
},
|
||||
selectedLibraryId() {
|
||||
// Reset folder selection when library changes
|
||||
if (this.selectedLibraryFolders.length) {
|
||||
this.selectedFolderId = this.selectedLibraryFolders[0].id
|
||||
} else {
|
||||
this.selectedFolderId = null
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
show: {
|
||||
get() {
|
||||
return this.$store.state.globals.showMoveToLibraryModal
|
||||
},
|
||||
set(val) {
|
||||
this.$store.commit('globals/setShowMoveToLibraryModal', val)
|
||||
}
|
||||
},
|
||||
libraryItem() {
|
||||
return this.$store.state.selectedLibraryItem
|
||||
},
|
||||
itemTitle() {
|
||||
return this.libraryItem?.media?.title || this.libraryItem?.media?.metadata?.title || ''
|
||||
},
|
||||
currentLibraryId() {
|
||||
return this.libraryItem?.libraryId
|
||||
},
|
||||
currentMediaType() {
|
||||
// Get media type from the current library
|
||||
const currentLibrary = this.$store.state.libraries.libraries.find((l) => l.id === this.currentLibraryId)
|
||||
return currentLibrary?.mediaType || 'book'
|
||||
},
|
||||
targetLibraries() {
|
||||
// Filter libraries to only show compatible ones (same media type, different library)
|
||||
return this.$store.state.libraries.libraries.filter((l) => l.mediaType === this.currentMediaType && l.id !== this.currentLibraryId)
|
||||
},
|
||||
libraryOptions() {
|
||||
return this.targetLibraries.map((lib) => ({
|
||||
text: lib.name,
|
||||
value: lib.id
|
||||
}))
|
||||
},
|
||||
selectedLibrary() {
|
||||
return this.targetLibraries.find((l) => l.id === this.selectedLibraryId)
|
||||
},
|
||||
selectedLibraryFolders() {
|
||||
return this.selectedLibrary?.folders || []
|
||||
},
|
||||
folderOptions() {
|
||||
return this.selectedLibraryFolders.map((folder) => ({
|
||||
text: folder.fullPath,
|
||||
value: folder.id
|
||||
}))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async moveItem() {
|
||||
if (!this.selectedLibraryId) return
|
||||
|
||||
const payload = {
|
||||
targetLibraryId: this.selectedLibraryId
|
||||
}
|
||||
|
||||
if (this.selectedFolderId && this.selectedLibraryFolders.length > 1) {
|
||||
payload.targetFolderId = this.selectedFolderId
|
||||
}
|
||||
|
||||
this.processing = true
|
||||
try {
|
||||
const response = await this.$axios.$post(`/api/items/${this.libraryItem.id}/move`, payload)
|
||||
if (response.success) {
|
||||
this.$toast.success(this.$strings.ToastItemMoved)
|
||||
this.show = false
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to move item', error)
|
||||
const errorMsg = error.response?.data || this.$strings.ToastItemMoveFailed
|
||||
this.$toast.error(errorMsg)
|
||||
} finally {
|
||||
this.processing = false
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.selectedLibraryId = null
|
||||
this.selectedFolderId = null
|
||||
// Pre-select first available library if any
|
||||
if (this.targetLibraries.length) {
|
||||
this.selectedLibraryId = this.targetLibraries[0].id
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
<modals-rssfeed-open-close-modal />
|
||||
<modals-raw-cover-preview-modal />
|
||||
<modals-share-modal />
|
||||
<modals-item-move-to-library-modal />
|
||||
<prompt-confirm />
|
||||
<readers-reader />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export const state = () => ({
|
|||
isCasting: false, // Actively casting
|
||||
isChromecastInitialized: false, // Script loadeds
|
||||
showBatchQuickMatchModal: false,
|
||||
showMoveToLibraryModal: false,
|
||||
dateFormats: [
|
||||
{
|
||||
text: 'MM/DD/YYYY',
|
||||
|
|
@ -204,6 +205,9 @@ export const mutations = {
|
|||
setShowBatchQuickMatchModal(state, val) {
|
||||
state.showBatchQuickMatchModal = val
|
||||
},
|
||||
setShowMoveToLibraryModal(state, val) {
|
||||
state.showMoveToLibraryModal = val
|
||||
},
|
||||
resetSelectedMediaItems(state) {
|
||||
state.selectedMediaItems = []
|
||||
},
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@
|
|||
"ButtonCreate": "Create",
|
||||
"ButtonCreateBackup": "Create Backup",
|
||||
"ButtonDelete": "Delete",
|
||||
"ButtonMove": "Move",
|
||||
"ButtonMoveToLibrary": "Move to library",
|
||||
"ButtonDownloadQueue": "Queue",
|
||||
"ButtonEdit": "Edit",
|
||||
"ButtonEditChapters": "Edit Chapters",
|
||||
|
|
@ -465,6 +467,8 @@
|
|||
"LabelMissing": "Missing",
|
||||
"LabelMissingEbook": "Has no ebook",
|
||||
"LabelMissingSupplementaryEbook": "Has no supplementary ebook",
|
||||
"LabelMoveToLibrary": "Move to Library",
|
||||
"LabelMovingItem": "Moving item",
|
||||
"LabelMobileRedirectURIs": "Allowed Mobile Redirect URIs",
|
||||
"LabelMobileRedirectURIsDescription": "This is a whitelist of valid redirect URIs for mobile apps. The default one is <code>audiobookshelf://oauth</code>, which you can remove or supplement with additional URIs for third-party app integration. Using an asterisk (<code>*</code>) as the sole entry permits any URI.",
|
||||
"LabelMore": "More",
|
||||
|
|
@ -572,6 +576,8 @@
|
|||
"LabelSelectEpisodesShowing": "Select {0} episodes showing",
|
||||
"LabelSelectUser": "Select user",
|
||||
"LabelSelectUsers": "Select users",
|
||||
"LabelSelectTargetLibrary": "Select target library",
|
||||
"LabelSelectTargetFolder": "Select target folder",
|
||||
"LabelSendEbookToDevice": "Send Ebook to...",
|
||||
"LabelSequence": "Sequence",
|
||||
"LabelSerial": "Serial",
|
||||
|
|
@ -850,6 +856,7 @@
|
|||
"MessageNoEpisodes": "No Episodes",
|
||||
"MessageNoFoldersAvailable": "No Folders Available",
|
||||
"MessageNoGenres": "No Genres",
|
||||
"MessageNoCompatibleLibraries": "No other compatible libraries available",
|
||||
"MessageNoIssues": "No Issues",
|
||||
"MessageNoItems": "No Items",
|
||||
"MessageNoItemsFound": "No items found",
|
||||
|
|
@ -1056,6 +1063,8 @@
|
|||
"ToastItemCoverUpdateSuccess": "Item cover updated",
|
||||
"ToastItemDeletedFailed": "Failed to delete item",
|
||||
"ToastItemDeletedSuccess": "Deleted item",
|
||||
"ToastItemMoved": "Item moved successfully",
|
||||
"ToastItemMoveFailed": "Failed to move item",
|
||||
"ToastItemDetailsUpdateSuccess": "Item details updated",
|
||||
"ToastItemMarkedAsFinishedFailed": "Failed to mark as Finished",
|
||||
"ToastItemMarkedAsFinishedSuccess": "Item marked as Finished",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue