SurenNeware | c2862dc | 2020-09-11 18:02:42 +0530 | [diff] [blame] | 1 | import i18n from '@/i18n'; |
| 2 | import StatusIcon from '../Global/StatusIcon'; |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 3 | const BVToastMixin = { |
SurenNeware | c2862dc | 2020-09-11 18:02:42 +0530 | [diff] [blame] | 4 | components: { |
| 5 | StatusIcon |
| 6 | }, |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 7 | methods: { |
SurenNeware | c2862dc | 2020-09-11 18:02:42 +0530 | [diff] [blame] | 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 | }, |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 20 | successToast(message, title = i18n.t('global.status.success')) { |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 21 | this.$root.$bvToast.toast(message, { |
SurenNeware | c2862dc | 2020-09-11 18:02:42 +0530 | [diff] [blame] | 22 | title: this.toastTitle(title, 'success'), |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 23 | variant: 'success', |
| 24 | autoHideDelay: 10000, //auto hide in milliseconds |
| 25 | isStatus: true, |
| 26 | solid: true |
| 27 | }); |
| 28 | }, |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 29 | errorToast(message, title = i18n.t('global.status.error')) { |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 30 | this.$root.$bvToast.toast(message, { |
SurenNeware | c2862dc | 2020-09-11 18:02:42 +0530 | [diff] [blame] | 31 | title: this.toastTitle(title, 'danger'), |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 32 | variant: 'danger', |
| 33 | noAutoHide: true, |
| 34 | isStatus: true, |
| 35 | solid: true |
| 36 | }); |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 37 | }, |
Yoshie Muranaka | 547b5fc | 2020-02-24 15:42:40 -0800 | [diff] [blame] | 38 | warningToast(message, title = i18n.t('global.status.warning')) { |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 39 | this.$root.$bvToast.toast(message, { |
SurenNeware | c2862dc | 2020-09-11 18:02:42 +0530 | [diff] [blame] | 40 | title: this.toastTitle(title, 'warning'), |
Yoshie Muranaka | 183c275 | 2020-02-12 11:30:49 -0800 | [diff] [blame] | 41 | variant: 'warning', |
| 42 | noAutoHide: true, |
| 43 | isStatus: true, |
| 44 | solid: true |
| 45 | }); |
Derick Montague | 4e90eed | 2020-03-03 18:11:44 -0600 | [diff] [blame] | 46 | }, |
| 47 | infoToast(message, title = i18n.t('global.status.informational')) { |
| 48 | this.$root.$bvToast.toast(message, { |
SurenNeware | c2862dc | 2020-09-11 18:02:42 +0530 | [diff] [blame] | 49 | title: this.toastTitle(title, 'info'), |
Derick Montague | 4e90eed | 2020-03-03 18:11:44 -0600 | [diff] [blame] | 50 | variant: 'info', |
| 51 | noAutoHide: true, |
| 52 | isStatus: true, |
| 53 | solid: true |
| 54 | }); |
Yoshie Muranaka | 0fc91e7 | 2020-02-05 11:23:06 -0800 | [diff] [blame] | 55 | } |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | export default BVToastMixin; |