updated standard toast function

This commit is contained in:
vabene1111
2022-04-23 01:31:15 +02:00
parent 3850287deb
commit e4223787be
20 changed files with 204 additions and 149 deletions

View File

@ -173,13 +173,13 @@ export default {
this.genericAPI(this.model, this.Actions.DELETE, { id: this.item1.id })
.then((result) => {
this.$emit("finish-action")
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_DELETE)
StandardToasts.makeStandardToast(this,StandardToasts.SUCCESS_DELETE)
})
.catch((err) => {
if (err.response.status === 403){
StandardToasts.makeStandardToast(StandardToasts.FAIL_DELETE_PROTECTED)
StandardToasts.makeStandardToast(this,StandardToasts.FAIL_DELETE_PROTECTED)
}else {
StandardToasts.makeStandardToast(StandardToasts.FAIL_DELETE)
StandardToasts.makeStandardToast(this,StandardToasts.FAIL_DELETE)
}
this.$emit("finish-action", "cancel")
})
@ -190,22 +190,22 @@ export default {
this.genericAPI(this.model, this.Actions.CREATE, this.form_data)
.then((result) => {
this.$emit("finish-action", { item: result.data })
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_CREATE)
StandardToasts.makeStandardToast(this,StandardToasts.SUCCESS_CREATE)
})
.catch((err) => {
console.log(err)
StandardToasts.makeStandardToast(StandardToasts.FAIL_CREATE)
StandardToasts.makeStandardToast(this,StandardToasts.FAIL_CREATE)
this.$emit("finish-action", "cancel")
})
} else {
this.genericAPI(this.model, this.Actions.UPDATE, this.form_data)
.then((result) => {
this.$emit("finish-action")
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_UPDATE)
StandardToasts.makeStandardToast(this,StandardToasts.SUCCESS_UPDATE)
})
.catch((err) => {
console.log(err, err.response)
StandardToasts.makeStandardToast(StandardToasts.FAIL_UPDATE)
StandardToasts.makeStandardToast(this,StandardToasts.FAIL_UPDATE)
this.$emit("finish-action", "cancel")
})
}
@ -224,11 +224,11 @@ export default {
this.genericAPI(this.model, this.Actions.MOVE, { source: this.item1.id, target: this.form_data.target.id })
.then((result) => {
this.$emit("finish-action", { target: this.form_data.target.id })
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_MOVE)
StandardToasts.makeStandardToast(this,StandardToasts.SUCCESS_MOVE)
})
.catch((err) => {
console.log(err)
StandardToasts.makeStandardToast(StandardToasts.FAIL_MOVE)
StandardToasts.makeStandardToast(this,StandardToasts.FAIL_MOVE)
this.$emit("finish-action", "cancel")
})
},
@ -249,12 +249,12 @@ export default {
})
.then((result) => {
this.$emit("finish-action", { target: this.form_data.target.id })
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_MERGE)
StandardToasts.makeStandardToast(this,StandardToasts.SUCCESS_MERGE)
})
.catch((err) => {
//TODO error checking not working with OpenAPI methods
console.log("Error", err)
StandardToasts.makeStandardToast(StandardToasts.FAIL_MERGE)
StandardToasts.makeStandardToast(this,StandardToasts.FAIL_MERGE)
this.$emit("finish-action", "cancel")
})