mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Fix:Edit author modal resetting form inputs on image change #2965
This commit is contained in:
		
							parent
							
								
									1576164218
								
							
						
					
					
						commit
						ba6a88a5bf
					
				@ -9,7 +9,7 @@
 | 
				
			|||||||
      <div class="flex">
 | 
					      <div class="flex">
 | 
				
			||||||
        <div class="w-40 p-2">
 | 
					        <div class="w-40 p-2">
 | 
				
			||||||
          <div class="w-full h-45 relative">
 | 
					          <div class="w-full h-45 relative">
 | 
				
			||||||
            <covers-author-image :author="author" />
 | 
					            <covers-author-image :author="authorCopy" />
 | 
				
			||||||
            <div v-if="userCanDelete && !processing && author.imagePath" class="absolute top-0 left-0 w-full h-full opacity-0 hover:opacity-100">
 | 
					            <div v-if="userCanDelete && !processing && author.imagePath" class="absolute top-0 left-0 w-full h-full opacity-0 hover:opacity-100">
 | 
				
			||||||
              <span class="absolute top-2 right-2 material-icons text-error transform hover:scale-125 transition-transform cursor-pointer text-lg" @click="removeCover">delete</span>
 | 
					              <span class="absolute top-2 right-2 material-icons text-error transform hover:scale-125 transition-transform cursor-pointer text-lg" @click="removeCover">delete</span>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
@ -30,9 +30,6 @@
 | 
				
			|||||||
                <ui-text-input-with-label v-model="authorCopy.asin" :disabled="processing" label="ASIN" />
 | 
					                <ui-text-input-with-label v-model="authorCopy.asin" :disabled="processing" label="ASIN" />
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <!-- <div class="p-2">
 | 
					 | 
				
			||||||
              <ui-text-input-with-label v-model="authorCopy.imagePath" :disabled="processing" :label="$strings.LabelPhotoPathURL" />
 | 
					 | 
				
			||||||
            </div> -->
 | 
					 | 
				
			||||||
            <div class="p-2">
 | 
					            <div class="p-2">
 | 
				
			||||||
              <ui-textarea-with-label v-model="authorCopy.description" :disabled="processing" :label="$strings.LabelDescription" :rows="8" />
 | 
					              <ui-textarea-with-label v-model="authorCopy.description" :disabled="processing" :label="$strings.LabelDescription" :rows="8" />
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
@ -106,9 +103,9 @@ export default {
 | 
				
			|||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    init() {
 | 
					    init() {
 | 
				
			||||||
      this.imageUrl = ''
 | 
					      this.imageUrl = ''
 | 
				
			||||||
      this.authorCopy.name = this.author.name
 | 
					      this.authorCopy = {
 | 
				
			||||||
      this.authorCopy.asin = this.author.asin
 | 
					        ...this.author
 | 
				
			||||||
      this.authorCopy.description = this.author.description
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    removeClick() {
 | 
					    removeClick() {
 | 
				
			||||||
      const payload = {
 | 
					      const payload = {
 | 
				
			||||||
@ -171,7 +168,9 @@ export default {
 | 
				
			|||||||
        .$delete(`/api/authors/${this.authorId}/image`)
 | 
					        .$delete(`/api/authors/${this.authorId}/image`)
 | 
				
			||||||
        .then((data) => {
 | 
					        .then((data) => {
 | 
				
			||||||
          this.$toast.success(this.$strings.ToastAuthorImageRemoveSuccess)
 | 
					          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) => {
 | 
					        .catch((error) => {
 | 
				
			||||||
          console.error('Failed', error)
 | 
					          console.error('Failed', error)
 | 
				
			||||||
@ -196,7 +195,9 @@ export default {
 | 
				
			|||||||
        .then((data) => {
 | 
					        .then((data) => {
 | 
				
			||||||
          this.imageUrl = ''
 | 
					          this.imageUrl = ''
 | 
				
			||||||
          this.$toast.success('Author image updated')
 | 
					          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) => {
 | 
					        .catch((error) => {
 | 
				
			||||||
          console.error('Failed', error)
 | 
					          console.error('Failed', error)
 | 
				
			||||||
@ -231,8 +232,11 @@ export default {
 | 
				
			|||||||
      } else if (response.updated) {
 | 
					      } else if (response.updated) {
 | 
				
			||||||
        if (response.author.imagePath) {
 | 
					        if (response.author.imagePath) {
 | 
				
			||||||
          this.$toast.success(this.$strings.ToastAuthorUpdateSuccess)
 | 
					          this.$toast.success(this.$strings.ToastAuthorUpdateSuccess)
 | 
				
			||||||
          this.$store.commit('globals/showEditAuthorModal', response.author)
 | 
					 | 
				
			||||||
        } else this.$toast.success(this.$strings.ToastAuthorUpdateSuccessNoImageFound)
 | 
					        } else this.$toast.success(this.$strings.ToastAuthorUpdateSuccessNoImageFound)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.authorCopy = {
 | 
				
			||||||
 | 
					          ...response.author
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        this.$toast.info('No updates were made for Author')
 | 
					        this.$toast.info('No updates were made for Author')
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -79,9 +79,6 @@ export default {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    authorUpdated(author) {
 | 
					    authorUpdated(author) {
 | 
				
			||||||
      if (this.selectedAuthor && this.selectedAuthor.id === author.id) {
 | 
					 | 
				
			||||||
        this.$store.commit('globals/setSelectedAuthor', author)
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      this.authors = this.authors.map((au) => {
 | 
					      this.authors = this.authors.map((au) => {
 | 
				
			||||||
        if (au.id === author.id) {
 | 
					        if (au.id === author.id) {
 | 
				
			||||||
          return author
 | 
					          return author
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user