diff --git a/client/components/app/BookShelfToolbar.vue b/client/components/app/BookShelfToolbar.vue
index bd31768b..9064c914 100644
--- a/client/components/app/BookShelfToolbar.vue
+++ b/client/components/app/BookShelfToolbar.vue
@@ -98,6 +98,9 @@
{{ $strings.ButtonMatchAllAuthors }}
+
+
+
@@ -183,6 +186,30 @@ export default {
}
]
},
+ authorSortItems() {
+ return [
+ {
+ text: this.$strings.LabelAuthorFirstLast,
+ value: 'name'
+ },
+ {
+ text: this.$strings.LabelAuthorLastFirst,
+ value: 'lastFirst'
+ },
+ {
+ text: this.$strings.LabelNumberOfBooks,
+ value: 'numBooks'
+ },
+ {
+ text: this.$strings.LabelAddedAt,
+ value: 'addedAt'
+ },
+ {
+ text: this.$strings.LabelUpdatedAt,
+ value: 'updatedAt'
+ }
+ ]
+ },
userIsAdminOrUp() {
return this.$store.getters['user/getIsAdminOrUp']
},
@@ -455,6 +482,9 @@ export default {
updateCollapseBookSeries() {
this.saveSettings()
},
+ updateAuthorSort() {
+ this.saveSettings()
+ },
saveSettings() {
this.$store.dispatch('user/updateUserSettings', this.settings)
},
diff --git a/client/pages/library/_library/authors/index.vue b/client/pages/library/_library/authors/index.vue
index 1f8e385b..3906f671 100644
--- a/client/pages/library/_library/authors/index.vue
+++ b/client/pages/library/_library/authors/index.vue
@@ -3,7 +3,7 @@
-
+
@@ -44,6 +44,22 @@ export default {
},
selectedAuthor() {
return this.$store.state.globals.selectedAuthor
+ },
+ authorSortBy() {
+ return this.$store.getters['user/getUserSetting']('authorSortBy') || 'name'
+ },
+ authorSortDesc() {
+ return !!this.$store.getters['user/getUserSetting']('authorSortDesc')
+ },
+ authorsSorted() {
+ const sortProp = this.authorSortBy
+ const bDesc = this.authorSortDesc ? -1 : 1
+ return this.authors.sort((a, b) => {
+ if (typeof a[sortProp] === 'number' && typeof b[sortProp] === 'number') {
+ return a[sortProp] > b[sortProp] ? bDesc : -bDesc
+ }
+ return a[sortProp].localeCompare(b[sortProp], undefined, { sensitivity: 'base' }) * bDesc
+ })
}
},
methods: {
diff --git a/client/store/user.js b/client/store/user.js
index 85babb09..a69ee058 100644
--- a/client/store/user.js
+++ b/client/store/user.js
@@ -11,7 +11,9 @@ export const state = () => ({
useChapterTrack: false,
seriesSortBy: 'name',
seriesSortDesc: false,
- seriesFilterBy: 'all'
+ seriesFilterBy: 'all',
+ authorSortBy: 'name',
+ authorSortDesc: false
}
})
diff --git a/server/controllers/LibraryController.js b/server/controllers/LibraryController.js
index ecea310c..a0233dd2 100644
--- a/server/controllers/LibraryController.js
+++ b/server/controllers/LibraryController.js
@@ -660,6 +660,7 @@ class LibraryController {
for (const author of authors) {
const oldAuthor = author.getOldAuthor().toJSON()
oldAuthor.numBooks = author.books.length
+ oldAuthor.lastFirst = author.lastFirst
oldAuthors.push(oldAuthor)
}