2018-08-11 01:47:10 -04:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<tabs-music></tabs-music>
|
|
|
|
|
|
|
|
<content-with-heading>
|
2018-12-08 02:48:15 -05:00
|
|
|
<template slot="options">
|
|
|
|
<index-button-list :index="index_list"></index-button-list>
|
|
|
|
</template>
|
2018-08-11 01:47:10 -04:00
|
|
|
<template slot="heading-left">
|
|
|
|
<p class="title is-4">Albums</p>
|
|
|
|
<p class="heading">{{ albums.total }} albums</p>
|
|
|
|
</template>
|
|
|
|
<template slot="heading-right">
|
|
|
|
<a class="button is-small" :class="{ 'is-info': hide_singles }" @click="update_hide_singles">
|
|
|
|
<span class="icon">
|
|
|
|
<i class="mdi mdi-numeric-1-box-multiple-outline"></i>
|
|
|
|
</span>
|
|
|
|
<span>Hide singles</span>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
<template slot="content">
|
2020-09-20 02:13:19 -04:00
|
|
|
<list-albums :albums="albums_filtered"></list-albums>
|
2018-08-11 01:47:10 -04:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { LoadDataBeforeEnterMixin } from './mixin'
|
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading'
|
|
|
|
import TabsMusic from '@/components/TabsMusic'
|
2018-12-08 02:48:15 -05:00
|
|
|
import IndexButtonList from '@/components/IndexButtonList'
|
2020-09-20 02:13:19 -04:00
|
|
|
import ListAlbums from '@/components/ListAlbums'
|
2018-08-11 01:47:10 -04:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
import * as types from '@/store/mutation_types'
|
|
|
|
|
|
|
|
const albumsData = {
|
|
|
|
load: function (to) {
|
2020-06-30 04:24:11 -04:00
|
|
|
return webapi.library_albums('music')
|
2018-08-11 01:47:10 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (vm, response) {
|
|
|
|
vm.albums = response.data
|
2018-12-16 03:17:43 -05:00
|
|
|
vm.index_list = [...new Set(vm.albums.items
|
|
|
|
.filter(album => !vm.$store.state.hide_singles || album.track_count > 2)
|
|
|
|
.map(album => album.name_sort.charAt(0).toUpperCase()))]
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PageAlbums',
|
2020-04-11 13:43:53 -04:00
|
|
|
mixins: [LoadDataBeforeEnterMixin(albumsData)],
|
2020-09-20 02:13:19 -04:00
|
|
|
components: { ContentWithHeading, TabsMusic, IndexButtonList, ListAlbums },
|
2018-08-11 01:47:10 -04:00
|
|
|
|
|
|
|
data () {
|
|
|
|
return {
|
2018-12-15 03:56:09 -05:00
|
|
|
albums: { items: [] },
|
2020-09-20 02:13:19 -04:00
|
|
|
index_list: []
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
hide_singles () {
|
|
|
|
return this.$store.state.hide_singles
|
2020-04-11 13:43:53 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
albums_filtered () {
|
2020-09-20 11:59:46 -04:00
|
|
|
if (this.hide_singles) {
|
|
|
|
return this.albums.items.filter(album => album.track_count > 2)
|
|
|
|
}
|
|
|
|
return this.albums.items
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
update_hide_singles: function (e) {
|
|
|
|
this.$store.commit(types.HIDE_SINGLES, !this.hide_singles)
|
|
|
|
}
|
2018-12-16 03:17:43 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
'hide_singles' () {
|
|
|
|
this.index_list = [...new Set(this.albums.items
|
|
|
|
.filter(album => !this.$store.state.hide_singles || album.track_count > 2)
|
|
|
|
.map(album => album.name_sort.charAt(0).toUpperCase()))]
|
|
|
|
}
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|