owntone-server/web-src/src/pages/PageAudiobooksAlbums.vue

79 lines
1.7 KiB
Vue
Raw Normal View History

<template>
2022-02-19 06:18:01 +01:00
<div class="fd-page-with-tabs">
<tabs-audiobooks />
<content-with-heading>
<template #options>
<index-button-list :index="albums.indexList" />
2020-09-27 19:22:33 +02:00
</template>
<template #heading-left>
2022-05-20 13:44:22 +02:00
<p class="title is-4" v-text="$t('page.audiobooks.albums.title')" />
<p
class="heading"
v-text="$t('page.audiobooks.albums.count', { count: albums.count })"
/>
</template>
<template #content>
<list-albums :albums="albums" />
</template>
</content-with-heading>
</div>
</template>
<script>
2022-02-19 06:18:01 +01:00
import TabsAudiobooks from '@/components/TabsAudiobooks.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ListAlbums from '@/components/ListAlbums.vue'
import webapi from '@/webapi'
import { GroupByList, byName } from '@/lib/GroupByList'
2022-02-19 06:18:01 +01:00
const dataObject = {
load(to) {
return webapi.library_albums('audiobook')
},
set(vm, response) {
vm.albums = new GroupByList(response.data)
vm.albums.group(byName('name_sort', true))
}
}
export default {
name: 'PageAudiobooksAlbums',
components: {
TabsAudiobooks,
ContentWithHeading,
IndexButtonList,
ListAlbums
},
beforeRouteEnter(to, from, next) {
dataObject.load(to).then((response) => {
next((vm) => dataObject.set(vm, response))
})
},
beforeRouteUpdate(to, from, next) {
if (!this.albums.isEmpty()) {
next()
return
}
const vm = this
dataObject.load(to).then((response) => {
dataObject.set(vm, response)
next()
})
},
data() {
return {
albums: new GroupByList()
2020-09-27 19:22:33 +02:00
}
},
methods: {}
}
</script>
<style></style>