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