owntone-server/web-src/src/components/ModalDialogPlayable.vue

106 lines
2.7 KiB
Vue
Raw Normal View History

<template>
<modal-dialog :actions="actions" :show="show" @close="$emit('close')">
<template #content>
2025-02-09 17:52:45 +01:00
<div class="title is-4">
2025-02-12 18:50:22 +01:00
<a v-if="item.handler" @click="item.handler" v-text="item.name"></a>
2025-02-09 17:52:45 +01:00
<span v-else v-text="item.name" />
</div>
<cover-artwork
v-if="item.image"
:url="item.image"
:artist="item.artist"
:album="item.name"
2025-02-11 19:05:15 +01:00
class="is-normal mb-5"
2025-02-09 17:52:45 +01:00
/>
2025-02-11 19:05:15 +01:00
<div class="buttons">
<a
v-for="button in buttons"
:key="button.label"
v-t="button.label"
class="button is-small"
2025-02-12 18:50:22 +01:00
@click="button.handler"
2025-02-11 19:05:15 +01:00
/>
2025-02-09 17:52:45 +01:00
</div>
<div
v-for="property in item.properties?.filter((p) => p.value)"
:key="property.label"
class="mb-3"
>
<div v-t="property.label" class="is-size-7 is-uppercase" />
<div class="title is-6">
<a
2025-02-12 18:50:22 +01:00
v-if="property.handler"
@click="property.handler"
2025-02-09 17:52:45 +01:00
v-text="property.value"
/>
<span v-else class="title is-6" v-text="property.value" />
</div>
</div>
</template>
</modal-dialog>
</template>
<script>
2025-02-09 17:52:45 +01:00
import CoverArtwork from '@/components/CoverArtwork.vue'
import ModalDialog from '@/components/ModalDialog.vue'
import webapi from '@/webapi'
export default {
name: 'ModalDialogPlayable',
2025-02-09 17:52:45 +01:00
components: { ModalDialog, CoverArtwork },
props: {
2025-02-09 17:52:45 +01:00
buttons: { default: () => [], type: Array },
item: { required: true, type: Object },
show: Boolean
},
emits: ['close'],
computed: {
actions() {
return [
{
label: this.$t('dialog.playable.add'),
handler: this.queue_add,
icon: 'playlist-plus'
},
{
label: this.$t('dialog.playable.add-next'),
handler: this.queue_add_next,
icon: 'playlist-play'
},
{
label: this.$t('dialog.playable.play'),
handler: this.play,
icon: 'play'
}
]
}
},
methods: {
play() {
this.$emit('close')
2025-02-09 17:52:45 +01:00
if (this.item.expression) {
webapi.player_play_expression(this.item.expression, false)
} else {
2025-02-09 17:52:45 +01:00
webapi.player_play_uri(this.item.uris || this.item.item.uri, false)
}
},
queue_add() {
this.$emit('close')
2025-02-09 17:52:45 +01:00
if (this.item.expression) {
webapi.queue_expression_add(this.item.expression)
} else {
2025-02-09 17:52:45 +01:00
webapi.queue_add(this.item.uris || this.item.uri)
}
},
queue_add_next() {
this.$emit('close')
2025-02-09 17:52:45 +01:00
if (this.item.expression) {
webapi.queue_expression_add_next(this.item.expression)
} else {
2025-02-09 17:52:45 +01:00
webapi.queue_add_next(this.item.uris || this.item.uri)
}
}
}
}
</script>