1170e030f6
Use message mixin everywhere Add mixin for success and error messages Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/51
43 lines
No EOL
1 KiB
JavaScript
43 lines
No EOL
1 KiB
JavaScript
export default {
|
|
setLoading(context) {
|
|
const timeout = setTimeout(function () {
|
|
context.loading = true
|
|
}, 100);
|
|
return () => {
|
|
clearTimeout(timeout)
|
|
context.loading = false
|
|
};
|
|
},
|
|
error(e, context) {
|
|
// Build the notification text from error response
|
|
let err = e.message
|
|
if (e.response && e.response.data && e.response.data.message) {
|
|
err += '<br/>' + e.response.data.message
|
|
}
|
|
|
|
// Fire a notification
|
|
context.$notify({
|
|
type: 'error',
|
|
title: 'Error',
|
|
text: err
|
|
})
|
|
|
|
context.loading = false
|
|
},
|
|
success(e, context) {
|
|
// Build the notification text from error response
|
|
let err = e.message
|
|
if (e.response && e.response.data && e.response.data.message) {
|
|
err += '<br/>' + e.response.data.message
|
|
}
|
|
|
|
// Fire a notification
|
|
context.$notify({
|
|
type: 'success',
|
|
title: 'Success',
|
|
text: err
|
|
})
|
|
|
|
context.loading = false
|
|
},
|
|
} |