2022-08-10 14:56:01 +00:00
|
|
|
<template>
|
2022-09-08 05:06:49 +00:00
|
|
|
<ContextMenuBase ref="base">
|
2022-08-10 14:56:01 +00:00
|
|
|
<template v-if="folder">
|
|
|
|
<template v-if="playable">
|
2022-09-08 05:06:49 +00:00
|
|
|
<li @click="play">Play All</li>
|
|
|
|
<li @click="shuffle">Shuffle All</li>
|
2022-08-10 14:56:01 +00:00
|
|
|
<li class="separator"/>
|
|
|
|
</template>
|
2022-09-08 05:06:49 +00:00
|
|
|
<li @click="rename">Rename</li>
|
|
|
|
<li @click="destroy">Delete</li>
|
2022-08-10 14:56:01 +00:00
|
|
|
</template>
|
|
|
|
</ContextMenuBase>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
import { useContextMenu } from '@/composables'
|
|
|
|
import { eventBus, requireInjection } from '@/utils'
|
2022-09-08 05:06:49 +00:00
|
|
|
import { playlistStore, songStore } from '@/stores'
|
2022-08-10 14:56:01 +00:00
|
|
|
import { playbackService } from '@/services'
|
2022-10-08 10:54:25 +00:00
|
|
|
import { DialogBoxKey, RouterKey } from '@/symbols'
|
2022-08-10 14:56:01 +00:00
|
|
|
|
|
|
|
const { context, base, ContextMenuBase, open, trigger } = useContextMenu()
|
|
|
|
|
|
|
|
const dialog = requireInjection(DialogBoxKey)
|
2022-10-08 10:54:25 +00:00
|
|
|
const router = requireInjection(RouterKey)
|
2022-08-10 14:56:01 +00:00
|
|
|
const folder = ref<PlaylistFolder>()
|
|
|
|
|
|
|
|
const playlistsInFolder = computed(() => folder.value ? playlistStore.byFolder(folder.value) : [])
|
|
|
|
const playable = computed(() => playlistsInFolder.value.length > 0)
|
|
|
|
|
|
|
|
const play = () => trigger(async () => {
|
|
|
|
await playbackService.queueAndPlay(await songStore.fetchForPlaylistFolder(folder.value!))
|
|
|
|
router.go('queue')
|
|
|
|
})
|
|
|
|
|
|
|
|
const shuffle = () => trigger(async () => {
|
|
|
|
await playbackService.queueAndPlay(await songStore.fetchForPlaylistFolder(folder.value!), true)
|
|
|
|
router.go('queue')
|
|
|
|
})
|
|
|
|
|
2022-09-08 05:06:49 +00:00
|
|
|
const rename = () => trigger(() => eventBus.emit('MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM', folder.value))
|
|
|
|
const destroy = () => trigger(() => eventBus.emit('PLAYLIST_FOLDER_DELETE', folder.value))
|
2022-08-10 14:56:01 +00:00
|
|
|
|
|
|
|
eventBus.on('PLAYLIST_FOLDER_CONTEXT_MENU_REQUESTED', async (e: MouseEvent, _folder: PlaylistFolder) => {
|
|
|
|
folder.value = _folder
|
|
|
|
await open(e.pageY, e.pageX, { folder })
|
|
|
|
})
|
|
|
|
</script>
|