2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<div class="modal-wrapper" :class="{ overlay: showingModalName }">
|
2022-08-10 14:56:01 +00:00
|
|
|
<CreatePlaylistForm v-if="showingModalName === 'create-playlist-form'" @close="close"/>
|
|
|
|
<EditPlaylistForm v-else-if="showingModalName === 'edit-playlist-form'" @close="close"/>
|
2022-04-15 17:00:08 +00:00
|
|
|
<CreateSmartPlaylistForm v-if="showingModalName === 'create-smart-playlist-form'" @close="close"/>
|
2022-07-10 15:17:48 +00:00
|
|
|
<EditSmartPlaylistForm v-if="showingModalName === 'edit-smart-playlist-form'" @close="close"/>
|
2022-04-15 17:00:08 +00:00
|
|
|
<AddUserForm v-if="showingModalName === 'add-user-form'" @close="close"/>
|
2022-07-10 15:17:48 +00:00
|
|
|
<EditUserForm v-if="showingModalName === 'edit-user-form'" @close="close"/>
|
|
|
|
<EditSongForm v-if="showingModalName === 'edit-song-form'" @close="close"/>
|
2022-08-10 14:56:01 +00:00
|
|
|
<CreatePlaylistFolderForm v-if="showingModalName === 'create-playlist-folder-form'" @close="close"/>
|
|
|
|
<EditPlaylistFolderForm v-if="showingModalName === 'edit-playlist-folder-form'" @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>
|
2022-07-20 08:00:02 +00:00
|
|
|
import { defineAsyncComponent, ref } from 'vue'
|
|
|
|
import { arrayify, eventBus, provideReadonly } from '@/utils'
|
2022-08-10 14:56:01 +00:00
|
|
|
import { EditSongFormInitialTabKey, PlaylistFolderKey, PlaylistKey, SongsKey, UserKey } from '@/symbols'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
declare type ModalName =
|
2022-08-10 14:56:01 +00:00
|
|
|
| 'create-playlist-form'
|
|
|
|
| 'edit-playlist-form'
|
2022-04-15 14:24:30 +00:00
|
|
|
| 'create-smart-playlist-form'
|
|
|
|
| 'edit-smart-playlist-form'
|
|
|
|
| 'add-user-form'
|
|
|
|
| 'edit-user-form'
|
|
|
|
| 'edit-song-form'
|
2022-08-10 14:56:01 +00:00
|
|
|
| 'create-playlist-folder-form'
|
|
|
|
| 'edit-playlist-folder-form'
|
2022-05-07 08:51:01 +00:00
|
|
|
| 'about-koel'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-08-10 14:56:01 +00:00
|
|
|
const CreatePlaylistForm = defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistForm.vue'))
|
|
|
|
const EditPlaylistForm = defineAsyncComponent(() => import('@/components/playlist/EditPlaylistForm.vue'))
|
|
|
|
const CreateSmartPlaylistForm = defineAsyncComponent(() => import('@/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue'))
|
|
|
|
const EditSmartPlaylistForm = defineAsyncComponent(() => import('@/components/playlist/smart-playlist/EditSmartPlaylistForm.vue'))
|
|
|
|
const AddUserForm = defineAsyncComponent(() => import('@/components/user/AddUserForm.vue'))
|
|
|
|
const EditUserForm = defineAsyncComponent(() => import('@/components/user/EditUserForm.vue'))
|
|
|
|
const EditSongForm = defineAsyncComponent(() => import('@/components/song/EditSongForm.vue'))
|
|
|
|
const CreatePlaylistFolderForm = defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistFolderForm.vue'))
|
|
|
|
const EditPlaylistFolderForm = defineAsyncComponent(() => import('@/components/playlist/EditPlaylistFolderForm.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)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-10 15:17:48 +00:00
|
|
|
const close = () => (showingModalName.value = null)
|
|
|
|
|
|
|
|
const playlistToEdit = ref<Playlist>()
|
|
|
|
const userToEdit = ref<User>()
|
|
|
|
const songsToEdit = ref<Song[]>()
|
2022-08-10 14:56:01 +00:00
|
|
|
const playlistFolderToEdit = ref<PlaylistFolder>()
|
2022-07-10 15:17:48 +00:00
|
|
|
const editSongFormInitialTab = ref<EditSongFormTabName>('details')
|
|
|
|
|
2022-07-20 08:00:02 +00:00
|
|
|
provideReadonly(PlaylistKey, playlistToEdit, false)
|
|
|
|
provideReadonly(UserKey, userToEdit)
|
2022-08-10 14:56:01 +00:00
|
|
|
provideReadonly(PlaylistFolderKey, playlistFolderToEdit, true, (name: string) => playlistFolderToEdit.value!.name = name)
|
2022-07-20 08:00:02 +00:00
|
|
|
provideReadonly(SongsKey, songsToEdit, false)
|
|
|
|
provideReadonly(EditSongFormInitialTabKey, editSongFormInitialTab)
|
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'),
|
2022-08-10 14:56:01 +00:00
|
|
|
'MODAL_SHOW_CREATE_PLAYLIST_FORM': () => (showingModalName.value = 'create-playlist-form'),
|
2022-04-15 17:00:08 +00:00
|
|
|
'MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM': () => (showingModalName.value = 'create-smart-playlist-form'),
|
2022-08-10 14:56:01 +00:00
|
|
|
'MODAL_SHOW_CREATE_PLAYLIST_FOLDER_FORM': () => (showingModalName.value = 'create-playlist-folder-form'),
|
|
|
|
|
|
|
|
'MODAL_SHOW_EDIT_PLAYLIST_FORM': (playlist: Playlist) => {
|
|
|
|
playlistToEdit.value = playlist
|
|
|
|
showingModalName.value = 'edit-playlist-form'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-10 15:17:48 +00:00
|
|
|
'MODAL_SHOW_EDIT_SMART_PLAYLIST_FORM': (playlist: Playlist) => {
|
|
|
|
playlistToEdit.value = playlist
|
2022-04-15 17:00:08 +00:00
|
|
|
showingModalName.value = 'edit-smart-playlist-form'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-10 15:17:48 +00:00
|
|
|
'MODAL_SHOW_EDIT_USER_FORM': (user: User) => {
|
|
|
|
userToEdit.value = user
|
2022-04-15 17:00:08 +00:00
|
|
|
showingModalName.value = 'edit-user-form'
|
|
|
|
},
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-10 15:17:48 +00:00
|
|
|
'MODAL_SHOW_EDIT_SONG_FORM': (songs: Song | Song[], initialTab: EditSongFormTabName = 'details') => {
|
|
|
|
songsToEdit.value = arrayify(songs)
|
|
|
|
editSongFormInitialTab.value = initialTab
|
2022-04-15 17:00:08 +00:00
|
|
|
showingModalName.value = 'edit-song-form'
|
2022-08-10 14:56:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
'MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM': (folder: PlaylistFolder) => {
|
|
|
|
playlistFolderToEdit.value = folder
|
|
|
|
showingModalName.value = 'edit-playlist-folder-form'
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
2022-07-22 16:15:30 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.modal-wrapper {
|
|
|
|
form {
|
|
|
|
position: relative;
|
|
|
|
min-width: 460px;
|
2022-07-29 12:12:55 +00:00
|
|
|
max-width: calc(100% - 24px);
|
2022-07-22 16:15:30 +00:00
|
|
|
background-color: var(--color-bg-primary);
|
|
|
|
border-radius: 4px;
|
|
|
|
|
2022-07-29 12:12:55 +00:00
|
|
|
@media only screen and (max-width: 667px) {
|
|
|
|
min-width: calc(100% - 24px);
|
|
|
|
}
|
|
|
|
|
2022-07-22 16:15:30 +00:00
|
|
|
> header, > main, > footer {
|
|
|
|
padding: 1.2rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
> footer {
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[type=text], [type=number], [type=email], [type=password], [type=url], [type=date], textarea, select {
|
|
|
|
width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
height: 32px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.warning {
|
|
|
|
color: var(--color-red);
|
|
|
|
}
|
|
|
|
|
|
|
|
textarea {
|
|
|
|
min-height: 192px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
background: var(--color-bg-secondary);
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
font-size: 1.8rem;
|
|
|
|
line-height: 2.2rem;
|
|
|
|
margin-bottom: .3rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|