owntone-server/web-src/src/pages/PageComposerTracks.vue

169 lines
4.4 KiB
Vue
Raw Normal View History

2021-10-23 10:48:11 +01:00
<template>
2023-11-29 01:27:48 +01:00
<div>
2021-10-23 10:48:11 +01:00
<content-with-heading>
<template #options>
2024-02-27 16:27:37 +01:00
<index-button-list :indices="tracks.indices" />
<div class="columns">
<div class="column">
<p class="heading mb-5" v-text="$t('page.artist.sort.title')" />
<control-dropdown
2024-02-22 19:32:11 +01:00
v-model:value="selected_grouping_option_id"
:options="grouping_options"
/>
</div>
</div>
</template>
<template #heading-left>
2022-05-20 13:44:22 +02:00
<p class="title is-4" v-text="composer.name" />
2021-10-23 10:48:11 +01:00
</template>
<template #heading-right>
2021-10-23 10:48:11 +01:00
<div class="buttons is-centered">
<a
class="button is-small is-light is-rounded"
2023-12-07 21:31:10 +01:00
@click="show_details_modal = true"
>
<mdicon class="icon" name="dots-horizontal" size="16" />
2021-10-23 10:48:11 +01:00
</a>
<a class="button is-small is-dark is-rounded" @click="play">
<mdicon class="icon" name="shuffle" size="16" />
<span v-text="$t('page.composer.shuffle')" />
2021-10-23 10:48:11 +01:00
</a>
</div>
</template>
<template #content>
<p class="heading has-text-centered-mobile">
<a
class="has-text-link"
@click="open_albums"
v-text="
$t('page.composer.album-count', {
count: composer.album_count
})
"
/>
<span>&nbsp;|&nbsp;</span>
<span
v-text="
$t('page.composer.track-count', { count: composer.track_count })
"
/>
</p>
<list-tracks :items="tracks" :expression="expression" />
<modal-dialog-composer
2024-03-26 03:13:17 +01:00
:item="composer"
2023-12-07 21:31:10 +01:00
:show="show_details_modal"
@close="show_details_modal = false"
/>
2021-10-23 10:48:11 +01:00
</template>
</content-with-heading>
</div>
</template>
<script>
import * as types from '@/store/mutation_types'
2022-02-19 06:18:01 +01:00
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ControlDropdown from '@/components/ControlDropdown.vue'
import { GroupedList } from '@/lib/GroupedList'
import IndexButtonList from '@/components/IndexButtonList.vue'
import ListTracks from '@/components/ListTracks.vue'
2022-02-19 06:18:01 +01:00
import ModalDialogComposer from '@/components/ModalDialogComposer.vue'
2021-10-23 10:48:11 +01:00
import webapi from '@/webapi'
2022-02-19 06:18:01 +01:00
const dataObject = {
load(to) {
return Promise.all([
webapi.library_composer(to.params.name),
webapi.library_composer_tracks(to.params.name)
])
2021-10-23 10:48:11 +01:00
},
set(vm, response) {
vm.composer = response[0].data
2024-02-22 19:32:11 +01:00
vm.tracks_list = new GroupedList(response[1].data.tracks)
2021-10-23 10:48:11 +01:00
}
}
export default {
name: 'PageComposerTracks',
components: {
ContentWithHeading,
ControlDropdown,
IndexButtonList,
ListTracks,
ModalDialogComposer
},
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()
})
},
2021-10-23 10:48:11 +01:00
data() {
2021-10-23 10:48:11 +01:00
return {
2023-12-07 21:31:10 +01:00
composer: {},
2024-02-22 19:32:11 +01:00
grouping_options: [
{
id: 1,
name: this.$t('page.composer.sort.name'),
options: { index: { field: 'title_sort', type: String } }
},
{
id: 2,
name: this.$t('page.composer.sort.rating'),
options: {
criteria: [{ field: 'rating', type: Number, order: -1 }],
index: { field: 'rating', type: 'Digits' }
}
}
],
2023-12-07 21:31:10 +01:00
show_details_modal: false,
2024-02-22 19:32:11 +01:00
tracks_list: new GroupedList()
2021-10-23 10:48:11 +01:00
}
},
computed: {
expression() {
2023-11-23 20:23:40 +01:00
return `composer is "${this.composer.name}" and media_kind is music`
},
2024-02-22 19:32:11 +01:00
selected_grouping_option_id: {
get() {
return this.$store.state.composer_tracks_sort
},
set(value) {
this.$store.commit(types.COMPOSER_TRACKS_SORT, value)
}
},
tracks() {
2024-02-22 19:32:11 +01:00
const grouping = this.grouping_options.find(
(o) => o.id === this.selected_grouping_option_id
)
2024-02-22 19:32:11 +01:00
this.tracks_list.group(grouping.options)
return this.tracks_list
2021-10-23 10:48:11 +01:00
}
},
methods: {
open_albums() {
2021-10-23 10:48:11 +01:00
this.show_details_modal = false
this.$router.push({
name: 'music-composer-albums',
params: { name: this.composer.name }
})
2021-10-23 10:48:11 +01:00
},
play() {
webapi.player_play_expression(this.expression, true)
2021-10-23 10:48:11 +01:00
}
}
}
</script>
<style></style>