2021-08-18 13:50:24 +02:00
|
|
|
<template>
|
|
|
|
<div class="w-full h-10 relative">
|
2021-10-09 00:30:20 +02:00
|
|
|
<div id="toolbar" class="absolute top-0 left-0 w-full h-full z-20 flex items-center px-8">
|
2021-09-28 13:44:40 +02:00
|
|
|
<template v-if="page !== 'search' && !isHome">
|
2021-09-24 23:14:33 +02:00
|
|
|
<p v-if="!selectedSeries" class="font-book">{{ numShowing }} {{ entityName }}</p>
|
|
|
|
<div v-else class="flex items-center">
|
2021-10-09 18:09:06 +02:00
|
|
|
<div @click="seriesBackArrow" class="rounded-full h-9 w-9 flex items-center justify-center hover:bg-white hover:bg-opacity-10 cursor-pointer">
|
|
|
|
<span class="material-icons text-2xl text-white">west</span>
|
2021-09-24 23:14:33 +02:00
|
|
|
</div>
|
|
|
|
<!-- <span class="material-icons text-2xl cursor-pointer" @click="seriesBackArrow">west</span> -->
|
|
|
|
<p class="pl-4 font-book text-lg">
|
2021-10-09 18:09:06 +02:00
|
|
|
{{ selectedSeries }}
|
2021-09-24 23:14:33 +02:00
|
|
|
</p>
|
2021-10-09 18:09:06 +02:00
|
|
|
<div class="w-6 h-6 rounded-full bg-black bg-opacity-30 flex items-center justify-center ml-3">
|
|
|
|
<span class="font-mono">{{ numShowing }}</span>
|
|
|
|
</div>
|
2021-09-24 14:32:38 +02:00
|
|
|
</div>
|
2021-09-24 23:14:33 +02:00
|
|
|
<div class="flex-grow" />
|
2021-09-05 20:21:02 +02:00
|
|
|
|
2021-10-07 04:08:52 +02:00
|
|
|
<ui-text-input v-show="!selectedSeries" v-model="_keywordFilter" placeholder="Keyword Filter" :padding-y="1.5" clearable class="text-xs w-40" />
|
2021-09-24 23:14:33 +02:00
|
|
|
<controls-filter-select v-show="showSortFilters" v-model="settings.filterBy" class="w-48 h-7.5 ml-4" @change="updateFilter" />
|
|
|
|
<controls-order-select v-show="showSortFilters" v-model="settings.orderBy" :descending.sync="settings.orderDesc" class="w-48 h-7.5 ml-4" @change="updateOrder" />
|
|
|
|
</template>
|
2021-09-28 13:44:40 +02:00
|
|
|
<template v-else-if="!isHome">
|
2021-09-24 23:14:33 +02:00
|
|
|
<div @click="searchBackArrow" class="rounded-full h-10 w-10 flex items-center justify-center hover:bg-white hover:bg-opacity-10 cursor-pointer">
|
|
|
|
<span class="material-icons text-3xl text-white">west</span>
|
|
|
|
</div>
|
|
|
|
<!-- <p class="font-book pl-4">{{ numShowing }} showing</p> -->
|
|
|
|
<div class="flex-grow" />
|
|
|
|
<p>Search results for "{{ searchQuery }}"</p>
|
|
|
|
<div class="flex-grow" />
|
|
|
|
</template>
|
2021-08-18 13:50:24 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2021-09-24 14:32:38 +02:00
|
|
|
props: {
|
|
|
|
page: String,
|
2021-09-28 13:44:40 +02:00
|
|
|
isHome: Boolean,
|
2021-09-24 23:14:33 +02:00
|
|
|
selectedSeries: String,
|
|
|
|
searchResults: {
|
2021-10-17 18:29:52 +02:00
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
2021-09-24 23:14:33 +02:00
|
|
|
},
|
|
|
|
searchQuery: String
|
2021-09-24 14:32:38 +02:00
|
|
|
},
|
2021-08-18 13:50:24 +02:00
|
|
|
data() {
|
2021-08-19 03:18:44 +02:00
|
|
|
return {
|
2021-08-24 01:31:04 +02:00
|
|
|
settings: {},
|
|
|
|
hasInit: false
|
2021-08-19 03:18:44 +02:00
|
|
|
}
|
2021-08-18 13:50:24 +02:00
|
|
|
},
|
|
|
|
computed: {
|
2021-09-24 14:32:38 +02:00
|
|
|
showSortFilters() {
|
|
|
|
return this.page === ''
|
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
numShowing() {
|
2021-09-24 14:32:38 +02:00
|
|
|
if (this.page === '') {
|
|
|
|
return this.$store.getters['audiobooks/getFiltered']().length
|
2021-09-24 23:14:33 +02:00
|
|
|
} else if (this.page === 'search') {
|
2021-10-17 18:29:52 +02:00
|
|
|
var audiobookSearchResults = this.searchResults ? this.searchResults.audiobooks || [] : []
|
|
|
|
return audiobookSearchResults.length
|
2021-09-24 14:32:38 +02:00
|
|
|
} else {
|
|
|
|
var groups = this.$store.getters['audiobooks/getSeriesGroups']()
|
|
|
|
if (this.selectedSeries) {
|
|
|
|
var group = groups.find((g) => g.name === this.selectedSeries)
|
|
|
|
if (group) return group.books.length
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return groups.length
|
|
|
|
}
|
|
|
|
},
|
|
|
|
entityName() {
|
|
|
|
if (!this.page) return 'Audiobooks'
|
|
|
|
if (this.page === 'series') return 'Series'
|
|
|
|
if (this.page === 'collections') return 'Collections'
|
|
|
|
return ''
|
2021-09-05 20:21:02 +02:00
|
|
|
},
|
|
|
|
_keywordFilter: {
|
|
|
|
get() {
|
|
|
|
return this.$store.state.audiobooks.keywordFilter
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$store.commit('audiobooks/setKeywordFilter', val)
|
|
|
|
}
|
2021-10-06 04:10:49 +02:00
|
|
|
},
|
|
|
|
currentLibraryId() {
|
|
|
|
return this.$store.state.libraries.currentLibraryId
|
2021-08-19 03:18:44 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2021-09-24 23:14:33 +02:00
|
|
|
searchBackArrow() {
|
2021-10-06 04:10:49 +02:00
|
|
|
this.$router.replace(`/library/${this.currentLibraryId}/bookshelf`)
|
2021-09-24 23:14:33 +02:00
|
|
|
},
|
2021-09-24 14:32:38 +02:00
|
|
|
seriesBackArrow() {
|
2021-10-06 04:10:49 +02:00
|
|
|
this.$router.replace(`/library/${this.currentLibraryId}/bookshelf/series`)
|
2021-09-24 14:32:38 +02:00
|
|
|
this.$emit('update:selectedSeries', null)
|
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
updateOrder() {
|
|
|
|
this.saveSettings()
|
|
|
|
},
|
|
|
|
updateFilter() {
|
|
|
|
this.saveSettings()
|
|
|
|
},
|
|
|
|
saveSettings() {
|
2021-08-24 01:31:04 +02:00
|
|
|
this.$store.dispatch('user/updateUserSettings', this.settings)
|
2021-08-18 13:50:24 +02:00
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
init() {
|
2021-08-24 01:31:04 +02:00
|
|
|
this.settings = { ...this.$store.state.user.settings }
|
|
|
|
},
|
|
|
|
settingsUpdated(settings) {
|
|
|
|
for (const key in settings) {
|
|
|
|
this.settings[key] = settings[key]
|
|
|
|
}
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
|
|
|
},
|
2021-08-19 03:18:44 +02:00
|
|
|
mounted() {
|
|
|
|
this.init()
|
2021-08-24 01:31:04 +02:00
|
|
|
this.$store.commit('user/addSettingsListener', { id: 'bookshelftoolbar', meth: this.settingsUpdated })
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.$store.commit('user/removeSettingsListener', 'bookshelftoolbar')
|
2021-08-19 03:18:44 +02:00
|
|
|
}
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#toolbar {
|
2021-09-26 22:34:08 +02:00
|
|
|
box-shadow: 0px 8px 6px #111111aa;
|
2021-08-18 13:50:24 +02:00
|
|
|
}
|
|
|
|
</style>
|