2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-05-08 18:18:27 +00:00
|
|
|
<ContextMenuBase ref="base" extra-class="playlist-item-menu">
|
2022-08-10 14:56:01 +00:00
|
|
|
<li :data-testid="`playlist-context-menu-edit-${playlist.id}`" @click="editPlaylist">
|
|
|
|
{{ playlist.is_smart ? 'Edit' : 'Rename' }}
|
|
|
|
</li>
|
2022-05-08 18:18:27 +00:00
|
|
|
<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>
|
2022-04-20 10:35:36 +00:00
|
|
|
import { Ref, toRef } 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()
|
2022-04-20 10:35:36 +00:00
|
|
|
const playlist = toRef(context, 'playlist') as Ref<Playlist>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-08-10 14:56:01 +00:00
|
|
|
const editPlaylist = () => trigger(() => eventBus.emit(
|
|
|
|
playlist.value.is_smart ? 'MODAL_SHOW_EDIT_SMART_PLAYLIST_FORM' : 'MODAL_SHOW_EDIT_PLAYLIST_FORM',
|
|
|
|
playlist.value
|
|
|
|
))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const deletePlaylist = () => trigger(() => eventBus.emit('PLAYLIST_DELETE', playlist.value))
|
2022-04-20 10:35:36 +00:00
|
|
|
|
|
|
|
defineExpose({ open })
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|