[web-src] Move "mark all played" to album modal

This commit is contained in:
chme 2020-04-12 07:29:07 +02:00
parent 6424e23f14
commit 77b4ea657a
2 changed files with 29 additions and 22 deletions

View File

@ -12,6 +12,9 @@
<p class="title is-4">
<a class="has-text-link" @click="open_album">{{ album.name }}</a>
</p>
<div class="buttons" v-if="media_kind === 'podcast' && new_tracks > 0">
<a class="button is-small" @click="mark_played">Mark as played</a>
</div>
<div class="content is-small">
<p v-if="album.artist && media_kind !== 'audiobook'">
<span class="heading">Album artist</span>
@ -51,7 +54,7 @@ import webapi from '@/webapi'
export default {
name: 'ModalDialogAlbum',
props: ['show', 'album', 'media_kind'],
props: ['show', 'album', 'media_kind', 'new_tracks'],
data () {
return {
@ -95,6 +98,13 @@ export default {
this.$router.push({ path: '/music/artists/' + this.album.artist_id })
},
mark_played: function () {
webapi.library_album_track_update(this.album.id, { play_count: 'played' }).then(({ data }) => {
this.$emit('play_count_changed')
this.$emit('close')
})
},
artwork_loaded: function () {
this.artwork_visible = true
},

View File

@ -12,12 +12,6 @@
</template>
<template slot="heading-right">
<div class="buttons is-centered">
<a class="button is-small" @click="mark_all_played" v-if="unplayed">
<span class="icon">
<i class="mdi mdi-pencil"></i>
</span>
<span>Mark All Played</span>
</a>
<a class="button is-small is-light is-rounded" @click="show_album_details_modal = true">
<span class="icon"><i class="mdi mdi-dots-horizontal mdi-18px"></i></span>
</a>
@ -48,8 +42,18 @@
</a>
</template>
</list-item-track>
<modal-dialog-track :show="show_details_modal" :track="selected_track" @close="show_details_modal = false" @play_count_changed="reload_tracks" />
<modal-dialog-album :show="show_album_details_modal" :album="album" :media_kind="'podcast'" @close="show_album_details_modal = false" />
<modal-dialog-track
:show="show_details_modal"
:track="selected_track"
@close="show_details_modal = false"
@play_count_changed="reload_tracks" />
<modal-dialog-album
:show="show_album_details_modal"
:album="album"
:media_kind="'podcast'"
:new_tracks="new_tracks"
@close="show_album_details_modal = false"
@play_count_changed="reload_tracks" />
</template>
</content-with-heading>
</template>
@ -74,7 +78,6 @@ const albumData = {
set: function (vm, response) {
vm.album = response[0].data
vm.tracks = response[1].data.tracks.items
vm.unplayed = !vm.tracks.every(track => track.play_count > 0)
}
}
@ -87,7 +90,6 @@ export default {
return {
album: {},
tracks: [],
unplayed: false,
show_details_modal: false,
selected_track: {},
@ -96,6 +98,12 @@ export default {
}
},
computed: {
new_tracks () {
return this.tracks.filter(track => track.play_count === 0).length
}
},
methods: {
play: function () {
webapi.player_play_uri(this.album.uri, false)
@ -105,17 +113,6 @@ export default {
webapi.player_play_uri(track.uri, false)
},
mark_all_played: function () {
webapi.library_album_track_update(this.album.id, { play_count: 'played' }).then(({ data }) => (
this.tracks.forEach(track => {
if (track.play_count === 0) {
track.play_count = 1
}
})
))
this.unplayed = false
},
open_dialog: function (track) {
this.selected_track = track
this.show_details_modal = true