From d56db5e6c1ae8d70cb38eb8527842c42f9accb22 Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Tue, 10 Jan 2023 19:34:34 +0300 Subject: [PATCH] add delete playlist modal --- src/components/PlaylistView/Header.vue | 28 ++++++---------------- src/components/modal.vue | 18 ++++++++++++++- src/components/modals/ConfirmModal.vue | 32 ++++++++++++++++++++++++++ src/composables/fetch/playlists.ts | 19 ++++++++++++++- src/stores/modal.ts | 8 +++++++ 5 files changed, 82 insertions(+), 23 deletions(-) create mode 100644 src/components/modals/ConfirmModal.vue diff --git a/src/components/PlaylistView/Header.vue b/src/components/PlaylistView/Header.vue index 515252af..ab0af21e 100644 --- a/src/components/PlaylistView/Header.vue +++ b/src/components/PlaylistView/Header.vue @@ -29,7 +29,7 @@ >Last updated {{ info.last_updated }}  |   Edit  | - + @@ -63,6 +63,10 @@ useVisibility(playlistheader, nav.toggleShowPlay); function editPlaylist() { modal.showEditPlaylistModal(info.value); } + +function deletePlaylist() { + modal.showDeletePlaylistModal(parseInt(playlist.info.id)); +} diff --git a/src/composables/fetch/playlists.ts b/src/composables/fetch/playlists.ts index 8c39dfef..1f13ad51 100644 --- a/src/composables/fetch/playlists.ts +++ b/src/composables/fetch/playlists.ts @@ -79,7 +79,10 @@ async function addTrackToPlaylist(playlist: Playlist, track: Track) { return; } - new Notification(track.title + " added to " + playlist.name, NotifType.Success); + new Notification( + track.title + " added to " + playlist.name, + NotifType.Success + ); } async function getPlaylist(pid: string) { @@ -153,6 +156,20 @@ export async function getPlaylistArtists(pid: string): Promise { return []; } +export async function deletePlaylist(pid: string) { + console.log(pid); + const { status } = await useAxios({ + url: paths.api.playlist.base + "/delete", + props: { + pid, + }, + }); + + if (status == 200) { + new Notification("Playlist deleted", NotifType.Success); + } +} + export { createNewPlaylist, getAllPlaylists, diff --git a/src/stores/modal.ts b/src/stores/modal.ts index 9f889353..ef9811a6 100644 --- a/src/stores/modal.ts +++ b/src/stores/modal.ts @@ -5,6 +5,7 @@ enum ModalOptions { newPlaylist, updatePlaylist, welcome, + deletePlaylist, } export default defineStore("newModal", { @@ -33,8 +34,15 @@ export default defineStore("newModal", { showWelcomeModal() { this.showModal(ModalOptions.welcome); }, + showDeletePlaylistModal(pid: number) { + this.props = { + pid: pid, + }; + this.showModal(ModalOptions.deletePlaylist); + }, hideModal() { this.visible = false; + this.setTitle(""); }, setTitle(new_title: string) { this.title = new_title;