2015-12-13 04:42:28 +00:00
|
|
|
<template>
|
2016-04-17 15:38:06 +00:00
|
|
|
<article class="item" v-if="showing" draggable="true" @dragstart="dragStart">
|
2016-01-16 18:11:24 +00:00
|
|
|
<span class="cover" :style="{ backgroundImage: 'url(' + artist.image + ')' }">
|
2015-12-13 04:42:28 +00:00
|
|
|
<a class="control" @click.prevent="play">
|
|
|
|
<i class="fa fa-play"></i>
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<footer>
|
2016-05-30 08:04:22 +00:00
|
|
|
<a class="name" @click.prevent="viewArtistDetails(artist)">{{ artist.name }}</a>
|
2015-12-13 04:42:28 +00:00
|
|
|
<p class="meta">
|
2016-06-04 11:57:27 +00:00
|
|
|
<span class="left">
|
2016-06-25 05:24:55 +00:00
|
|
|
{{ artist.albums.length | pluralize('album') }}
|
2016-06-04 11:57:27 +00:00
|
|
|
•
|
2016-06-25 05:24:55 +00:00
|
|
|
{{ artist.songCount | pluralize('song') }}
|
2016-06-04 11:57:27 +00:00
|
|
|
•
|
2016-06-25 05:24:55 +00:00
|
|
|
{{ artist.playCount | pluralize('play') }}
|
2016-06-04 11:57:27 +00:00
|
|
|
</span>
|
|
|
|
<span class="right">
|
2016-06-05 16:57:15 +00:00
|
|
|
<a href="#" @click.prevent="download" v-if="sharedState.allowDownload" title="Download all songs by artist">
|
2016-06-04 11:57:27 +00:00
|
|
|
<i class="fa fa-download"></i>
|
|
|
|
</a>
|
|
|
|
</span>
|
2015-12-13 04:42:28 +00:00
|
|
|
</p>
|
|
|
|
</footer>
|
|
|
|
</article>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2016-03-31 08:58:46 +00:00
|
|
|
import { map } from 'lodash';
|
2016-02-14 08:34:14 +00:00
|
|
|
import $ from 'jquery';
|
|
|
|
|
2016-06-25 05:24:55 +00:00
|
|
|
import { pluralize } from '../../utils';
|
2016-06-25 10:15:57 +00:00
|
|
|
import { artistStore, queueStore, sharedStore } from '../../stores';
|
|
|
|
import { playback, download } from '../../services';
|
2016-05-30 08:04:22 +00:00
|
|
|
import artistAlbumDetails from '../../mixins/artist-album-details';
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
export default {
|
2016-06-25 05:24:55 +00:00
|
|
|
name: 'shared--artist-item',
|
2015-12-13 04:42:28 +00:00
|
|
|
props: ['artist'],
|
2016-05-30 08:04:22 +00:00
|
|
|
mixins: [artistAlbumDetails],
|
2016-06-25 05:24:55 +00:00
|
|
|
filters: { pluralize },
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-04 11:57:27 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
sharedState: sharedStore.state,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2016-04-17 15:38:06 +00:00
|
|
|
computed: {
|
|
|
|
/**
|
|
|
|
* Determine if the artist item should be shown.
|
|
|
|
* We're not showing those without any songs, or the special "Various Artists".
|
|
|
|
*
|
|
|
|
* @return {Boolean}
|
|
|
|
*/
|
|
|
|
showing() {
|
|
|
|
return this.artist.songCount && !artistStore.isVariousArtists(this.artist);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-12-13 04:42:28 +00:00
|
|
|
methods: {
|
|
|
|
/**
|
2016-02-14 08:20:33 +00:00
|
|
|
* Play all songs by the current artist, or queue them up if Ctrl/Cmd key is pressed.
|
2015-12-13 04:42:28 +00:00
|
|
|
*/
|
2016-02-14 08:34:14 +00:00
|
|
|
play(e) {
|
|
|
|
if (e.metaKey || e.ctrlKey) {
|
2016-04-17 15:38:06 +00:00
|
|
|
queueStore.queue(this.artist.songs);
|
2016-02-14 08:20:33 +00:00
|
|
|
} else {
|
|
|
|
playback.playAllByArtist(this.artist);
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
},
|
2016-01-15 07:27:25 +00:00
|
|
|
|
2016-06-04 11:57:27 +00:00
|
|
|
/**
|
|
|
|
* Download all songs by artist.
|
|
|
|
*/
|
|
|
|
download() {
|
|
|
|
download.fromArtist(this.artist);
|
|
|
|
},
|
|
|
|
|
2016-02-14 08:34:14 +00:00
|
|
|
/**
|
|
|
|
* Allow dragging the artist (actually, their songs).
|
|
|
|
*/
|
|
|
|
dragStart(e) {
|
2016-04-17 15:38:06 +00:00
|
|
|
const songIds = map(this.artist.songs, 'id');
|
2016-02-14 08:34:14 +00:00
|
|
|
e.dataTransfer.setData('text/plain', songIds);
|
|
|
|
e.dataTransfer.effectAllowed = 'move';
|
|
|
|
|
|
|
|
// Set a fancy drop image using our ghost element.
|
2016-03-28 13:38:14 +00:00
|
|
|
const $ghost = $('#dragGhost').text(`All ${songIds.length} song${songIds.length === 1 ? '' : 's'} by ${this.artist.name}`);
|
2016-02-14 08:34:14 +00:00
|
|
|
e.dataTransfer.setDragImage($ghost[0], 0, 0);
|
|
|
|
},
|
2015-12-13 04:42:28 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="sass">
|
2016-03-13 17:00:32 +00:00
|
|
|
@import "../../../sass/partials/_vars.scss";
|
|
|
|
@import "../../../sass/partials/_mixins.scss";
|
2016-01-15 07:27:25 +00:00
|
|
|
|
2016-02-08 12:21:24 +00:00
|
|
|
@include artist-album-card();
|
2015-12-13 04:42:28 +00:00
|
|
|
</style>
|