feat(webui): increment/decrement numberSort in bulk

Closes: #628
This commit is contained in:
Gauthier Roebroeck 2023-01-17 16:39:35 +08:00
parent c30c755f63
commit e7fbe57e44
2 changed files with 45 additions and 1 deletions

View file

@ -43,6 +43,32 @@
</v-btn> </v-btn>
<span class="subtitle-1">{{ prop.label }}</span> <span class="subtitle-1">{{ prop.label }}</span>
<v-btn v-if="prop.prop === 'number'" icon @click="copyFromNumberSort">
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on">mdi-content-copy</v-icon>
</template>
<span>{{ $t('dialog.edit_books.copy_from', {field: $t('dialog.edit_books.field_number_sort')}) }}</span>
</v-tooltip>
</v-btn>
<span v-if="prop.prop === 'numberSort'">
<v-btn icon @click="numberSortDecrement">
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on">mdi-numeric-negative-1</v-icon>
</template>
<span>{{ $t('dialog.edit_books.number_sort_decrement') }}</span>
</v-tooltip>
</v-btn>
<v-btn icon @click="numberSortIncrement">
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on">mdi-numeric-positive-1</v-icon>
</template>
<span>{{ $t('dialog.edit_books.number_sort_increment') }}</span>
</v-tooltip>
</v-btn>
</span>
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
@ -259,7 +285,7 @@ export default Vue.extend({
validateReleaseDate(date: string): string | boolean { validateReleaseDate(date: string): string | boolean {
return date && !isMatch(date, 'yyyy-MM-dd') ? this.$t('dialog.edit_books.field_release_date_error').toString() : true return date && !isMatch(date, 'yyyy-MM-dd') ? this.$t('dialog.edit_books.field_release_date_error').toString() : true
}, },
bookDisplayName(book: BookDto):string { bookDisplayName(book: BookDto): string {
const parts = book.url.split('/') const parts = book.url.split('/')
return parts[parts.length - 2] + '/' + parts[parts.length - 1] return parts[parts.length - 2] + '/' + parts[parts.length - 1]
}, },
@ -279,6 +305,21 @@ export default Vue.extend({
this.form[book.id][propLock] = lock this.form[book.id][propLock] = lock
} }
}, },
numberSortDecrement() {
for (const book of this.books) {
this.form[book.id].numberSort = this.form[book.id].numberSort - 1
}
},
numberSortIncrement() {
for (const book of this.books) {
this.form[book.id].numberSort = this.form[book.id].numberSort + 1
}
},
copyFromNumberSort() {
for (const book of this.books) {
this.form[book.id].number = this.form[book.id].numberSort
}
},
dialogReset(books: BookDto[]) { dialogReset(books: BookDto[]) {
(this.$refs.form as any)?.resetValidation() (this.$refs.form as any)?.resetValidation()
this.form = books.reduce((accum, current) => { this.form = books.reduce((accum, current) => {

View file

@ -347,6 +347,7 @@
"authors_notice_multiple_edit": "You are editing authors for multiple books. This will override existing authors of each book.", "authors_notice_multiple_edit": "You are editing authors for multiple books. This will override existing authors of each book.",
"button_cancel": "Cancel", "button_cancel": "Cancel",
"button_confirm": "Save changes", "button_confirm": "Save changes",
"copy_from": "Copy from {field}",
"dialog_title_multiple": "Edit {count} book | Edit {count} books", "dialog_title_multiple": "Edit {count} book | Edit {count} books",
"dialog_title_single": "Edit {book}", "dialog_title_single": "Edit {book}",
"field_alternate_title": "Alternate title", "field_alternate_title": "Alternate title",
@ -364,6 +365,8 @@
"field_summary": "Summary", "field_summary": "Summary",
"field_tags": "Tags", "field_tags": "Tags",
"field_title": "Title", "field_title": "Title",
"number_sort_decrement": "Decrement all by 1",
"number_sort_increment": "Increment all by 1",
"tab_authors": "Authors", "tab_authors": "Authors",
"tab_general": "General", "tab_general": "General",
"tab_links": "Links", "tab_links": "Links",