diff --git a/komga-webui/src/components/Dialogs.vue b/komga-webui/src/components/Dialogs.vue index 6c37e90f..cfec82de 100644 --- a/komga-webui/src/components/Dialogs.vue +++ b/komga-webui/src/components/Dialogs.vue @@ -10,9 +10,14 @@ :collection="editCollection" /> - - - import CollectionAddToDialog from '@/components/dialogs/CollectionAddToDialog.vue' -import CollectionDeleteDialog from '@/components/dialogs/CollectionDeleteDialog.vue' import CollectionEditDialog from '@/components/dialogs/CollectionEditDialog.vue' import EditBooksDialog from '@/components/dialogs/EditBooksDialog.vue' import EditSeriesDialog from '@/components/dialogs/EditSeriesDialog.vue' -import LibraryDeleteDialog from '@/components/dialogs/LibraryDeleteDialog.vue' import LibraryEditDialog from '@/components/dialogs/LibraryEditDialog.vue' import Vue from 'vue' import ReadListAddToDialog from '@/components/dialogs/ReadListAddToDialog.vue' -import ReadListDeleteDialog from '@/components/dialogs/ReadListDeleteDialog.vue' import ReadListEditDialog from '@/components/dialogs/ReadListEditDialog.vue' import {BookDto} from '@/types/komga-books' import {SeriesDto} from "@/types/komga-series"; +import {ERROR} from "@/types/events"; +import ConfirmationDialog from "@/components/dialogs/ConfirmationDialog.vue"; export default Vue.extend({ name: 'Dialogs', components: { + ConfirmationDialog, CollectionAddToDialog, CollectionEditDialog, - CollectionDeleteDialog, ReadListAddToDialog, ReadListEditDialog, - ReadListDeleteDialog, LibraryEditDialog, - LibraryDeleteDialog, EditBooksDialog, EditSeriesDialog, }, computed: { // collections addToCollectionDialog: { - get (): boolean { + get(): boolean { return this.$store.state.addToCollectionDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogAddSeriesToCollectionDisplay', val) }, }, - addToCollectionSeries (): SeriesDto | SeriesDto[] { + addToCollectionSeries(): SeriesDto | SeriesDto[] { return this.$store.state.addToCollectionSeries }, editCollectionDialog: { - get (): boolean { + get(): boolean { return this.$store.state.editCollectionDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogEditCollectionDisplay', val) }, }, - editCollection (): CollectionDto { + editCollection(): CollectionDto { return this.$store.state.editCollection }, deleteCollectionDialog: { - get (): boolean { + get(): boolean { return this.$store.state.deleteCollectionDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogDeleteCollectionDisplay', val) }, }, - deleteCollections (): CollectionDto | CollectionDto[] { + collectionsToDelete(): CollectionDto | CollectionDto[] { return this.$store.state.deleteCollections }, + collectionsToDeleteSingle(): boolean { + return !Array.isArray(this.collectionsToDelete) + }, // read lists addToReadListDialog: { - get (): boolean { + get(): boolean { return this.$store.state.addToReadListDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogAddBooksToReadListDisplay', val) }, }, - addToReadListBooks (): BookDto | BookDto[] { + addToReadListBooks(): BookDto | BookDto[] { return this.$store.state.addToReadListBooks }, editReadListDialog: { - get (): boolean { + get(): boolean { return this.$store.state.editReadListDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogEditReadListDisplay', val) }, }, - editReadList (): ReadListDto { + editReadList(): ReadListDto { return this.$store.state.editReadList }, deleteReadListDialog: { - get (): boolean { + get(): boolean { return this.$store.state.deleteReadListDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogDeleteReadListDisplay', val) }, }, - deleteReadLists (): ReadListDto | ReadListDto[] { + readListsToDelete(): ReadListDto | ReadListDto[] { return this.$store.state.deleteReadLists }, + readListsToDeleteSingle(): boolean { + return !Array.isArray(this.readListsToDelete) + }, // libraries editLibraryDialog: { - get (): boolean { + get(): boolean { return this.$store.state.editLibraryDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogEditLibraryDisplay', val) }, }, - editLibrary (): LibraryDto | undefined { + editLibrary(): LibraryDto | undefined { return this.$store.state.editLibrary }, deleteLibraryDialog: { - get (): boolean { + get(): boolean { return this.$store.state.deleteLibraryDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogDeleteLibraryDisplay', val) }, }, - deleteLibrary (): LibraryDto { + libraryToDelete(): LibraryDto { return this.$store.state.deleteLibrary }, // books updateBooksDialog: { - get (): boolean { + get(): boolean { return this.$store.state.updateBooksDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogUpdateBooksDisplay', val) }, }, - updateBooks (): BookDto | BookDto[] { + updateBooks(): BookDto | BookDto[] { return this.$store.state.updateBooks }, // series updateSeriesDialog: { - get (): boolean { + get(): boolean { return this.$store.state.updateSeriesDialog }, - set (val) { + set(val) { this.$store.dispatch('dialogUpdateSeriesDisplay', val) }, }, - updateSeries (): SeriesDto | SeriesDto[] { + updateSeries(): SeriesDto | SeriesDto[] { return this.$store.state.updateSeries }, }, + methods: { + async deleteLibrary() { + try { + await this.$store.dispatch('deleteLibrary', this.libraryToDelete) + } catch (e) { + this.$eventHub.$emit(ERROR, {message: e.message} as ErrorEvent) + } + }, + async deleteReadLists() { + const toUpdate = (this.readListsToDeleteSingle ? [this.readListsToDelete] : this.readListsToDelete) as ReadListDto[] + for (const b of toUpdate) { + try { + await this.$komgaReadLists.deleteReadList(b.id) + } catch (e) { + this.$eventHub.$emit(ERROR, {message: e.message} as ErrorEvent) + } + } + }, + async deleteCollections() { + const toUpdate = (this.collectionsToDeleteSingle ? [this.collectionsToDelete] : this.collectionsToDelete) as CollectionDto[] + for (const b of toUpdate) { + try { + await this.$komgaCollections.deleteCollection(b.id) + } catch (e) { + this.$eventHub.$emit(ERROR, {message: e.message} as ErrorEvent) + } + } + }, + }, }) diff --git a/komga-webui/src/components/UsersList.vue b/komga-webui/src/components/UsersList.vue index a3c1918d..1b0a9d43 100644 --- a/komga-webui/src/components/UsersList.vue +++ b/komga-webui/src/components/UsersList.vue @@ -105,25 +105,37 @@ :user="userToEdit" /> - - + diff --git a/komga-webui/src/components/dialogs/CollectionDeleteDialog.vue b/komga-webui/src/components/dialogs/CollectionDeleteDialog.vue deleted file mode 100644 index 87225d27..00000000 --- a/komga-webui/src/components/dialogs/CollectionDeleteDialog.vue +++ /dev/null @@ -1,110 +0,0 @@ - - - - - diff --git a/komga-webui/src/components/dialogs/ConfirmationDialog.vue b/komga-webui/src/components/dialogs/ConfirmationDialog.vue index 36344fec..298ea454 100644 --- a/komga-webui/src/components/dialogs/ConfirmationDialog.vue +++ b/komga-webui/src/components/dialogs/ConfirmationDialog.vue @@ -8,7 +8,18 @@ - {{ body }} + {{ body }} + + + + + + + + + @@ -18,6 +29,7 @@ {{ buttonCancel || $t('common.cancel') }} {{ buttonConfirm }} @@ -33,6 +45,7 @@ export default Vue.extend({ data: () => { return { modal: false, + confirmation: false, } }, props: { @@ -43,7 +56,15 @@ export default Vue.extend({ }, body: { type: String, - required: true, + required: false, + }, + bodyHtml: { + type: String, + required: false, + }, + confirmText: { + type: String, + required: false, }, buttonCancel: { type: String, @@ -68,6 +89,7 @@ export default Vue.extend({ }, methods: { dialogCancel() { + this.confirmation = false this.$emit('input', false) }, dialogConfirm() { diff --git a/komga-webui/src/components/dialogs/LibraryDeleteDialog.vue b/komga-webui/src/components/dialogs/LibraryDeleteDialog.vue deleted file mode 100644 index 3f587137..00000000 --- a/komga-webui/src/components/dialogs/LibraryDeleteDialog.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - - - diff --git a/komga-webui/src/components/dialogs/ReadListDeleteDialog.vue b/komga-webui/src/components/dialogs/ReadListDeleteDialog.vue deleted file mode 100644 index 8d4c86ce..00000000 --- a/komga-webui/src/components/dialogs/ReadListDeleteDialog.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - - - diff --git a/komga-webui/src/components/dialogs/UserDeleteDialog.vue b/komga-webui/src/components/dialogs/UserDeleteDialog.vue deleted file mode 100644 index b13731d6..00000000 --- a/komga-webui/src/components/dialogs/UserDeleteDialog.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - - - diff --git a/komga-webui/src/locales/en.json b/komga-webui/src/locales/en.json index 8211f6c8..d1d75d7c 100644 --- a/komga-webui/src/locales/en.json +++ b/komga-webui/src/locales/en.json @@ -252,7 +252,6 @@ "label_roles": "Roles" }, "delete_collection": { - "button_cancel": "Cancel", "button_confirm": "Delete", "confirm_delete": "Yes, delete the collection \"{name}\"", "confirm_delete_multiple": "Yes, delete {count} collections", @@ -262,14 +261,12 @@ "warning_multiple_html": "{count} collections will be removed from this server. Your media files will not be affected. This cannot be undone. Continue?" }, "delete_library": { - "button_cancel": "Cancel", "button_confirm": "Delete", "confirm_delete": "Yes, delete the library \"{name}\"", "title": "Delete Library", "warning_html": "The library {name} will be removed from this server. Your media files will not be affected. This cannot be undone. Continue?" }, "delete_readlist": { - "button_cancel": "Cancel", "button_confirm": "Delete", "confirm_delete": "Yes, delete the read list \"{name}\"", "confirm_delete_multiple": "Yes, delete {count} read lists", @@ -279,7 +276,6 @@ "warning_multiple_html": "{count} read lists will be removed from this server. Your media files will not be affected. This cannot be undone. Continue?" }, "delete_user": { - "button_cancel": "Cancel", "button_confirm": "Delete", "confirm_delete": "Yes, delete the user \"{name}\"", "dialog_title": "Delete User", @@ -415,7 +411,6 @@ "title": "Select Series" }, "server_stop": { - "button_cancel": "Cancel", "button_confirm": "Stop", "confirmation_message": "Are you sure you want to stop Komga?", "dialog_title": "Shut down server"