2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2024-04-04 22:20:42 +00:00
|
|
|
<div class="add-to w-full max-w-[256px] min-w-[200px] p-3 space-y-3" data-testid="add-to-menu" tabindex="0">
|
2022-04-15 14:24:30 +00:00
|
|
|
<section class="existing-playlists">
|
2024-04-04 22:20:42 +00:00
|
|
|
<p class="mb-2 text-[0.9rem]">Add {{ pluralize(songs, 'song') }} to</p>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<ul v-koel-overflow-fade class="relative max-h-48 overflow-y-scroll space-y-1.5">
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-if="config.queue">
|
2022-04-30 20:57:04 +00:00
|
|
|
<template v-if="queue.length">
|
2022-05-09 12:25:19 +00:00
|
|
|
<li
|
|
|
|
v-if="currentSong"
|
|
|
|
class="queue-after-current"
|
|
|
|
data-testid="queue-after-current"
|
|
|
|
tabindex="0"
|
|
|
|
@click="queueSongsAfterCurrent"
|
|
|
|
>
|
2022-04-30 20:57:04 +00:00
|
|
|
After Current Song
|
|
|
|
</li>
|
2022-05-09 12:25:19 +00:00
|
|
|
<li class="bottom-queue" data-testid="queue-bottom" tabindex="0" @click="queueSongsToBottom">
|
|
|
|
Bottom of Queue
|
|
|
|
</li>
|
|
|
|
<li class="top-queue" data-testid="queue-top" tabindex="0" @click="queueSongsToTop">Top of Queue</li>
|
2022-04-30 20:57:04 +00:00
|
|
|
</template>
|
2022-05-09 12:25:19 +00:00
|
|
|
<li v-else data-testid="queue" tabindex="0" @click="queueSongsToBottom">Queue</li>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<li
|
2022-05-09 12:25:19 +00:00
|
|
|
v-if="config.favorites"
|
2022-04-15 14:24:30 +00:00
|
|
|
class="favorites"
|
2022-05-09 12:25:19 +00:00
|
|
|
data-testid="add-to-favorites"
|
2022-04-15 14:24:30 +00:00
|
|
|
tabindex="0"
|
2022-05-09 12:25:19 +00:00
|
|
|
@click="addSongsToFavorite"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
Favorites
|
|
|
|
</li>
|
|
|
|
|
2022-12-06 10:28:48 +00:00
|
|
|
<li
|
|
|
|
v-for="playlist in playlists"
|
|
|
|
:key="playlist.id"
|
|
|
|
class="playlist"
|
|
|
|
data-testid="add-to-playlist"
|
|
|
|
tabindex="0"
|
|
|
|
@click="addSongsToExistingPlaylist(playlist)"
|
|
|
|
>
|
|
|
|
{{ playlist.name }}
|
|
|
|
</li>
|
2022-04-15 14:24:30 +00:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
<Btn
|
|
|
|
class="!w-full !border !border-solid !border-white/20"
|
|
|
|
transparent
|
|
|
|
@click.prevent="addSongsToNewPlaylist"
|
|
|
|
>
|
|
|
|
New Playlist…
|
|
|
|
</Btn>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2024-03-19 22:48:12 +00:00
|
|
|
import { computed, toRef, toRefs, watch } from 'vue'
|
2022-11-18 18:44:20 +00:00
|
|
|
import { pluralize } from '@/utils'
|
2022-04-30 20:57:04 +00:00
|
|
|
import { playlistStore, queueStore } from '@/stores'
|
2022-12-06 10:28:48 +00:00
|
|
|
import { useSongMenuMethods } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
import Btn from '@/components/ui/form/Btn.vue'
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-11-13 15:18:24 +00:00
|
|
|
const props = defineProps<{ songs: Song[], config: AddToMenuConfig }>()
|
|
|
|
const { songs, config } = toRefs(props)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-04-30 20:57:04 +00:00
|
|
|
const queue = toRef(queueStore.state, 'songs')
|
2022-09-12 15:33:41 +00:00
|
|
|
const currentSong = queueStore.current
|
2022-04-25 16:13:18 +00:00
|
|
|
|
|
|
|
const allPlaylists = toRef(playlistStore.state, 'playlists')
|
2024-01-24 22:39:47 +00:00
|
|
|
const playlists = computed(() => allPlaylists.value.filter(({ is_smart }) => !is_smart))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-11-13 15:18:24 +00:00
|
|
|
const emit = defineEmits<{ (e: 'closing'): void }>()
|
2022-04-15 17:00:08 +00:00
|
|
|
const close = () => emit('closing')
|
|
|
|
|
|
|
|
const {
|
|
|
|
queueSongsAfterCurrent,
|
|
|
|
queueSongsToBottom,
|
|
|
|
queueSongsToTop,
|
|
|
|
addSongsToFavorite,
|
2022-12-06 10:28:48 +00:00
|
|
|
addSongsToExistingPlaylist,
|
|
|
|
addSongsToNewPlaylist
|
2022-04-20 10:20:09 +00:00
|
|
|
} = useSongMenuMethods(songs, close)
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
watch(songs, () => songs.value.length || close())
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
<style lang="postcss" scoped>
|
2024-04-04 22:20:42 +00:00
|
|
|
li {
|
|
|
|
@apply h-9 leading-9 py-0 px-3 whitespace-nowrap overflow-hidden text-ellipsis rounded bg-white/5 cursor-pointer
|
2024-04-23 21:01:27 +00:00
|
|
|
hover:bg-k-highlight hover:text-k-text-primary;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
</style>
|