owntone-server/web-src/src/pages/PageAudiobooksArtists.vue
Alain Nussbaumer 387e531d64 [web] Cleanup of code to simplify
Useless methods have been removed and code has been partially cleaned up.
2023-06-07 21:25:54 +02:00

89 lines
1.9 KiB
Vue

<template>
<div class="fd-page-with-tabs">
<tabs-audiobooks />
<content-with-heading>
<template #options>
<index-button-list :index="artists.indexList" />
</template>
<template #heading-left>
<p class="title is-4" v-text="$t('page.audiobooks.artists.title')" />
<p
class="heading"
v-text="$t('page.audiobooks.artists.count', { count: artists.count })"
/>
</template>
<template #heading-right />
<template #content>
<list-artists :artists="artists" />
</template>
</content-with-heading>
</div>
</template>
<script>
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import TabsAudiobooks from '@/components/TabsAudiobooks.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
import ListArtists from '@/components/ListArtists.vue'
import webapi from '@/webapi'
import { GroupByList, byName } from '@/lib/GroupByList'
const dataObject = {
load(to) {
return webapi.library_artists('audiobook')
},
set(vm, response) {
vm.artists_list = new GroupByList(response.data)
}
}
export default {
name: 'PageAudiobooksArtists',
components: {
ContentWithHeading,
TabsAudiobooks,
IndexButtonList,
ListArtists
},
beforeRouteEnter(to, from, next) {
dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response))
})
},
beforeRouteUpdate(to, from, next) {
if (!this.artists_list.isEmpty()) {
next()
return
}
const vm = this
dataObject.load(to).then((response) => {
dataObject.set(vm, response)
next()
})
},
data() {
return {
artists_list: new GroupByList()
}
},
computed: {
artists() {
if (!this.artists_list) {
return []
}
this.artists_list.group(byName('name_sort', true))
return this.artists_list
}
},
methods: {}
}
</script>
<style></style>