From c3fd9045a861f75c71894bd97d9c2380078e1906 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 22 Aug 2021 08:52:37 -0500 Subject: [PATCH] Series as a dropdown and filter, fix genre list in details modal --- client/components/controls/FilterSelect.vue | 8 ++ .../components/modals/edit-tabs/Details.vue | 39 ++++-- client/components/ui/InputDropdown.vue | 112 ++++++++++++++++++ client/components/ui/MultiSelect.vue | 39 ++---- client/layouts/default.vue | 9 ++ client/package.json | 2 +- client/plugins/init.client.js | 71 +++++++++++ client/store/audiobooks.js | 71 ++++++++--- package.json | 2 +- server/utils/index.js | 19 ++- server/utils/scandir.js | 3 +- 11 files changed, 310 insertions(+), 65 deletions(-) create mode 100644 client/components/ui/InputDropdown.vue diff --git a/client/components/controls/FilterSelect.vue b/client/components/controls/FilterSelect.vue index 2c6294f3..a87fb3d8 100644 --- a/client/components/controls/FilterSelect.vue +++ b/client/components/controls/FilterSelect.vue @@ -76,6 +76,11 @@ export default { text: 'Tag', value: 'tags', sublist: true + }, + { + text: 'Series', + value: 'series', + sublist: true } ] } @@ -116,6 +121,9 @@ export default { tags() { return this.$store.state.audiobooks.tags }, + series() { + return this.$store.state.audiobooks.series + }, sublistItems() { return this[this.sublist] || [] } diff --git a/client/components/modals/edit-tabs/Details.vue b/client/components/modals/edit-tabs/Details.vue index a1183e7d..1f8c172f 100644 --- a/client/components/modals/edit-tabs/Details.vue +++ b/client/components/modals/edit-tabs/Details.vue @@ -21,11 +21,20 @@ - + + + - +
+
+ +
+
+ +
+
Remove @@ -55,8 +64,8 @@ export default { publishYear: null, genres: [] }, - resettingProgress: false, - genres: ['adventure', 'autobiography', 'biography', 'childrens', 'comedy', 'crime', 'dystopian', 'fantasy', 'fiction', 'health', 'history', 'horror', 'mystery', 'new_adult', 'nonfiction', 'philosophy', 'politics', 'religion', 'romance', 'sci-fi', 'self-help', 'short_story', 'technology', 'thriller', 'true_crime', 'western', 'young_adult'] + newTags: [], + resettingProgress: false } }, watch: { @@ -87,21 +96,25 @@ export default { }, userProgress() { return this.userAudiobook ? this.userAudiobook.progress : 0 + }, + genres() { + return this.$store.state.audiobooks.genres + }, + tags() { + return this.$store.state.audiobooks.tags + }, + series() { + return this.$store.state.audiobooks.series } }, methods: { - addGenre(genre) { - this.genres.push({ - text: genre, - value: genre - }) - }, async submitForm() { - console.log('Submit form', this.details) this.isProcessing = true const updatePayload = { - book: this.details + book: this.details, + tags: this.newTags } + var updatedAudiobook = await this.$axios.$patch(`/api/audiobook/${this.audiobook.id}`, updatePayload).catch((error) => { console.error('Failed to update', error) return false @@ -120,6 +133,8 @@ export default { this.details.genres = this.book.genres || [] this.details.series = this.book.series this.details.publishYear = this.book.publishYear + + this.newTags = this.audiobook.tags || [] }, resetProgress() { if (confirm(`Are you sure you want to reset your progress?`)) { diff --git a/client/components/ui/InputDropdown.vue b/client/components/ui/InputDropdown.vue new file mode 100644 index 00000000..879c8b8d --- /dev/null +++ b/client/components/ui/InputDropdown.vue @@ -0,0 +1,112 @@ + + + \ No newline at end of file diff --git a/client/components/ui/MultiSelect.vue b/client/components/ui/MultiSelect.vue index 3a1c62ad..0158d7ee 100644 --- a/client/components/ui/MultiSelect.vue +++ b/client/components/ui/MultiSelect.vue @@ -4,7 +4,7 @@
-
{{ snakeToNormal(item) }}
+
{{ $snakeToNormal(item) }}
@@ -13,7 +13,7 @@