mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-09 00:45:05 +02:00
Update browser confirm prompts to use confirm prompt modal instead
This commit is contained in:
parent
c7d8021a16
commit
b0045b5b8b
5 changed files with 129 additions and 73 deletions
|
@ -91,24 +91,36 @@ export default {
|
|||
},
|
||||
deleteUserClick(user) {
|
||||
if (this.isDeletingUser) return
|
||||
if (confirm(this.$getString('MessageRemoveUserWarning', [user.username]))) {
|
||||
this.isDeletingUser = true
|
||||
this.$axios
|
||||
.$delete(`/api/users/${user.id}`)
|
||||
.then((data) => {
|
||||
this.isDeletingUser = false
|
||||
if (data.error) {
|
||||
this.$toast.error(data.error)
|
||||
} else {
|
||||
this.$toast.success(this.$strings.ToastUserDeleteSuccess)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to delete user', error)
|
||||
this.$toast.error(this.$strings.ToastUserDeleteFailed)
|
||||
this.isDeletingUser = false
|
||||
})
|
||||
|
||||
const payload = {
|
||||
message: this.$getString('MessageRemoveUserWarning', [user.username]),
|
||||
callback: (confirmed) => {
|
||||
if (confirmed) {
|
||||
this.deleteUser(user)
|
||||
}
|
||||
},
|
||||
type: 'yesNo'
|
||||
}
|
||||
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||
},
|
||||
deleteUser(user) {
|
||||
this.isDeletingUser = true
|
||||
this.$axios
|
||||
.$delete(`/api/users/${user.id}`)
|
||||
.then((data) => {
|
||||
if (data.error) {
|
||||
this.$toast.error(data.error)
|
||||
} else {
|
||||
this.$toast.success(this.$strings.ToastUserDeleteSuccess)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to delete user', error)
|
||||
this.$toast.error(this.$strings.ToastUserDeleteFailed)
|
||||
})
|
||||
.finally(() => {
|
||||
this.isDeletingUser = false
|
||||
})
|
||||
},
|
||||
editUser(user) {
|
||||
this.$emit('edit', user)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue