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'"
|
|
|
|
@close="close"
|
|
|
|
:playlist="boundData.playlist"
|
|
|
|
/>
|
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-15 14:24:30 +00:00
|
|
|
:songs="boundData.songs"
|
|
|
|
:initialTab="boundData.initialTab"
|
|
|
|
@close="close"
|
|
|
|
v-if="showingModalName === 'edit-song-form'"
|
|
|
|
/>
|
2022-04-15 17:00:08 +00:00
|
|
|
<AboutDialog v-if="showingModalName === 'about-dialog'" @close="close"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-15 14:24:30 +00:00
|
|
|
import { eventBus } from '@/utils'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { defineAsyncComponent, ref } from 'vue'
|
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'
|
|
|
|
| 'about-dialog'
|
|
|
|
|
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-15 17:00:08 +00:00
|
|
|
const AddUserForm = defineAsyncComponent(() => import('@/components/user/add-form.vue'))
|
|
|
|
const EditUserForm = defineAsyncComponent(() => import('@/components/user/edit-form.vue'))
|
2022-04-21 09:38:24 +00:00
|
|
|
const EditSongForm = defineAsyncComponent(() => import('@/components/song/SongEditForm.vue'))
|
2022-04-15 17:00:08 +00:00
|
|
|
const AboutDialog = defineAsyncComponent(() => import('@/components/meta/about-dialog.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({
|
|
|
|
'MODAL_SHOW_ABOUT_DIALOG': () => (showingModalName.value = 'about-dialog'),
|
|
|
|
'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-15 17:00:08 +00:00
|
|
|
'MODAL_SHOW_EDIT_SMART_PLAYLIST_FORM': (playlist: Playlist) => {
|
|
|
|
boundData.value.playlist = playlist
|
|
|
|
showingModalName.value = 'edit-smart-playlist-form'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
'MODAL_SHOW_EDIT_USER_FORM': (user: User) => {
|
|
|
|
boundData.value.user = user
|
|
|
|
showingModalName.value = 'edit-user-form'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
'MODAL_SHOW_EDIT_SONG_FORM': (songs: Song[], initialTab: string = 'details'): void => {
|
|
|
|
boundData.value.songs = songs
|
|
|
|
boundData.value.initialTab = initialTab
|
|
|
|
showingModalName.value = 'edit-song-form'
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|