Added mixins for modal notify and error
This commit is contained in:
parent
133a623657
commit
55e527c229
1 changed files with 35 additions and 1 deletions
36
src/main.js
36
src/main.js
|
|
@ -9,7 +9,7 @@ Vue.config.productionTip = false
|
|||
Vue.mixin({
|
||||
methods: {
|
||||
modalConfirm: function(modalText) {
|
||||
var context = this;
|
||||
var context = this
|
||||
|
||||
// Stop GPU preview to show modal
|
||||
context.$root.$emit('globalTogglePreview', false)
|
||||
|
|
@ -31,7 +31,41 @@ Vue.mixin({
|
|||
})
|
||||
}
|
||||
return new Promise(showModal)
|
||||
},
|
||||
|
||||
modalNotify: function(message) {
|
||||
UIkit.notification({message: message, status: 'success'})
|
||||
},
|
||||
|
||||
modalError: function(error) {
|
||||
console.log(error)
|
||||
var errormsg = ''
|
||||
|
||||
// If a response was obtained
|
||||
if (error.response) {
|
||||
// If the response is a nicely formatted JSON response from the server
|
||||
if (error.response.data.message) {
|
||||
errormsg = `${error.response.status}: ${error.response.data.message}`
|
||||
console.log(errormsg)
|
||||
}
|
||||
// If the response is just some generic error response
|
||||
else {
|
||||
errormsg = `${error.response.status}: ${error.response.data}`
|
||||
console.log(errormsg)
|
||||
}
|
||||
// If the error occured during the request
|
||||
} else if (error.request) {
|
||||
errormsg = `${error.message}`
|
||||
console.log(errormsg)
|
||||
// Everything else
|
||||
} else {
|
||||
errormsg = `${error.message}`
|
||||
console.log(errormsg)
|
||||
}
|
||||
this.$store.dispatch('errorState', errormsg);
|
||||
UIkit.notification({message: `<span uk-icon=\'icon: warning\'></span> ${errormsg}`, status: 'danger'})
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue