global mixin for toasting error and success

This commit is contained in:
Moriz Wahl 2022-02-15 11:18:50 +01:00
parent ce457ffc0c
commit df63d76a86
2 changed files with 27 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import DashboardPlugin from './plugins/dashboard-plugin'
import App from './App.vue' import App from './App.vue'
import i18n from './i18n.js' import i18n from './i18n.js'
import { loadAllRules } from './validation-rules' import { loadAllRules } from './validation-rules'
import { toasters } from './mixins/toaster'
import 'regenerator-runtime' import 'regenerator-runtime'
@ -18,6 +19,8 @@ import { apolloProvider } from './plugins/apolloProvider'
Vue.use(DashboardPlugin) Vue.use(DashboardPlugin)
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.mixin(toasters)
Vue.toasted.register( Vue.toasted.register(
'error', 'error',
(payload) => { (payload) => {

View File

@ -0,0 +1,24 @@
export const toasters = {
methods: {
toastSuccess(message) {
this.toast(message, {
title: this.$t('success'),
variant: 'danger',
})
},
toastError(message) {
this.toast(message, {
title: this.$t('error.error'),
variant: 'success',
})
},
toast(message, options) {
this.$bvToast.toast(message, {
autoHideDelay: 5000,
appendToast: false,
solid: true,
...options,
})
},
},
}