From 7f8de7915cb277ce3c591c3da22a9bdcda3f3497 Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 16 Mar 2025 18:02:16 -0500 Subject: [PATCH] Update remove playlist translations and use our custom confirm modal --- .../components/modals/playlists/EditModal.vue | 39 ++++++++++++------- client/pages/playlist/_id.vue | 38 +++++++++++------- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/client/components/modals/playlists/EditModal.vue b/client/components/modals/playlists/EditModal.vue index cd2deffe..78ca6002 100644 --- a/client/components/modals/playlists/EditModal.vue +++ b/client/components/modals/playlists/EditModal.vue @@ -74,21 +74,32 @@ export default { this.newPlaylistDescription = this.playlist.description || '' }, removeClick() { - if (confirm(this.$getString('MessageConfirmRemovePlaylist', [this.playlistName]))) { - this.processing = true - this.$axios - .$delete(`/api/playlists/${this.playlist.id}`) - .then(() => { - this.processing = false - this.show = false - this.$toast.success(this.$strings.ToastPlaylistRemoveSuccess) - }) - .catch((error) => { - console.error('Failed to remove playlist', error) - this.processing = false - this.$toast.error(this.$strings.ToastRemoveFailed) - }) + const payload = { + message: this.$getString('MessageConfirmRemovePlaylist', [this.playlistName]), + callback: (confirmed) => { + if (confirmed) { + this.removePlaylist() + } + }, + type: 'yesNo' } + this.$store.commit('globals/setConfirmPrompt', payload) + }, + removePlaylist() { + this.processing = true + this.$axios + .$delete(`/api/playlists/${this.playlist.id}`) + .then(() => { + this.show = false + this.$toast.success(this.$strings.ToastPlaylistRemoveSuccess) + }) + .catch((error) => { + console.error('Failed to remove playlist', error) + this.$toast.error(this.$strings.ToastRemoveFailed) + }) + .finally(() => { + this.processing = false + }) }, submitForm() { if (this.newPlaylistName === this.playlistName && this.newPlaylistDescription === this.playlist.description) { diff --git a/client/pages/playlist/_id.vue b/client/pages/playlist/_id.vue index 5cd31885..09755324 100644 --- a/client/pages/playlist/_id.vue +++ b/client/pages/playlist/_id.vue @@ -109,21 +109,31 @@ export default { this.$store.commit('globals/setEditPlaylist', this.playlist) }, removeClick() { - if (confirm(`Are you sure you want to remove playlist "${this.playlistName}"?`)) { - this.processingRemove = true - var playlistName = this.playlistName - this.$axios - .$delete(`/api/playlists/${this.playlist.id}`) - .then(() => { - this.processingRemove = false - this.$toast.success(`Playlist "${playlistName}" Removed`) - }) - .catch((error) => { - console.error('Failed to remove playlist', error) - this.processingRemove = false - this.$toast.error(`Failed to remove playlist`) - }) + const payload = { + message: this.$getString('MessageConfirmRemovePlaylist', [this.playlistName]), + callback: (confirmed) => { + if (confirmed) { + this.removePlaylist() + } + }, + type: 'yesNo' } + this.$store.commit('globals/setConfirmPrompt', payload) + }, + removePlaylist() { + this.processingRemove = true + this.$axios + .$delete(`/api/playlists/${this.playlist.id}`) + .then(() => { + this.$toast.success(this.$strings.ToastPlaylistRemoveSuccess) + }) + .catch((error) => { + console.error('Failed to remove playlist', error) + this.$toast.error(this.$strings.ToastRemoveFailed) + }) + .finally(() => { + this.processingRemove = false + }) }, clickPlay() { const queueItems = []