2018-08-11 07:47:10 +02:00
|
|
|
<template>
|
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
|
|
|
<div class="title is-4">
|
|
|
|
{{ playlist.name }}
|
|
|
|
</div>
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-right>
|
2019-02-17 11:24:30 +01:00
|
|
|
<div class="buttons is-centered">
|
2022-02-19 06:39:14 +01:00
|
|
|
<a
|
|
|
|
class="button is-small is-light is-rounded"
|
|
|
|
@click="show_playlist_details_modal = true"
|
|
|
|
>
|
2022-04-16 10:14:03 +02:00
|
|
|
<span class="icon"><mdicon name="dots-horizontal" size="16" /></span>
|
2019-02-17 11:24:30 +01:00
|
|
|
</a>
|
|
|
|
<a class="button is-small is-dark is-rounded" @click="play">
|
2022-04-16 10:14:03 +02:00
|
|
|
<span class="icon"><mdicon name="shuffle" size="16" /></span>
|
2022-02-19 06:39:14 +01:00
|
|
|
<span>Shuffle</span>
|
2019-02-17 11:24:30 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #content>
|
2018-08-11 07:47:10 +02:00
|
|
|
<p class="heading has-text-centered-mobile">{{ tracks.length }} tracks</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<list-tracks :tracks="tracks" :uris="uris" />
|
|
|
|
<modal-dialog-playlist
|
|
|
|
:show="show_playlist_details_modal"
|
|
|
|
:playlist="playlist"
|
|
|
|
:uris="uris"
|
|
|
|
@close="show_playlist_details_modal = false"
|
|
|
|
/>
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 06:18:01 +01:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
|
|
|
import ListTracks from '@/components/ListTracks.vue'
|
|
|
|
import ModalDialogPlaylist from '@/components/ModalDialogPlaylist.vue'
|
2018-08-11 07:47:10 +02:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
2022-02-19 06:18:01 +01:00
|
|
|
const dataObject = {
|
2018-08-11 07:47:10 +02:00
|
|
|
load: function (to) {
|
|
|
|
return Promise.all([
|
|
|
|
webapi.library_playlist(to.params.playlist_id),
|
|
|
|
webapi.library_playlist_tracks(to.params.playlist_id)
|
|
|
|
])
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (vm, response) {
|
|
|
|
vm.playlist = response[0].data
|
|
|
|
vm.tracks = response[1].data.items
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PagePlaylist',
|
2020-10-04 17:31:47 +02:00
|
|
|
components: { ContentWithHeading, ListTracks, ModalDialogPlaylist },
|
2018-08-11 07:47:10 +02:00
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
next((vm) => dataObject.set(vm, response))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
beforeRouteUpdate(to, from, next) {
|
|
|
|
const vm = this
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
dataObject.set(vm, response)
|
|
|
|
next()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
2018-08-11 07:47:10 +02:00
|
|
|
return {
|
|
|
|
playlist: {},
|
2018-12-15 09:56:09 +01:00
|
|
|
tracks: [],
|
|
|
|
|
2019-02-17 11:24:30 +01:00
|
|
|
show_playlist_details_modal: false
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-04 17:31:47 +02:00
|
|
|
computed: {
|
2022-02-19 06:39:14 +01:00
|
|
|
uris() {
|
2020-08-29 14:06:11 +02:00
|
|
|
if (this.playlist.random) {
|
2022-02-19 06:39:14 +01:00
|
|
|
return this.tracks.map((a) => a.uri).join(',')
|
2020-08-29 14:06:11 +02:00
|
|
|
}
|
2020-10-04 17:31:47 +02:00
|
|
|
return this.playlist.uri
|
|
|
|
}
|
|
|
|
},
|
2018-12-17 10:35:39 +01:00
|
|
|
|
2020-10-04 17:31:47 +02:00
|
|
|
methods: {
|
|
|
|
play: function () {
|
|
|
|
webapi.player_play_uri(this.uris, true)
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<style></style>
|