koel/resources/assets/js/components/playlist/item-context-menu.vue

30 lines
897 B
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
2022-04-15 17:00:08 +00:00
<BaseContextMenu extra-class="playlist-item-menu" ref="base">
2022-04-15 14:24:30 +00:00
<li @click="editPlaylist" :data-testid="`playlist-context-menu-edit-${playlist.id}`">Edit</li>
<li @click="deletePlaylist" :data-testid="`playlist-context-menu-delete-${playlist.id}`">Delete</li>
2022-04-15 17:00:08 +00:00
</BaseContextMenu>
2022-04-15 14:24:30 +00:00
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
import { toRefs } 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-04-15 17:00:08 +00:00
const { base, BaseContextMenu, open, close } = useContextMenu()
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const props = defineProps<{ playlist: Playlist }>()
const { playlist } = toRefs(props)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const emit = defineEmits(['edit'])
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const editPlaylist = () => {
playlist.value.is_smart ? eventBus.emit('MODAL_SHOW_EDIT_SMART_PLAYLIST_FORM', playlist.value) : emit('edit')
close()
}
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const deletePlaylist = () => {
eventBus.emit('PLAYLIST_DELETE', playlist.value)
close()
}
2022-04-15 14:24:30 +00:00
</script>