From fc06b4a987ed43c4754b2e3691493ed2093ac64a Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Fri, 9 Jul 2021 15:21:50 +0800 Subject: [PATCH] feat(webui): library option to automatically empty trash after scan --- .../components/dialogs/LibraryEditDialog.vue | 436 +++++++++--------- komga-webui/src/locales/en.json | 13 +- komga-webui/src/types/komga-libraries.ts | 9 +- 3 files changed, 244 insertions(+), 214 deletions(-) diff --git a/komga-webui/src/components/dialogs/LibraryEditDialog.vue b/komga-webui/src/components/dialogs/LibraryEditDialog.vue index 5e0ae6716..41ad5bbb5 100644 --- a/komga-webui/src/components/dialogs/LibraryEditDialog.vue +++ b/komga-webui/src/components/dialogs/LibraryEditDialog.vue @@ -2,7 +2,8 @@
@@ -13,217 +14,244 @@ {{ dialogTitle }} - {{ confirmText }} + + {{ $t('dialog.edit_library.button_next') }} + + {{ confirmText }} {{ dialogTitle }} - - - mdi-bookshelf - {{ $t('dialog.edit_library.tab_general') }} - - - mdi-tune - {{ $t('dialog.edit_library.tab_options') }} - + + + + mdi-bookshelf + {{ $t('dialog.edit_library.tab_general') }} + + + mdi-tune + {{ $t('dialog.edit_library.tab_options') }} + + + mdi-book-information-variant + {{ $t('dialog.edit_library.tab_metadata') }} + - - - - + + + + - - - - - + + + + + - - - + + + - - - - {{ $t('dialog.edit_library.button_browse') }} - - - - - + + + + {{ $t('dialog.edit_library.button_browse') }} + + + + + - - - - - - - - + + + + + + + + {{ + $t('dialog.edit_library.label_import_local') + }} + + + + + + {{ + $t('dialog.edit_library.label_import_barcode_isbn') + }} + + + - + + + - - - - - - - - + + {{ $t('dialog.edit_library.button_cancel') }} - {{ confirmText }} + + {{ $t('dialog.edit_library.button_next') }} + + {{ confirmText }}
@@ -259,6 +287,7 @@ export default Vue.extend({ scanDeep: false, repairExtensions: false, convertToCbz: false, + emptyTrashAfterScan: false, }, validationFieldNames: new Map([]), } @@ -270,6 +299,9 @@ export default Vue.extend({ confirmText(): string { return this.library ? this.$t('dialog.edit_library.button_confirm_edit').toString() : this.$t('dialog.edit_library.button_confirm_add').toString() }, + showNext(): boolean { + return !this.library && this.tab !== 2 + }, importComicInfo: { get: function (): number { @@ -301,20 +333,6 @@ export default Vue.extend({ }, }, - scanner: { - get: function (): number { - const val = [this.form.scanDeep, this.form.scanForceModifiedTime] - const count = val.filter(Boolean).length - if (count === val.length) return 2 - if (count === 0) return 0 - return 1 - }, - set: function (value: boolean): void { - this.form.scanDeep = value - this.form.scanForceModifiedTime = value - }, - }, - fileManagement: { get: function (): number { const val = [this.form.repairExtensions, this.form.convertToCbz] @@ -352,6 +370,10 @@ export default Vue.extend({ }, }, methods: { + nextTab() { + this.$v.$touch() + if (!this.$v.$invalid) this.tab += 1 + }, getErrors(fieldName: string) { const errors = [] @@ -385,6 +407,7 @@ export default Vue.extend({ this.form.scanDeep = library ? library.scanDeep : false this.form.repairExtensions = library ? library.repairExtensions : false this.form.convertToCbz = library ? library.convertToCbz : false + this.form.emptyTrashAfterScan = library ? library.emptyTrashAfterScan : false this.$v.$reset() }, validateLibrary() { @@ -406,6 +429,7 @@ export default Vue.extend({ scanDeep: this.form.scanDeep, repairExtensions: this.form.repairExtensions, convertToCbz: this.form.convertToCbz, + emptyTrashAfterScan: this.form.emptyTrashAfterScan, } } return null diff --git a/komga-webui/src/locales/en.json b/komga-webui/src/locales/en.json index 0bb527587..c569d7843 100644 --- a/komga-webui/src/locales/en.json +++ b/komga-webui/src/locales/en.json @@ -322,6 +322,7 @@ "button_cancel": "Cancel", "button_confirm_add": "Add", "button_confirm_edit": "Edit", + "button_next": "Next", "dialog_title_add": "Add Library", "dialot_title_edit": "Edit Library", "field_convert_to_cbz": "Automatically convert to CBZ", @@ -337,6 +338,7 @@ "field_repair_extensions": "Automatically repair incorrect file extensions", "field_root_folder": "Root folder", "field_scanner_deep_scan": "Deep scan", + "field_scanner_empty_trash_after_scan": "Empty trash automatically after every scan", "field_scanner_force_directory_modified_time": "Force directory modified time", "file_browser_dialog_button_confirm": "Choose", "file_browser_dialog_title": "Library's root folder", @@ -347,6 +349,7 @@ "label_import_local": "Import local media assets", "label_scanner": "Scanner", "tab_general": "General", + "tab_metadata": "Metadata", "tab_options": "Options" }, "edit_readlist": { @@ -389,6 +392,11 @@ "field_all_libraries": "All libraries", "label_shared_with": "Shared with {name}" }, + "empty_trash": { + "body": "By default the media server doesn't remove information for media right away. This helps if a drive is temporarily disconnected. When you empty the trash for a library, all information about missing media is deleted.", + "button_confirm": "Empty", + "title": "Empty trash for library" + }, "file_browser": { "button_cancel": "Cancel", "button_confirm_default": "Choose", @@ -455,11 +463,6 @@ "page_of_pages": "{page} / {pages}", "title": "Inspect Book", "title_comparison": "Book Comparison" - }, - "empty_trash": { - "title": "Empty trash for library", - "body": "By default the media server doesn't remove information for media right away. This helps if a drive is temporarily disconnected. When you empty the trash for a library, all information about missing media is deleted.", - "button_confirm": "Empty" } }, "enums": { diff --git a/komga-webui/src/types/komga-libraries.ts b/komga-webui/src/types/komga-libraries.ts index 628ec12ee..40d8c82fa 100644 --- a/komga-webui/src/types/komga-libraries.ts +++ b/komga-webui/src/types/komga-libraries.ts @@ -12,7 +12,8 @@ interface LibraryCreationDto { scanForceModifiedTime: boolean, scanDeep: boolean, repairExtensions: boolean, - convertToCbz: boolean + convertToCbz: boolean, + emptyTrashAfterScan: boolean, } interface LibraryUpdateDto { @@ -29,7 +30,8 @@ interface LibraryUpdateDto { scanForceModifiedTime: boolean, scanDeep: boolean, repairExtensions: boolean, - convertToCbz: boolean + convertToCbz: boolean, + emptyTrashAfterScan: boolean, } interface LibraryDto { @@ -47,5 +49,6 @@ interface LibraryDto { scanForceModifiedTime: boolean, scanDeep: boolean, repairExtensions: boolean, - convertToCbz: boolean + convertToCbz: boolean, + emptyTrashAfterScan: boolean, }