Newer
Older
<b-modal
ref="modalFallbackSelector"
:title="$t('playlistSelector.defaultTitle')"
:cancel-title="$t('cancel')"
size="lg"
>
<p v-if="loaded">
{{ $t('playlistSelector.currentPlaylistLabel') }}:

Konrad Mohrfeldt
committed
<span v-if="show.defaultPlaylistId === null">
<i
><small>{{ $t('noneSetFeminine') }}</small></i
>
</span>
<span v-else>

Konrad Mohrfeldt
committed
{{ show.defaultPlaylistId }},
<br />
<span v-if="currentPlaylistDescription">
{{ $t('showMeta.description') }}: <b>{{ currentPlaylistDescription }}</b>
</span>
</span>
</p>
<div v-if="loaded">
<b-table ref="playlistsTable" striped :fields="playlistsTableFields" :items="playlists">
<!-- Column: Entries
This column displays the number of entries of the playlist.
-->
<template #cell(entries)="data">
<span
v-b-tooltip.html="playlistToolTip(data.value)"
class="tw-underline hover:tw-no-underline tw-cursor-help"
>
{{ $t('playlistTable.items', { smart_count: data.value.length }) }}
</span>
</template>
<!-- Column: Duration
This column displays the number of entries of the playlist.
-->
<template #cell(duration)="data">
{{ playlistDuration(data.item) }}
</template>
This column displays the available buttons for actions the user can
take on this playlist (e.g. editing and deleting).
-->
<template #cell(actions)="data">
<b-button-group size="sm">
<b-button

Konrad Mohrfeldt
committed
v-if="data.item.id !== show.defaultPlaylistId"
<b-button v-else variant="danger" @click="choose(null)">
{{ $t('playlistTable.unset') }}
</b-button>
</b-button-group>
</template>
</b-table>
</div>
<div v-else>
<img src="/assets/radio.gif" :alt="$t('loading')" />
</div>
<div>
<b-button :to="'files'">
{{ $t('playlistSelector.goToFiles') }}
</b-button>
</div>
</b-modal>
</template>
<script>
import { mapGetters } from 'vuex'
import prettyDate from '@/mixins/prettyDate'
import playlist from '@/mixins/playlist'
export default {
mixins: [prettyDate, playlist],

Konrad Mohrfeldt
committed
props: {
show: { type: Object, required: true },
},
},
computed: {
loaded() {
return this.$store.state.playlists.loaded.playlists
},
playlistsTableFields() {
return [
{ key: 'id', label: this.$t('playlistTable.index') },
{ key: 'description', label: this.$t('playlistTable.description') },
{ key: 'entries', label: this.$t('playlistTable.entries') },
{ key: 'duration', label: this.$t('playlistTable.duration') },
{ key: 'actions', label: this.$t('playlistTable.actions'), class: 'text-right' },
]
},
currentPlaylistDescription() {
let description = false

Konrad Mohrfeldt
committed
if (this.show.defaultPlaylistId !== null) {
const choosenList = this.playlists.find((list) => list.id === this.show.defaultPlaylistId)
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
if (choosenList && choosenList.description.length > 0) {
description = choosenList.description
}
}
return description
},
...mapGetters({
playlists: 'playlists/playlists',
}),
},
methods: {
open(saveFunction) {
this.saveFunction = saveFunction
this.$refs.modalFallbackSelector.show()
},
hide() {
this.$refs.modalFallbackSelector.hide()
},
choose(id) {
this.saveFunction(id)
},
playlistToolTip(entries) {
let text = '<div style="white-space: nowrap;" align="left">'
for (const i in entries) {
text += i + ': ' + entries[i].uri + '<br>'
}
text += '</div>'
return text
},
},
}
</script>