2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-10-23 17:52:07 +00:00
|
|
|
<ArtistAlbumCard
|
2022-07-04 13:24:02 +00:00
|
|
|
v-if="showing"
|
2022-10-23 17:52:07 +00:00
|
|
|
:entity="album"
|
|
|
|
:layout="layout"
|
2024-04-23 21:01:27 +00:00
|
|
|
:title="`${album.name} by ${album.artist_name}`"
|
2022-10-23 17:52:07 +00:00
|
|
|
@contextmenu="requestContextMenu"
|
2022-04-15 14:24:30 +00:00
|
|
|
@dblclick="shuffle"
|
2022-09-03 08:32:09 +00:00
|
|
|
@dragstart="onDragStart"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-10-23 17:52:07 +00:00
|
|
|
<template #name>
|
2024-04-04 22:20:42 +00:00
|
|
|
<a :href="`#/album/${album.id}`" class="font-medium" data-testid="name">{{ album.name }}</a>
|
2022-10-23 17:52:07 +00:00
|
|
|
<a v-if="isStandardArtist" :href="`#/artist/${album.artist_id}`">{{ album.artist_name }}</a>
|
2024-04-04 22:20:42 +00:00
|
|
|
<span v-else class="text-k-text-secondary">{{ album.artist_name }}</span>
|
2022-10-23 17:52:07 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #meta>
|
2024-04-04 22:20:42 +00:00
|
|
|
<a :title="`Shuffle all songs in the album ${album.name}`" role="button" @click.prevent="shuffle">
|
2022-10-23 17:52:07 +00:00
|
|
|
Shuffle
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
v-if="allowDownload"
|
|
|
|
:title="`Download all songs in the album ${album.name}`"
|
|
|
|
role="button"
|
|
|
|
@click.prevent="download"
|
|
|
|
>
|
|
|
|
Download
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</ArtistAlbumCard>
|
2022-04-15 14:24:30 +00:00
|
|
|
</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-11-18 18:44:20 +00:00
|
|
|
import { eventBus } 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-11-18 18:44:20 +00:00
|
|
|
import { useDraggable, useRouter } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-23 17:52:07 +00:00
|
|
|
import ArtistAlbumCard from '@/components/ui/ArtistAlbumCard.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-18 18:44:20 +00:00
|
|
|
const { go } = useRouter()
|
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
|
|
|
|
2024-01-04 11:35:36 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allows_download')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
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 () => {
|
2022-10-21 20:06:43 +00:00
|
|
|
playbackService.queueAndPlay(await songStore.fetchForAlbum(album.value), true /* shuffled */)
|
2022-11-18 18:44:20 +00:00
|
|
|
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>
|