[web-src] Keep PageTracks in line with PageArtist

This commit is contained in:
chme 2018-10-27 07:12:07 +02:00
parent 08a370966d
commit 075c4cdb45
2 changed files with 13 additions and 11 deletions

View File

@ -2,8 +2,7 @@
<div> <div>
<content-with-heading> <content-with-heading>
<template slot="heading-left"> <template slot="heading-left">
<a class="title is-4 has-text-link has-text-weight-normal" @click="open_artist">{{ artist }}</a> <p class="title is-4">{{ artist.name }}</p>
<p class="heading">{{ tracks.total }} tracks</p>
</template> </template>
<template slot="heading-right"> <template slot="heading-right">
<a class="button is-small is-dark is-rounded" @click="play"> <a class="button is-small is-dark is-rounded" @click="play">
@ -14,7 +13,8 @@
</a> </a>
</template> </template>
<template slot="content"> <template slot="content">
<list-item-track v-for="(track, index) in tracks.items" :key="track.id" :track="track" :position="index" :context_uri="track.uri" :links="links"></list-item-track> <p class="heading has-text-centered-mobile"><a class="has-text-link" @click="open_artist">{{ artist.album_count }} albums</a> | {{ artist.track_count }} tracks</p>
<list-item-track v-for="(track, index) in tracks.items" :key="track.id" :track="track" :position="index" :context_uri="track.uri"></list-item-track>
</template> </template>
</content-with-heading> </content-with-heading>
</div> </div>
@ -28,12 +28,15 @@ import webapi from '@/webapi'
const tracksData = { const tracksData = {
load: function (to) { load: function (to) {
return webapi.library_artist_tracks(to.params.artist) return Promise.all([
webapi.library_artist(to.params.artist_id),
webapi.library_artist_tracks(to.params.artist_id)
])
}, },
set: function (vm, response) { set: function (vm, response) {
vm.artist_id = vm.$route.params.artist vm.artist = response[0].data
vm.tracks = response.data.tracks vm.tracks = response[1].data.tracks
} }
} }
@ -44,16 +47,15 @@ export default {
data () { data () {
return { return {
tracks: {}, artist: {},
artist: '', tracks: {}
artist_id: 0
} }
}, },
methods: { methods: {
open_artist: function () { open_artist: function () {
this.show_details_modal = false this.show_details_modal = false
this.$router.push({ path: '/music/artists/' + this.artist_id }) this.$router.push({ path: '/music/artists/' + this.artist.id })
}, },
play: function () { play: function () {

View File

@ -84,7 +84,7 @@ export const router = new VueRouter({
meta: { show_progress: true } meta: { show_progress: true }
}, },
{ {
path: '/music/artists/:artist/tracks', path: '/music/artists/:artist_id/tracks',
name: 'Tracks', name: 'Tracks',
component: PageTracks, component: PageTracks,
meta: { show_progress: true } meta: { show_progress: true }