From ba6a88a5bfe316d2e66cc60da66eae453cedd5cf Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 27 May 2024 16:04:36 -0500 Subject: [PATCH] Fix:Edit author modal resetting form inputs on image change #2965 --- .../components/modals/authors/EditModal.vue | 24 +++++++++++-------- .../pages/library/_library/authors/index.vue | 3 --- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client/components/modals/authors/EditModal.vue b/client/components/modals/authors/EditModal.vue index 09ca7806e0..a31cfd8723 100644 --- a/client/components/modals/authors/EditModal.vue +++ b/client/components/modals/authors/EditModal.vue @@ -9,7 +9,7 @@
- +
delete
@@ -30,9 +30,6 @@
-
@@ -106,9 +103,9 @@ export default { methods: { init() { this.imageUrl = '' - this.authorCopy.name = this.author.name - this.authorCopy.asin = this.author.asin - this.authorCopy.description = this.author.description + this.authorCopy = { + ...this.author + } }, removeClick() { const payload = { @@ -171,7 +168,9 @@ export default { .$delete(`/api/authors/${this.authorId}/image`) .then((data) => { this.$toast.success(this.$strings.ToastAuthorImageRemoveSuccess) - this.$store.commit('globals/showEditAuthorModal', data.author) + + this.authorCopy.updatedAt = data.author.updatedAt + this.authorCopy.imagePath = data.author.imagePath }) .catch((error) => { console.error('Failed', error) @@ -196,7 +195,9 @@ export default { .then((data) => { this.imageUrl = '' this.$toast.success('Author image updated') - this.$store.commit('globals/showEditAuthorModal', data.author) + + this.authorCopy.updatedAt = data.author.updatedAt + this.authorCopy.imagePath = data.author.imagePath }) .catch((error) => { console.error('Failed', error) @@ -231,8 +232,11 @@ export default { } else if (response.updated) { if (response.author.imagePath) { this.$toast.success(this.$strings.ToastAuthorUpdateSuccess) - this.$store.commit('globals/showEditAuthorModal', response.author) } else this.$toast.success(this.$strings.ToastAuthorUpdateSuccessNoImageFound) + + this.authorCopy = { + ...response.author + } } else { this.$toast.info('No updates were made for Author') } diff --git a/client/pages/library/_library/authors/index.vue b/client/pages/library/_library/authors/index.vue index 27ba3ffe1b..9adcce5b04 100644 --- a/client/pages/library/_library/authors/index.vue +++ b/client/pages/library/_library/authors/index.vue @@ -79,9 +79,6 @@ export default { } }, authorUpdated(author) { - if (this.selectedAuthor && this.selectedAuthor.id === author.id) { - this.$store.commit('globals/setSelectedAuthor', author) - } this.authors = this.authors.map((au) => { if (au.id === author.id) { return author