Newer
Older
Eliot Berriot
committed
<template>
<div class="ui card">
<div class="content">
<div class="right floated tiny ui image">
<img v-if="album.cover.original" v-lazy="$store.getters['instance/absoluteUrl'](album.cover.square_crop)">
Eliot Berriot
committed
<img v-else src="../../../assets/audio/default-cover.png">
</div>
<div class="header">
<router-link class="discrete link" :to="{name: 'library.albums.detail', params: {id: album.id }}">{{ album.title }} </router-link>
Eliot Berriot
committed
</div>
<div class="meta">
<span>
<router-link :title="album.artist.name" tag="span" :to="{name: 'library.artists.detail', params: {id: album.artist.id }}">
<span v-translate="{artist: album.artist.name}" translate-context="Content/Album/Card" :translate-params="{artist: album.artist.name}">By %{ artist }</span>
</span><span class="time" v-if="album.release_date">– {{ album.release_date | year }}</span>
Eliot Berriot
committed
</div>
<div class="description" v-if="mode === 'rich'">
<table class="ui very basic fixed single line compact unstackable table">
Eliot Berriot
committed
<tbody>
<tr v-for="track in tracks">
Ciarán Ainsworth
committed
<play-button :class="['basic', {orange: isPlaying && track.id === currentTrack.id}, 'icon']" :discrete="true" :track="track"></play-button>
Eliot Berriot
committed
</td>
<td class="content-cell" colspan="5">
<track-favorite-icon :track="track"></track-favorite-icon>
<router-link :title="track.title" class="track discrete link" :to="{name: 'library.tracks.detail', params: {id: track.id }}">
Eliot Berriot
committed
<template v-if="track.position">
{{ track.position }}.
</template>
Eliot Berriot
committed
{{ track.title }}
</router-link>
</td>
</tr>
</tbody>
</table>
<div class="center aligned segment" v-if="album.tracks.length > initialTracks">
<em v-if="!showAllTracks" @click="showAllTracks = true" class="expand">
<translate translate-context="Content/Album/Card.Link/Verb" :translate-params="{count: album.tracks.length - initialTracks}" :translate-n="album.tracks.length - initialTracks" translate-plural="Show %{ count } more tracks">Show %{ count } more track</translate>
</em>
<em v-else @click="showAllTracks = false" class="expand">
<translate translate-context="Content/*/Card.Link/Verb">Collapse</translate>
Eliot Berriot
committed
</div>
</div>
</div>
<div class="extra content">
Eliot Berriot
committed
<play-button class="mini basic orange right floated" :tracks="tracksWithAlbum" :album="album">
<translate translate-context="Content/Queue/Button.Label/Short, Verb">Play all</translate>
Eliot Berriot
committed
<span>
<i class="music icon"></i>
<translate translate-context="*/*/*" :translate-params="{count: album.tracks.length}" :translate-n="album.tracks.length" translate-plural="%{ count } tracks">%{ count } track</translate>
Eliot Berriot
committed
</span>
</div>
</div>
</template>
<script>
Ciarán Ainsworth
committed
import { mapGetters } from "vuex"
Eliot Berriot
committed
import backend from '@/audio/backend'
import TrackFavoriteIcon from '@/components/favorites/TrackFavoriteIcon'
import PlayButton from '@/components/audio/PlayButton'
export default {
props: {
album: {type: Object},
Ciarán Ainsworth
committed
mode: {type: String, default: 'rich'},
Eliot Berriot
committed
},
components: {
TrackFavoriteIcon,
PlayButton
},
data () {
return {
backend: backend,
Eliot Berriot
committed
showAllTracks: false
}
},
computed: {
tracks () {
if (this.showAllTracks) {
return this.album.tracks
}
return this.album.tracks.slice(0, this.initialTracks)
Eliot Berriot
committed
},
Ciarán Ainsworth
committed
...mapGetters({
currentTrack: "queue/currentTrack",
}),
isPlaying () {
return this.$store.state.player.playing
},
Eliot Berriot
committed
tracksWithAlbum () {
// needed to include album data (especially cover)
// with tracks appended in queue (#795)
let self = this
return this.album.tracks.map(t => {
return {
...t,
album: {
...self.album,
tracks: []
}
}
})
Eliot Berriot
committed
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.content-cell {
.link,
.button {
padding: 0.5em 0;
}
.link {
margin-left: 0.5em;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Eliot Berriot
committed
tr {
.favorite-icon:not(.favorited) {
Eliot Berriot
committed
}
&:hover .favorite-icon {
visibility: visible;
}
.favorite-icon {
float: right;
Eliot Berriot
committed
}
}
.expand {
cursor: pointer;
}
</style>