koel/resources/assets/js/components/main-wrapper/main-content/album.vue

149 lines
4.7 KiB
Vue
Raw Normal View History

2016-01-15 07:27:25 +00:00
<template>
<section id="albumWrapper">
<h1 class="heading">
<span class="overview">
<img :src="album.cover" width="64" height="64" class="cover">
{{ album.name }}
2016-02-19 07:20:34 +00:00
<i class="fa fa-angle-down toggler"
v-show="isPhone && !showingControls"
2016-01-15 07:27:25 +00:00
@click="showingControls = true"></i>
2016-02-19 07:20:34 +00:00
<i class="fa fa-angle-up toggler"
v-show="isPhone && showingControls"
2016-01-15 07:27:25 +00:00
@click.prevent="showingControls = false"></i>
<span class="meta" v-show="meta.songCount">
by <a class="artist" @click.prevent="viewArtistDetails">{{ album.artist.name }}</a>
2016-01-15 10:05:54 +00:00
{{ meta.songCount }} {{ meta.songCount | pluralize 'song' }}
2016-02-19 07:20:34 +00:00
2016-01-15 07:27:25 +00:00
{{ meta.totalLength }}
</span>
</span>
<div class="buttons" v-show="!isPhone || showingControls">
2016-02-21 11:04:57 +00:00
<button class="play-shuffle btn btn-orange" @click.prevent="shuffle" v-if="selectedSongs.length < 2">
2016-01-15 07:27:25 +00:00
<i class="fa fa-random"></i> All
</button>
2016-02-21 11:04:57 +00:00
<button class="play-shuffle btn btn-orange" @click.prevent="shuffleSelected" v-if="selectedSongs.length > 1">
2016-01-15 07:27:25 +00:00
<i class="fa fa-random"></i> Selected
</button>
2016-02-21 11:04:57 +00:00
<button class="btn btn-green" @click.prevent.stop="showingAddToMenu = !showingAddToMenu" v-if="selectedSongs.length">
2016-01-15 07:27:25 +00:00
{{ showingAddToMenu ? 'Cancel' : 'Add To…' }}
</button>
2016-01-16 18:11:24 +00:00
<add-to-menu :songs="selectedSongs" :showing="showingAddToMenu"></add-to-menu>
2016-01-15 07:27:25 +00:00
</div>
</h1>
2016-01-16 18:11:24 +00:00
<song-list :items="album.songs" :selected-songs.sync="selectedSongs" type="album"></song-list>
2016-01-15 07:27:25 +00:00
</section>
</template>
<script>
import isMobile from 'ismobilejs';
import albumStore from '../../../stores/album';
import playback from '../../../services/playback';
import hasSongList from '../../../mixins/has-song-list';
export default {
mixins: [hasSongList],
data() {
return {
album: albumStore.stub,
isPhone: isMobile.phone,
showingControls: false,
};
},
2016-03-05 09:01:12 +00:00
watch: {
/**
* Watch the album's song count.
* If this is changed to 0, the user has edit the songs in this album
* and move all of them into another album.
* We should then go back to the album list.
*/
'album.songs.length': function (newVal) {
if (!newVal) {
this.$root.loadMainView('albums');
}
},
},
2016-01-15 07:27:25 +00:00
events: {
/**
2016-01-15 08:13:23 +00:00
* Listen to 'main-content-view:load' event (triggered from $root currently)
* to load the requested album into view if applicable.
*
2016-01-17 14:26:24 +00:00
* @param {String} view The view name
2016-01-15 08:13:23 +00:00
* @param {Object} album The album object
2016-01-15 07:27:25 +00:00
*/
2016-01-15 08:13:23 +00:00
'main-content-view:load': function (view, album) {
if (view === 'album') {
this.album = album;
}
2016-01-15 07:27:25 +00:00
},
},
methods: {
/**
* Shuffle the songs in the current album.
*/
shuffle() {
playback.queueAndPlay(this.album.songs, true);
},
/**
* Load the artist details screen.
*/
viewArtistDetails() {
this.$root.loadArtist(this.album.artist);
},
},
};
</script>
<style lang="sass" scoped>
@import "resources/assets/sass/partials/_vars.scss";
@import "resources/assets/sass/partials/_mixins.scss";
#albumWrapper {
button.play-shuffle {
i {
margin-right: 0 !important;
}
}
.heading {
.overview {
position: relative;
padding-left: 84px;
@media only screen and (max-device-width : 768px) {
padding-left: 0;
}
2016-01-15 07:27:25 +00:00
}
.cover {
position: absolute;
left: 0;
top: -7px;
@media only screen and (max-device-width : 768px) {
display: none;
}
2016-01-15 07:27:25 +00:00
}
a.artist {
color: $colorMainText;
display: inline;
&:hover {
color: $colorHighlight;
}
}
}
}
</style>