Update:Item edit modal add Save and Save & Close buttons

This commit is contained in:
advplyr 2022-05-08 15:25:33 -05:00
parent 9de4b1069a
commit f94c706fc8

View File

@ -1,8 +1,8 @@
<template>
<div class="w-full h-full relative">
<div id="formWrapper" class="w-full overflow-y-auto">
<widgets-book-details-edit v-if="mediaType == 'book'" ref="itemDetailsEdit" :library-item="libraryItem" @submit="submitForm" />
<widgets-podcast-details-edit v-else ref="itemDetailsEdit" :library-item="libraryItem" @submit="submitForm" />
<widgets-book-details-edit v-if="mediaType == 'book'" ref="itemDetailsEdit" :library-item="libraryItem" @submit="saveAndClose" />
<widgets-podcast-details-edit v-else ref="itemDetailsEdit" :library-item="libraryItem" @submit="saveAndClose" />
</div>
<div class="absolute bottom-0 left-0 w-full py-4 bg-bg" :class="isScrollable ? 'box-shadow-md-up' : 'border-t border-white border-opacity-5'">
@ -19,7 +19,9 @@
<ui-btn v-if="userIsAdminOrUp && !isFile" :loading="rescanning" :disabled="!!libraryScan" color="bg" type="button" class="h-full" small @click.stop.prevent="rescan">Re-Scan</ui-btn>
</ui-tooltip>
<ui-btn @click="submitForm">Submit</ui-btn>
<ui-btn @click="save" class="mx-2">Save</ui-btn>
<ui-btn @click="saveAndClose">Save & Close</ui-btn>
</div>
</div>
</div>
@ -144,19 +146,23 @@ export default {
this.rescanning = false
})
},
submitForm() {
async saveAndClose() {
const wasUpdated = await this.save()
if (wasUpdated !== null) this.$emit('close')
},
async save() {
if (this.isProcessing) {
return
return null
}
if (!this.$refs.itemDetailsEdit) {
return
return null
}
var updatedDetails = this.$refs.itemDetailsEdit.getDetails()
if (!updatedDetails.hasChanges) {
this.$toast.info('No changes were made')
return
return false
}
this.updateDetails(updatedDetails)
return this.updateDetails(updatedDetails)
},
async updateDetails(updatedDetails) {
this.isProcessing = true
@ -168,11 +174,12 @@ export default {
if (updateResult) {
if (updateResult.updated) {
this.$toast.success('Item details updated')
this.$emit('close')
return true
} else {
this.$toast.info('No updates were necessary')
}
}
return false
},
removeItem() {
if (confirm(`Are you sure you want to remove this item?\n\n*Does not delete your files, only removes the item from audiobookshelf`)) {