diff --git a/client/components/app/Appbar.vue b/client/components/app/Appbar.vue index 382f5cf3..d625dac7 100644 --- a/client/components/app/Appbar.vue +++ b/client/components/app/Appbar.vue @@ -287,26 +287,37 @@ export default { }) }, batchDeleteClick() { - const audiobookText = this.numMediaItemsSelected > 1 ? `these ${this.numMediaItemsSelected} items` : 'this item' - const confirmMsg = `Are you sure you want to remove ${audiobookText}?\n\n*Does not delete your files, only removes the items from Audiobookshelf` - if (confirm(confirmMsg)) { - this.$store.commit('setProcessingBatch', true) - this.$axios - .$post(`/api/items/batch/delete`, { - libraryItemIds: this.selectedMediaItems.map((i) => i.id) - }) - .then(() => { - this.$toast.success('Batch delete success!') - this.$store.commit('setProcessingBatch', false) - this.$store.commit('globals/resetSelectedMediaItems', []) - this.$eventBus.$emit('bookshelf_clear_selection') - }) - .catch((error) => { - this.$toast.error('Batch delete failed') - console.error('Failed to batch delete', error) - this.$store.commit('setProcessingBatch', false) - }) + const payload = { + message: `This will delete ${this.numMediaItemsSelected} library items from the database and your file system. Are you sure?`, + checkboxLabel: 'Delete from file system. Uncheck to only remove from database.', + yesButtonText: this.$strings.ButtonDelete, + yesButtonColor: 'error', + checkboxDefaultValue: true, + callback: (confirmed, hardDelete) => { + if (confirmed) { + this.$store.commit('setProcessingBatch', true) + + this.$axios + .$post(`/api/items/batch/delete?hard=${hardDelete ? 1 : 0}`, { + libraryItemIds: this.selectedMediaItems.map((i) => i.id) + }) + .then(() => { + this.$toast.success('Batch delete success') + this.$store.commit('globals/resetSelectedMediaItems', []) + this.$eventBus.$emit('bookshelf_clear_selection') + }) + .catch((error) => { + console.error('Batch delete failed', error) + this.$toast.error('Batch delete failed') + }) + .finally(() => { + this.$store.commit('setProcessingBatch', false) + }) + } + }, + type: 'yesNo' } + this.$store.commit('globals/setConfirmPrompt', payload) }, batchEditClick() { this.$router.push('/batch') diff --git a/client/components/cards/LazyBookCard.vue b/client/components/cards/LazyBookCard.vue index c4d3e967..42a3be4e 100644 --- a/client/components/cards/LazyBookCard.vue +++ b/client/components/cards/LazyBookCard.vue @@ -526,6 +526,14 @@ export default { } } } + + if (this.userCanDelete) { + items.push({ + func: 'deleteLibraryItem', + text: this.$strings.ButtonDelete + }) + } + return items }, _socket() { @@ -777,6 +785,35 @@ export default { this.store.commit('globals/setSelectedPlaylistItems', [{ libraryItem: this.libraryItem, episode: this.recentEpisode }]) this.store.commit('globals/setShowPlaylistsModal', true) }, + deleteLibraryItem() { + const payload = { + message: 'This will delete the library item from the database and your file system. Are you sure?', + checkboxLabel: 'Delete from file system. Uncheck to only remove from database.', + yesButtonText: this.$strings.ButtonDelete, + yesButtonColor: 'error', + checkboxDefaultValue: true, + callback: (confirmed, hardDelete) => { + if (confirmed) { + this.processing = true + const axios = this.$axios || this.$nuxt.$axios + axios + .$delete(`/api/items/${this.libraryItemId}?hard=${hardDelete ? 1 : 0}`) + .then(() => { + this.$toast.success('Item deleted') + }) + .catch((error) => { + console.error('Failed to delete item', error) + this.$toast.error('Failed to delete item') + }) + .finally(() => { + this.processing = false + }) + } + }, + type: 'yesNo' + } + this.store.commit('globals/setConfirmPrompt', payload) + }, createMoreMenu() { if (!this.$refs.moreIcon) return diff --git a/client/components/modals/item/tabs/Details.vue b/client/components/modals/item/tabs/Details.vue index e95b8d57..14fe68a7 100644 --- a/client/components/modals/item/tabs/Details.vue +++ b/client/components/modals/item/tabs/Details.vue @@ -7,11 +7,6 @@