2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-09-08 05:06:49 +00:00
|
|
|
<ContextMenuBase ref="base">
|
2022-08-10 14:56:01 +00:00
|
|
|
<li data-testid="playlist-context-menu-create-simple" @click="onItemClicked('new-playlist')">New Playlist</li>
|
|
|
|
<li data-testid="playlist-context-menu-create-smart" @click="onItemClicked('new-smart-playlist')">
|
|
|
|
New Smart Playlist
|
|
|
|
</li>
|
|
|
|
<li data-testid="playlist-context-menu-create-folder" @click="onItemClicked('new-folder')">New Folder</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 { useContextMenu } from '@/composables'
|
2022-08-10 14:56:01 +00:00
|
|
|
import { eventBus } from '@/utils'
|
|
|
|
import { EventName } from '@/config'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const { base, ContextMenuBase, open, trigger } = useContextMenu()
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-08-10 14:56:01 +00:00
|
|
|
const actionToEventMap: Record<string, EventName> = {
|
|
|
|
'new-playlist': 'MODAL_SHOW_CREATE_PLAYLIST_FORM',
|
|
|
|
'new-smart-playlist': 'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM',
|
|
|
|
'new-folder': 'MODAL_SHOW_CREATE_PLAYLIST_FOLDER_FORM'
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-08-10 14:56:01 +00:00
|
|
|
const onItemClicked = (key: keyof typeof actionToEventMap) => trigger(() => eventBus.emit(actionToEventMap[key]))
|
2022-04-20 12:38:38 +00:00
|
|
|
|
2022-11-15 15:52:38 +00:00
|
|
|
eventBus.on('CREATE_NEW_PLAYLIST_CONTEXT_MENU_REQUESTED', async e => await open(e.pageY, e.pageX))
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|