Update remove playlist translations and use our custom confirm modal

This commit is contained in:
advplyr 2025-03-16 18:02:16 -05:00
parent 394bf8cb70
commit 7f8de7915c
2 changed files with 49 additions and 28 deletions

View File

@ -74,21 +74,32 @@ export default {
this.newPlaylistDescription = this.playlist.description || '' this.newPlaylistDescription = this.playlist.description || ''
}, },
removeClick() { removeClick() {
if (confirm(this.$getString('MessageConfirmRemovePlaylist', [this.playlistName]))) { 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.processing = true
this.$axios this.$axios
.$delete(`/api/playlists/${this.playlist.id}`) .$delete(`/api/playlists/${this.playlist.id}`)
.then(() => { .then(() => {
this.processing = false
this.show = false this.show = false
this.$toast.success(this.$strings.ToastPlaylistRemoveSuccess) this.$toast.success(this.$strings.ToastPlaylistRemoveSuccess)
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to remove playlist', error) console.error('Failed to remove playlist', error)
this.processing = false
this.$toast.error(this.$strings.ToastRemoveFailed) this.$toast.error(this.$strings.ToastRemoveFailed)
}) })
} .finally(() => {
this.processing = false
})
}, },
submitForm() { submitForm() {
if (this.newPlaylistName === this.playlistName && this.newPlaylistDescription === this.playlist.description) { if (this.newPlaylistName === this.playlistName && this.newPlaylistDescription === this.playlist.description) {

View File

@ -109,21 +109,31 @@ export default {
this.$store.commit('globals/setEditPlaylist', this.playlist) this.$store.commit('globals/setEditPlaylist', this.playlist)
}, },
removeClick() { removeClick() {
if (confirm(`Are you sure you want to remove playlist "${this.playlistName}"?`)) { 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.processingRemove = true
var playlistName = this.playlistName
this.$axios this.$axios
.$delete(`/api/playlists/${this.playlist.id}`) .$delete(`/api/playlists/${this.playlist.id}`)
.then(() => { .then(() => {
this.processingRemove = false this.$toast.success(this.$strings.ToastPlaylistRemoveSuccess)
this.$toast.success(`Playlist "${playlistName}" Removed`)
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to remove playlist', error) console.error('Failed to remove playlist', error)
this.processingRemove = false this.$toast.error(this.$strings.ToastRemoveFailed)
this.$toast.error(`Failed to remove playlist`) })
.finally(() => {
this.processingRemove = false
}) })
}
}, },
clickPlay() { clickPlay() {
const queueItems = [] const queueItems = []