diff --git a/client/components/app/BookShelfToolbar.vue b/client/components/app/BookShelfToolbar.vue index c9989868..8a8f5f88 100644 --- a/client/components/app/BookShelfToolbar.vue +++ b/client/components/app/BookShelfToolbar.vue @@ -109,13 +109,7 @@ export default { totalEntities: 0, processingSeries: false, processingIssues: false, - processingAuthors: false, - contextMenuItems: [ - { - text: 'cat', - action: 'dog' - } - ] + processingAuthors: false } }, computed: { diff --git a/client/components/tables/library/LibraryItem.vue b/client/components/tables/library/LibraryItem.vue index f378e9ac..4b881304 100644 --- a/client/components/tables/library/LibraryItem.vue +++ b/client/components/tables/library/LibraryItem.vue @@ -1,32 +1,29 @@ @@ -63,34 +60,45 @@ export default { menuTitle() { return this.library.name }, - mobileMenuItems() { + contextMenuItems() { const items = [ + { + text: this.$strings.ButtonEdit, + action: 'edit', + value: 'edit' + }, { text: this.$strings.ButtonScan, + action: 'scan', value: 'scan' }, { text: this.$strings.ButtonForceReScan, + action: 'force-scan', value: 'force-scan' } ] if (this.isBookLibrary) { items.push({ text: this.$strings.ButtonMatchBooks, + action: 'match-books', value: 'match-books' }) } items.push({ text: this.$strings.ButtonDelete, + action: 'delete', value: 'delete' }) return items } }, methods: { - mobileMenuAction(action) { + contextMenuAction(action) { this.showMobileMenu = false - if (action === 'scan') { + if (action === 'edit') { + this.editClick() + } else if (action === 'scan') { this.scan() } else if (action === 'force-scan') { this.forceScan() @@ -130,37 +138,52 @@ export default { }) }, forceScan() { - if (confirm(this.$strings.MessageConfirmForceReScan)) { - this.$store - .dispatch('libraries/requestLibraryScan', { libraryId: this.library.id, force: 1 }) - .then(() => { - this.$toast.success(this.$strings.ToastLibraryScanStarted) - }) - .catch((error) => { - console.error('Failed to start scan', error) - this.$toast.error(this.$strings.ToastLibraryScanFailedToStart) - }) + const payload = { + message: this.$strings.MessageConfirmForceReScan, + callback: (confirmed) => { + if (confirmed) { + this.$store + .dispatch('libraries/requestLibraryScan', { libraryId: this.library.id, force: 1 }) + .then(() => { + this.$toast.success(this.$strings.ToastLibraryScanStarted) + }) + .catch((error) => { + console.error('Failed to start scan', error) + this.$toast.error(this.$strings.ToastLibraryScanFailedToStart) + }) + } + }, + type: 'yesNo' } + this.$store.commit('globals/setConfirmPrompt', payload) }, deleteClick() { - if (confirm(this.$getString('MessageConfirmDeleteLibrary', [this.library.name]))) { - this.isDeleting = true - this.$axios - .$delete(`/api/libraries/${this.library.id}`) - .then((data) => { - this.isDeleting = false - if (data.error) { - this.$toast.error(data.error) - } else { - this.$toast.success(this.$strings.ToastLibraryDeleteSuccess) - } - }) - .catch((error) => { - console.error('Failed to delete library', error) - this.$toast.error(this.$strings.ToastLibraryDeleteFailed) - this.isDeleting = false - }) + const payload = { + message: this.$getString('MessageConfirmDeleteLibrary', [this.library.name]), + callback: (confirmed) => { + if (confirmed) { + this.isDeleting = true + this.$axios + .$delete(`/api/libraries/${this.library.id}`) + .then((data) => { + if (data.error) { + this.$toast.error(data.error) + } else { + this.$toast.success(this.$strings.ToastLibraryDeleteSuccess) + } + }) + .catch((error) => { + console.error('Failed to delete library', error) + this.$toast.error(this.$strings.ToastLibraryDeleteFailed) + }) + .finally(() => { + this.isDeleting = false + }) + } + }, + type: 'yesNo' } + this.$store.commit('globals/setConfirmPrompt', payload) } }, mounted() {} diff --git a/client/components/ui/ContextMenuDropdown.vue b/client/components/ui/ContextMenuDropdown.vue index 988f7469..018bf34b 100644 --- a/client/components/ui/ContextMenuDropdown.vue +++ b/client/components/ui/ContextMenuDropdown.vue @@ -1,7 +1,7 @@