2018-08-11 07:47:10 +02:00
|
|
|
<template>
|
2023-06-23 22:23:32 +02:00
|
|
|
<div class="fd-page">
|
|
|
|
<content-with-heading>
|
|
|
|
<template #heading-left>
|
|
|
|
<div class="title is-4" v-text="playlist.name" />
|
|
|
|
</template>
|
|
|
|
<template #heading-right>
|
|
|
|
<div class="buttons is-centered">
|
|
|
|
<a
|
|
|
|
class="button is-small is-light is-rounded"
|
|
|
|
@click="show_playlist_details_modal = true"
|
|
|
|
>
|
2023-06-30 21:41:40 +02:00
|
|
|
<mdicon class="icon" name="dots-horizontal" size="16" />
|
2023-06-23 22:23:32 +02:00
|
|
|
</a>
|
|
|
|
<a class="button is-small is-dark is-rounded" @click="play">
|
2023-06-30 21:41:40 +02:00
|
|
|
<mdicon class="icon" name="shuffle" size="16" />
|
2023-06-23 22:23:32 +02:00
|
|
|
<span v-text="$t('page.playlist.shuffle')" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<template #content>
|
|
|
|
<p
|
|
|
|
class="heading has-text-centered-mobile"
|
|
|
|
v-text="$t('page.playlist.track-count', { count: tracks.count })"
|
|
|
|
/>
|
|
|
|
<list-tracks :tracks="tracks" :uris="uris" />
|
|
|
|
<modal-dialog-playlist
|
|
|
|
:show="show_playlist_details_modal"
|
|
|
|
:playlist="playlist"
|
|
|
|
:uris="uris"
|
|
|
|
@close="show_playlist_details_modal = false"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
2018-08-11 07:47:10 +02:00
|
|
|
</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'
|
2023-03-23 23:19:55 +01:00
|
|
|
import { GroupByList } from '@/lib/GroupByList'
|
2018-08-11 07:47:10 +02:00
|
|
|
|
2022-02-19 06:18:01 +01:00
|
|
|
const dataObject = {
|
2023-06-07 21:25:54 +02:00
|
|
|
load(to) {
|
2018-08-11 07:47:10 +02:00
|
|
|
return Promise.all([
|
|
|
|
webapi.library_playlist(to.params.playlist_id),
|
|
|
|
webapi.library_playlist_tracks(to.params.playlist_id)
|
|
|
|
])
|
|
|
|
},
|
|
|
|
|
2023-06-07 21:25:54 +02:00
|
|
|
set(vm, response) {
|
2018-08-11 07:47:10 +02:00
|
|
|
vm.playlist = response[0].data
|
2023-03-23 23:19:55 +01:00
|
|
|
vm.tracks = new GroupByList(response[1].data)
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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: {},
|
2023-03-23 23:19:55 +01:00
|
|
|
tracks: new GroupByList(),
|
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: {
|
2023-06-07 21:25:54 +02:00
|
|
|
play() {
|
2020-10-04 17:31:47 +02:00
|
|
|
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>
|