mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-03-01 00:15:54 +01:00
Update browser confirm prompts to use confirm prompt modal instead
This commit is contained in:
parent
c7d8021a16
commit
b0045b5b8b
@ -18,7 +18,7 @@
|
|||||||
<ui-textarea-with-label v-model="newCollectionDescription" :label="$strings.LabelDescription" />
|
<ui-textarea-with-label v-model="newCollectionDescription" :label="$strings.LabelDescription" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="absolute bottom-0 left-0 right-0 w-full py-2 px-4 flex">
|
<div class="absolute bottom-0 left-0 right-0 w-full py-4 px-4 flex">
|
||||||
<ui-btn v-if="userCanDelete" small color="error" type="button" @click.stop="removeClick">{{ $strings.ButtonRemove }}</ui-btn>
|
<ui-btn v-if="userCanDelete" small color="error" type="button" @click.stop="removeClick">{{ $strings.ButtonRemove }}</ui-btn>
|
||||||
<div class="flex-grow" />
|
<div class="flex-grow" />
|
||||||
<ui-btn color="success" type="submit">{{ $strings.ButtonSave }}</ui-btn>
|
<ui-btn color="success" type="submit">{{ $strings.ButtonSave }}</ui-btn>
|
||||||
@ -94,21 +94,32 @@ export default {
|
|||||||
this.newCollectionDescription = this.collection.description || ''
|
this.newCollectionDescription = this.collection.description || ''
|
||||||
},
|
},
|
||||||
removeClick() {
|
removeClick() {
|
||||||
if (confirm(this.$getString('MessageConfirmRemoveCollection', [this.collectionName]))) {
|
const payload = {
|
||||||
this.processing = true
|
message: this.$getString('MessageConfirmRemoveCollection', [this.collectionName]),
|
||||||
this.$axios
|
callback: (confirmed) => {
|
||||||
.$delete(`/api/collections/${this.collection.id}`)
|
if (confirmed) {
|
||||||
.then(() => {
|
this.deleteCollection()
|
||||||
this.processing = false
|
}
|
||||||
this.show = false
|
},
|
||||||
this.$toast.success(this.$strings.ToastCollectionRemoveSuccess)
|
type: 'yesNo'
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Failed to remove collection', error)
|
|
||||||
this.processing = false
|
|
||||||
this.$toast.error(this.$strings.ToastRemoveFailed)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||||
|
},
|
||||||
|
deleteCollection() {
|
||||||
|
this.processing = true
|
||||||
|
this.$axios
|
||||||
|
.$delete(`/api/collections/${this.collection.id}`)
|
||||||
|
.then(() => {
|
||||||
|
this.show = false
|
||||||
|
this.$toast.success(this.$strings.ToastCollectionRemoveSuccess)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Failed to remove collection', error)
|
||||||
|
this.$toast.error(this.$strings.ToastRemoveFailed)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.processing = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
submitForm() {
|
submitForm() {
|
||||||
if (this.newCollectionName === this.collectionName && this.newCollectionDescription === this.collection.description) {
|
if (this.newCollectionName === this.collectionName && this.newCollectionDescription === this.collection.description) {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<button aria-label="Download Backup" class="inline-flex material-symbols text-xl mx-1 mt-1 text-white/70 hover:text-white/100" @click.stop="downloadBackup(backup)">download</button>
|
<button aria-label="Download Backup" class="inline-flex material-symbols text-xl mx-1 mt-1 text-white/70 hover:text-white/100" @click.stop="downloadBackup(backup)">download</button>
|
||||||
|
|
||||||
<button aria-label="Delete Backup" class="inline-flex material-symbols text-xl mx-1 text-white/70 hover:text-error" @click="deleteBackupClick(backup)">delete</button>
|
<button aria-label="Delete Backup" class="inline-flex material-symbols text-xl mx-1 text-white/70 hover:text-error" @click.stop="deleteBackupClick(backup)">delete</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -107,21 +107,32 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteBackupClick(backup) {
|
deleteBackupClick(backup) {
|
||||||
if (confirm(this.$getString('MessageConfirmDeleteBackup', [this.$formatDatetime(backup.createdAt, this.dateFormat, this.timeFormat)]))) {
|
const payload = {
|
||||||
this.processing = true
|
message: this.$getString('MessageConfirmDeleteBackup', [this.$formatDatetime(backup.createdAt, this.dateFormat, this.timeFormat)]),
|
||||||
this.$axios
|
callback: (confirmed) => {
|
||||||
.$delete(`/api/backups/${backup.id}`)
|
if (confirmed) {
|
||||||
.then((data) => {
|
this.deleteBackup(backup)
|
||||||
this.setBackups(data.backups || [])
|
}
|
||||||
this.$toast.success(this.$strings.ToastBackupDeleteSuccess)
|
},
|
||||||
this.processing = false
|
type: 'yesNo'
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error)
|
|
||||||
this.$toast.error(this.$strings.ToastBackupDeleteFailed)
|
|
||||||
this.processing = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||||
|
},
|
||||||
|
deleteBackup(backup) {
|
||||||
|
this.processing = true
|
||||||
|
this.$axios
|
||||||
|
.$delete(`/api/backups/${backup.id}`)
|
||||||
|
.then((data) => {
|
||||||
|
this.setBackups(data.backups || [])
|
||||||
|
this.$toast.success(this.$strings.ToastBackupDeleteSuccess)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
this.$toast.error(this.$strings.ToastBackupDeleteFailed)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.processing = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
applyBackup(backup) {
|
applyBackup(backup) {
|
||||||
this.selectedBackup = backup
|
this.selectedBackup = backup
|
||||||
|
@ -91,24 +91,36 @@ export default {
|
|||||||
},
|
},
|
||||||
deleteUserClick(user) {
|
deleteUserClick(user) {
|
||||||
if (this.isDeletingUser) return
|
if (this.isDeletingUser) return
|
||||||
if (confirm(this.$getString('MessageRemoveUserWarning', [user.username]))) {
|
|
||||||
this.isDeletingUser = true
|
const payload = {
|
||||||
this.$axios
|
message: this.$getString('MessageRemoveUserWarning', [user.username]),
|
||||||
.$delete(`/api/users/${user.id}`)
|
callback: (confirmed) => {
|
||||||
.then((data) => {
|
if (confirmed) {
|
||||||
this.isDeletingUser = false
|
this.deleteUser(user)
|
||||||
if (data.error) {
|
}
|
||||||
this.$toast.error(data.error)
|
},
|
||||||
} else {
|
type: 'yesNo'
|
||||||
this.$toast.success(this.$strings.ToastUserDeleteSuccess)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Failed to delete user', error)
|
|
||||||
this.$toast.error(this.$strings.ToastUserDeleteFailed)
|
|
||||||
this.isDeletingUser = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
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) {
|
editUser(user) {
|
||||||
this.$emit('edit', user)
|
this.$emit('edit', user)
|
||||||
|
@ -176,21 +176,31 @@ export default {
|
|||||||
this.$store.commit('globals/setEditCollection', this.collection)
|
this.$store.commit('globals/setEditCollection', this.collection)
|
||||||
},
|
},
|
||||||
removeClick() {
|
removeClick() {
|
||||||
if (confirm(this.$getString('MessageConfirmRemoveCollection', [this.collectionName]))) {
|
const payload = {
|
||||||
this.processing = true
|
message: this.$getString('MessageConfirmRemoveCollection', [this.collectionName]),
|
||||||
this.$axios
|
callback: (confirmed) => {
|
||||||
.$delete(`/api/collections/${this.collection.id}`)
|
if (confirmed) {
|
||||||
.then(() => {
|
this.deleteCollection()
|
||||||
this.$toast.success(this.$strings.ToastCollectionRemoveSuccess)
|
}
|
||||||
})
|
},
|
||||||
.catch((error) => {
|
type: 'yesNo'
|
||||||
console.error('Failed to remove collection', error)
|
|
||||||
this.$toast.error(this.$strings.ToastCollectionRemoveFailed)
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this.processing = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||||
|
},
|
||||||
|
deleteCollection() {
|
||||||
|
this.processing = true
|
||||||
|
this.$axios
|
||||||
|
.$delete(`/api/collections/${this.collection.id}`)
|
||||||
|
.then(() => {
|
||||||
|
this.$toast.success(this.$strings.ToastCollectionRemoveSuccess)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Failed to remove collection', error)
|
||||||
|
this.$toast.error(this.$strings.ToastCollectionRemoveFailed)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.processing = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
clickPlay() {
|
clickPlay() {
|
||||||
const queueItems = []
|
const queueItems = []
|
||||||
|
@ -599,19 +599,31 @@ export default {
|
|||||||
},
|
},
|
||||||
clearProgressClick() {
|
clearProgressClick() {
|
||||||
if (!this.userMediaProgress) return
|
if (!this.userMediaProgress) return
|
||||||
if (confirm(this.$strings.MessageConfirmResetProgress)) {
|
|
||||||
this.resettingProgress = true
|
const payload = {
|
||||||
this.$axios
|
message: this.$strings.MessageConfirmResetProgress,
|
||||||
.$delete(`/api/me/progress/${this.userMediaProgress.id}`)
|
callback: (confirmed) => {
|
||||||
.then(() => {
|
if (confirmed) {
|
||||||
console.log('Progress reset complete')
|
this.clearProgress()
|
||||||
this.resettingProgress = false
|
}
|
||||||
})
|
},
|
||||||
.catch((error) => {
|
type: 'yesNo'
|
||||||
console.error('Progress reset failed', error)
|
|
||||||
this.resettingProgress = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||||
|
},
|
||||||
|
clearProgress() {
|
||||||
|
this.resettingProgress = true
|
||||||
|
this.$axios
|
||||||
|
.$delete(`/api/me/progress/${this.userMediaProgress.id}`)
|
||||||
|
.then(() => {
|
||||||
|
console.log('Progress reset complete')
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Progress reset failed', error)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.resettingProgress = false
|
||||||
|
})
|
||||||
},
|
},
|
||||||
clickRSSFeed() {
|
clickRSSFeed() {
|
||||||
this.$store.commit('globals/setRSSFeedOpenCloseModal', {
|
this.$store.commit('globals/setRSSFeedOpenCloseModal', {
|
||||||
|
Loading…
Reference in New Issue
Block a user