1import i18n from '@/i18n'; 2import StatusIcon from '../Global/StatusIcon'; 3const BVToastMixin = { 4 components: { 5 StatusIcon 6 }, 7 methods: { 8 toastTitle(title, status) { 9 // Create title with icon 10 const titleWithIcon = this.$createElement( 11 'strong', 12 { class: 'toast-icon' }, 13 [ 14 this.$createElement('StatusIcon', { props: { status: status } }), 15 title 16 ] 17 ); 18 return titleWithIcon; 19 }, 20 successToast(message, title = i18n.t('global.status.success')) { 21 this.$root.$bvToast.toast(message, { 22 title: this.toastTitle(title, 'success'), 23 variant: 'success', 24 autoHideDelay: 10000, //auto hide in milliseconds 25 isStatus: true, 26 solid: true 27 }); 28 }, 29 errorToast(message, title = i18n.t('global.status.error')) { 30 this.$root.$bvToast.toast(message, { 31 title: this.toastTitle(title, 'danger'), 32 variant: 'danger', 33 noAutoHide: true, 34 isStatus: true, 35 solid: true 36 }); 37 }, 38 warningToast(message, title = i18n.t('global.status.warning')) { 39 this.$root.$bvToast.toast(message, { 40 title: this.toastTitle(title, 'warning'), 41 variant: 'warning', 42 noAutoHide: true, 43 isStatus: true, 44 solid: true 45 }); 46 }, 47 infoToast(message, title = i18n.t('global.status.informational')) { 48 this.$root.$bvToast.toast(message, { 49 title: this.toastTitle(title, 'info'), 50 variant: 'info', 51 noAutoHide: true, 52 isStatus: true, 53 solid: true 54 }); 55 } 56 } 57}; 58 59export default BVToastMixin; 60