import i18n from '@/i18n'; import StatusIcon from '../Global/StatusIcon'; const BVToastMixin = { components: { StatusIcon }, methods: { toastTitle(title, status) { // Create title with icon const titleWithIcon = this.$createElement( 'strong', { class: 'toast-icon' }, [ this.$createElement('StatusIcon', { props: { status: status } }), title ] ); return titleWithIcon; }, successToast(message, title = i18n.t('global.status.success')) { this.$root.$bvToast.toast(message, { title: this.toastTitle(title, 'success'), variant: 'success', autoHideDelay: 10000, //auto hide in milliseconds isStatus: true, solid: true }); }, errorToast(message, title = i18n.t('global.status.error')) { this.$root.$bvToast.toast(message, { title: this.toastTitle(title, 'danger'), variant: 'danger', noAutoHide: true, isStatus: true, solid: true }); }, warningToast(message, title = i18n.t('global.status.warning')) { this.$root.$bvToast.toast(message, { title: this.toastTitle(title, 'warning'), variant: 'warning', noAutoHide: true, isStatus: true, solid: true }); }, infoToast(message, title = i18n.t('global.status.informational')) { this.$root.$bvToast.toast(message, { title: this.toastTitle(title, 'info'), variant: 'info', noAutoHide: true, isStatus: true, solid: true }); } } }; export default BVToastMixin;