2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<article
|
2022-07-04 13:24:02 +00:00
|
|
|
v-if="showing"
|
2022-04-21 21:51:17 +00:00
|
|
|
:class="layout"
|
2022-06-10 10:47:46 +00:00
|
|
|
:title="`${album.name} by ${album.artist_name}`"
|
2022-04-15 14:24:30 +00:00
|
|
|
class="item"
|
2022-05-10 23:01:48 +00:00
|
|
|
data-testid="album-card"
|
2022-04-15 14:24:30 +00:00
|
|
|
draggable="true"
|
|
|
|
tabindex="0"
|
|
|
|
@dblclick="shuffle"
|
2022-09-03 08:32:09 +00:00
|
|
|
@dragstart="onDragStart"
|
2022-04-30 11:55:54 +00:00
|
|
|
@contextmenu.prevent="requestContextMenu"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-07-22 14:25:30 +00:00
|
|
|
<AlbumThumbnail :entity="album"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<footer>
|
2022-10-09 08:55:58 +00:00
|
|
|
<a :href="`#/album/${album.id}`" class="name" data-testid="name">{{ album.name }}</a>
|
|
|
|
<a v-if="isStandardArtist" :href="`#/artist/${album.artist_id}`" class="artist">{{ album.artist_name }}</a>
|
2022-07-05 21:28:06 +00:00
|
|
|
<span v-else class="text-secondary">{{ album.artist_name }}</span>
|
2022-04-15 14:24:30 +00:00
|
|
|
<p class="meta">
|
2022-10-11 15:28:43 +00:00
|
|
|
<a
|
|
|
|
:title="`Shuffle all songs in the album ${album.name}`"
|
|
|
|
class="shuffle-album"
|
|
|
|
data-testid="shuffle-album"
|
|
|
|
href
|
|
|
|
role="button"
|
|
|
|
@click.prevent="shuffle"
|
|
|
|
>
|
|
|
|
Shuffle
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
v-if="allowDownload"
|
|
|
|
:title="`Download all songs in the album ${album.name}`"
|
|
|
|
class="download-album"
|
|
|
|
data-testid="download-album"
|
|
|
|
href
|
|
|
|
role="button"
|
|
|
|
@click.prevent="download"
|
|
|
|
>
|
|
|
|
Download
|
|
|
|
</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
</p>
|
|
|
|
</footer>
|
|
|
|
</article>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-07 18:05:46 +00:00
|
|
|
import { computed, toRef, toRefs } from 'vue'
|
2022-10-11 15:28:43 +00:00
|
|
|
import { eventBus, requireInjection, secondsToHis } from '@/utils'
|
2022-07-04 13:24:02 +00:00
|
|
|
import { albumStore, artistStore, commonStore, songStore } from '@/stores'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { downloadService, playbackService } from '@/services'
|
2022-09-03 08:32:09 +00:00
|
|
|
import { useDraggable } from '@/composables'
|
2022-10-08 10:54:25 +00:00
|
|
|
import { RouterKey } from '@/symbols'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import AlbumThumbnail from '@/components/ui/AlbumArtistThumbnail.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const router = requireInjection(RouterKey)
|
|
|
|
|
2022-09-03 08:32:09 +00:00
|
|
|
const { startDragging } = useDraggable('album')
|
|
|
|
|
2022-05-02 07:21:14 +00:00
|
|
|
const props = withDefaults(defineProps<{ album: Album, layout?: ArtistAlbumCardLayout }>(), { layout: 'full' })
|
2022-04-15 17:00:08 +00:00
|
|
|
const { album, layout } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allow_download')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const duration = computed(() => secondsToHis(album.value.length))
|
2022-07-04 13:24:02 +00:00
|
|
|
const isStandardArtist = computed(() => artistStore.isStandard(album.value.artist_id))
|
|
|
|
const showing = computed(() => !albumStore.isUnknown(album.value))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const shuffle = async () => {
|
|
|
|
await playbackService.queueAndPlay(await songStore.fetchForAlbum(album.value), true /* shuffled */)
|
2022-10-08 10:54:25 +00:00
|
|
|
router.go('queue')
|
2022-06-10 10:47:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const download = () => downloadService.fromAlbum(album.value)
|
2022-09-03 08:32:09 +00:00
|
|
|
const onDragStart = (event: DragEvent) => startDragging(event, album.value)
|
2022-04-15 17:00:08 +00:00
|
|
|
const requestContextMenu = (event: MouseEvent) => eventBus.emit('ALBUM_CONTEXT_MENU_REQUESTED', event, album.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2022-08-10 14:56:01 +00:00
|
|
|
<style lang="scss" scoped>
|
2022-04-15 14:24:30 +00:00
|
|
|
@include artist-album-card();
|
|
|
|
</style>
|