Update: author toasts, title and name required toasts

This commit is contained in:
Nicholas Wallace 2024-08-28 21:52:14 -07:00
parent 9f525309d9
commit bc2515f993
6 changed files with 23 additions and 15 deletions

View file

@ -116,12 +116,12 @@ export default {
this.$axios this.$axios
.$delete(`/api/authors/${this.authorId}`) .$delete(`/api/authors/${this.authorId}`)
.then(() => { .then(() => {
this.$toast.success('Author removed') this.$toast.success(this.$strings.ToastAuthorRemoveSuccess)
this.show = false this.show = false
}) })
.catch((error) => { .catch((error) => {
console.error('Failed to remove author', error) console.error('Failed to remove author', error)
this.$toast.error('Failed to remove author') this.$toast.error(this.$strings.ToastAuthorRemoveFailed)
}) })
.finally(() => { .finally(() => {
this.processing = false this.processing = false
@ -182,7 +182,7 @@ export default {
}, },
submitUploadCover() { submitUploadCover() {
if (!this.imageUrl?.startsWith('http:') && !this.imageUrl?.startsWith('https:')) { if (!this.imageUrl?.startsWith('http:') && !this.imageUrl?.startsWith('https:')) {
this.$toast.error('Invalid image url') this.$toast.error(this.$strings.ToastInvalidImageUrl)
return return
} }
@ -194,14 +194,14 @@ export default {
.$post(`/api/authors/${this.authorId}/image`, updatePayload) .$post(`/api/authors/${this.authorId}/image`, updatePayload)
.then((data) => { .then((data) => {
this.imageUrl = '' this.imageUrl = ''
this.$toast.success('Author image updated') this.$toast.success(this.$strings.ToastAuthorUpdateSuccess)
this.authorCopy.updatedAt = data.author.updatedAt this.authorCopy.updatedAt = data.author.updatedAt
this.authorCopy.imagePath = data.author.imagePath this.authorCopy.imagePath = data.author.imagePath
}) })
.catch((error) => { .catch((error) => {
console.error('Failed', error) console.error('Failed', error)
this.$toast.error(error.response.data || 'Failed to remove author image') this.$toast.error(error.response.data || this.$strings.ToastAuthorImageRemoveFailed)
}) })
.finally(() => { .finally(() => {
this.processing = false this.processing = false
@ -209,7 +209,7 @@ export default {
}, },
async searchAuthor() { async searchAuthor() {
if (!this.authorCopy.name && !this.authorCopy.asin) { if (!this.authorCopy.name && !this.authorCopy.asin) {
this.$toast.error('Must enter an author name') this.$toast.error(this.$strings.ToastNameRequired)
return return
} }
this.processing = true this.processing = true
@ -228,17 +228,19 @@ export default {
return null return null
}) })
if (!response) { if (!response) {
this.$toast.error('Author not found') this.$toast.error(this.$strings.ToastAuthorSearchNotFound)
} 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)
} else this.$toast.success(this.$strings.ToastAuthorUpdateSuccessNoImageFound) } else {
this.$toast.success(this.$strings.ToastAuthorUpdateSuccessNoImageFound)
}
this.authorCopy = { this.authorCopy = {
...response.author ...response.author
} }
} else { } else {
this.$toast.info('No updates were made for Author') this.$toast.info(this.$strings.ToastAuthorNoUpdatesNeeded)
} }
this.processing = false this.processing = false
} }

View file

@ -115,7 +115,7 @@ export default {
return return
} }
if (!this.newCollectionName) { if (!this.newCollectionName) {
return this.$toast.error('Collection must have a name') return this.$toast.error(this.$strings.ToastNameRequired)
} }
this.processing = true this.processing = true

View file

@ -397,7 +397,7 @@ export default {
}, },
submitSearch() { submitSearch() {
if (!this.searchTitle) { if (!this.searchTitle) {
this.$toast.warning('Search title is required') this.$toast.warning(this.$strings.ToastTitleRequired)
return return
} }
this.persistProvider() this.persistProvider()

View file

@ -156,7 +156,7 @@ export default {
}, },
validate() { validate() {
if (!this.libraryCopy.name) { if (!this.libraryCopy.name) {
this.$toast.error('Library must have a name') this.$toast.error(this.$strings.ToastNameRequired)
return false return false
} }
if (!this.libraryCopy.folders.length) { if (!this.libraryCopy.folders.length) {
@ -264,4 +264,4 @@ export default {
.tab.tab-selected { .tab.tab-selected {
height: 41px; height: 41px;
} }
</style> </style>

View file

@ -95,7 +95,7 @@ export default {
return return
} }
if (!this.newPlaylistName) { if (!this.newPlaylistName) {
return this.$toast.error('Playlist must have a name') return this.$toast.error(this.$strings.ToastNameRequired)
} }
this.processing = true this.processing = true

View file

@ -809,7 +809,11 @@
"ToastApiCallFailed": "API call failed", "ToastApiCallFailed": "API call failed",
"ToastAuthorImageRemoveFailed": "Failed to remove image", "ToastAuthorImageRemoveFailed": "Failed to remove image",
"ToastAuthorImageRemoveSuccess": "Author image removed", "ToastAuthorImageRemoveSuccess": "Author image removed",
"ToastAuthorNotFound": "Author {0} not found", "ToastAuthorNoUpdatesNeeded": "No updates needed for author",
"ToastAuthorNotFound": "Author \"{0}\" not found",
"ToastAuthorRemoveFailed": "Failed to remove author",
"ToastAuthorRemoveSuccess": "Author removed",
"ToastAuthorSearchNotFound": "Author not found",
"ToastAuthorUpdateFailed": "Failed to update author", "ToastAuthorUpdateFailed": "Failed to update author",
"ToastAuthorUpdateMerged": "Author merged", "ToastAuthorUpdateMerged": "Author merged",
"ToastAuthorUpdateSuccess": "Author updated", "ToastAuthorUpdateSuccess": "Author updated",
@ -857,6 +861,7 @@
"ToastFailedToUpdateAccount": "Failed to update account", "ToastFailedToUpdateAccount": "Failed to update account",
"ToastFailedToUpdateUser": "Failed to update user", "ToastFailedToUpdateUser": "Failed to update user",
"ToastFfprobeFailed": "FFprobe failed", "ToastFfprobeFailed": "FFprobe failed",
"ToastInvalidImageUrl": "Invalid image URL",
"ToastItemCoverUpdateFailed": "Failed to update item cover", "ToastItemCoverUpdateFailed": "Failed to update item cover",
"ToastItemCoverUpdateSuccess": "Item cover updated", "ToastItemCoverUpdateSuccess": "Item cover updated",
"ToastItemDeletedFailed": "Failed to delete item", "ToastItemDeletedFailed": "Failed to delete item",
@ -879,6 +884,7 @@
"ToastLibraryUpdateFailed": "Failed to update library", "ToastLibraryUpdateFailed": "Failed to update library",
"ToastLibraryUpdateSuccess": "Library \"{0}\" updated", "ToastLibraryUpdateSuccess": "Library \"{0}\" updated",
"ToastNameEmailRequired": "Name and email are required", "ToastNameEmailRequired": "Name and email are required",
"ToastNameRequired": "Name is required",
"ToastNewUserCreatedFailed": "Failed to create account: \"{0}\"", "ToastNewUserCreatedFailed": "Failed to create account: \"{0}\"",
"ToastNewUserCreatedSuccess": "New account created", "ToastNewUserCreatedSuccess": "New account created",
"ToastNewUserLibraryError": "Must select at least one library", "ToastNewUserLibraryError": "Must select at least one library",