koel/resources/assets/js/components/playlist/PlaylistContextMenu.vue

28 lines
1,007 B
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<ContextMenuBase ref="base">
<li :data-testid="`playlist-context-menu-edit-${playlist.id}`" @click="editPlaylist">
{{ playlist.is_smart ? 'Edit' : 'Rename' }}
</li>
<li :data-testid="`playlist-context-menu-delete-${playlist.id}`" @click="deletePlaylist">Delete</li>
2022-04-24 08:29:14 +00:00
</ContextMenuBase>
2022-04-15 14:24:30 +00:00
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
2022-04-15 14:24:30 +00:00
import { eventBus } from '@/utils'
2022-04-15 17:00:08 +00:00
import { useContextMenu } from '@/composables'
2022-04-15 14:24:30 +00:00
2022-06-10 10:47:46 +00:00
const { context, base, ContextMenuBase, open, trigger } = useContextMenu()
const playlist = ref<Playlist>()
2022-04-15 14:24:30 +00:00
const editPlaylist = () => trigger(() => eventBus.emit('MODAL_SHOW_EDIT_PLAYLIST_FORM', playlist.value))
2022-06-10 10:47:46 +00:00
const deletePlaylist = () => trigger(() => eventBus.emit('PLAYLIST_DELETE', playlist.value))
onMounted(() => {
eventBus.on('PLAYLIST_CONTEXT_MENU_REQUESTED', async (event: MouseEvent, _playlist: Playlist) => {
playlist.value = _playlist
await open(event.pageY, event.pageX, { playlist })
})
})
2022-04-15 14:24:30 +00:00
</script>