[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"> <p class="title is-4">
<a class="has-text-link" @click="open_album">{{ album.name }}</a> <a class="has-text-link" @click="open_album">{{ album.name }}</a>
</p> </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"> <div class="content is-small">
<p v-if="album.artist && media_kind !== 'audiobook'"> <p v-if="album.artist && media_kind !== 'audiobook'">
<span class="heading">Album artist</span> <span class="heading">Album artist</span>
@ -51,7 +54,7 @@ import webapi from '@/webapi'
export default { export default {
name: 'ModalDialogAlbum', name: 'ModalDialogAlbum',
props: ['show', 'album', 'media_kind'], props: ['show', 'album', 'media_kind', 'new_tracks'],
data () { data () {
return { return {
@ -95,6 +98,13 @@ export default {
this.$router.push({ path: '/music/artists/' + this.album.artist_id }) 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 () { artwork_loaded: function () {
this.artwork_visible = true this.artwork_visible = true
}, },

View File

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