2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<div class="modal-wrapper" :class="{ overlay: showingModalName }">
|
2022-04-15 17:00:08 +00:00
|
|
|
<CreateSmartPlaylistForm v-if="showingModalName === 'create-smart-playlist-form'" @close="close"/>
|
|
|
|
<EditSmartPlaylistForm
|
2022-04-15 14:24:30 +00:00
|
|
|
v-if="showingModalName === 'edit-smart-playlist-form'"
|
|
|
|
:playlist="boundData.playlist"
|
2022-04-24 08:29:14 +00:00
|
|
|
@close="close"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
2022-04-15 17:00:08 +00:00
|
|
|
<AddUserForm v-if="showingModalName === 'add-user-form'" @close="close"/>
|
|
|
|
<EditUserForm v-if="showingModalName === 'edit-user-form'" :user="boundData.user" @close="close"/>
|
|
|
|
<EditSongForm
|
2022-04-24 08:29:14 +00:00
|
|
|
v-if="showingModalName === 'edit-song-form'"
|
2022-04-15 14:24:30 +00:00
|
|
|
:initialTab="boundData.initialTab"
|
2022-04-24 08:29:14 +00:00
|
|
|
:songs="boundData.songs"
|
2022-04-15 14:24:30 +00:00
|
|
|
@close="close"
|
|
|
|
/>
|
2022-05-07 08:51:01 +00:00
|
|
|
<AboutKoel v-if="showingModalName === 'about-koel'" @close="close"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineAsyncComponent, ref } from 'vue'
|
2022-04-25 16:13:18 +00:00
|
|
|
import { eventBus, arrayify } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
interface ModalWrapperBoundData {
|
|
|
|
playlist?: Playlist
|
|
|
|
user?: User
|
|
|
|
songs?: Song[]
|
|
|
|
initialTab?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
declare type ModalName =
|
|
|
|
| 'create-smart-playlist-form'
|
|
|
|
| 'edit-smart-playlist-form'
|
|
|
|
| 'add-user-form'
|
|
|
|
| 'edit-user-form'
|
|
|
|
| 'edit-song-form'
|
2022-05-07 08:51:01 +00:00
|
|
|
| 'about-koel'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-20 12:38:38 +00:00
|
|
|
const CreateSmartPlaylistForm = defineAsyncComponent(() => import('@/components/playlist/smart-playlist/SmartPlaylistCreateForm.vue'))
|
|
|
|
const EditSmartPlaylistForm = defineAsyncComponent(() => import('@/components/playlist/smart-playlist/SmartPlaylistEditForm.vue'))
|
2022-04-23 21:36:19 +00:00
|
|
|
const AddUserForm = defineAsyncComponent(() => import('@/components/user/UserAddForm.vue'))
|
2022-04-23 21:46:25 +00:00
|
|
|
const EditUserForm = defineAsyncComponent(() => import('@/components/user/UserEditForm.vue'))
|
2022-04-21 09:38:24 +00:00
|
|
|
const EditSongForm = defineAsyncComponent(() => import('@/components/song/SongEditForm.vue'))
|
2022-04-24 08:29:14 +00:00
|
|
|
const AboutKoel = defineAsyncComponent(() => import('@/components/meta/AboutKoelModal.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const showingModalName = ref<ModalName | null>(null)
|
|
|
|
const boundData = ref<ModalWrapperBoundData>({})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const close = () => {
|
|
|
|
showingModalName.value = null
|
|
|
|
boundData.value = {}
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
eventBus.on({
|
2022-05-07 08:51:01 +00:00
|
|
|
'MODAL_SHOW_ABOUT_KOEL': () => (showingModalName.value = 'about-koel'),
|
2022-04-15 17:00:08 +00:00
|
|
|
'MODAL_SHOW_ADD_USER_FORM': () => (showingModalName.value = 'add-user-form'),
|
|
|
|
'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM': () => (showingModalName.value = 'create-smart-playlist-form'),
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-24 08:29:14 +00:00
|
|
|
MODAL_SHOW_EDIT_SMART_PLAYLIST_FORM (playlist: Playlist) {
|
2022-04-15 17:00:08 +00:00
|
|
|
boundData.value.playlist = playlist
|
|
|
|
showingModalName.value = 'edit-smart-playlist-form'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-24 08:29:14 +00:00
|
|
|
MODAL_SHOW_EDIT_USER_FORM (user: User) {
|
2022-04-15 17:00:08 +00:00
|
|
|
boundData.value.user = user
|
|
|
|
showingModalName.value = 'edit-user-form'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-25 16:13:18 +00:00
|
|
|
MODAL_SHOW_EDIT_SONG_FORM (songs: Song | Song[], initialTab = 'details') {
|
|
|
|
boundData.value.songs = arrayify(songs)
|
2022-04-15 17:00:08 +00:00
|
|
|
boundData.value.initialTab = initialTab
|
|
|
|
showingModalName.value = 'edit-song-form'
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|