blob: 95ac53127faef61da38af7b56ca7efa076ed0a10 [file] [log] [blame]
SurenNewarec2862dc2020-09-11 18:02:42 +05301import i18n from '@/i18n';
2import StatusIcon from '../Global/StatusIcon';
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -08003const BVToastMixin = {
SurenNewarec2862dc2020-09-11 18:02:42 +05304 components: {
5 StatusIcon
6 },
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -08007 methods: {
SurenNewarec2862dc2020-09-11 18:02:42 +05308 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 Muranaka547b5fc2020-02-24 15:42:40 -080020 successToast(message, title = i18n.t('global.status.success')) {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080021 this.$root.$bvToast.toast(message, {
SurenNewarec2862dc2020-09-11 18:02:42 +053022 title: this.toastTitle(title, 'success'),
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080023 variant: 'success',
24 autoHideDelay: 10000, //auto hide in milliseconds
25 isStatus: true,
26 solid: true
27 });
28 },
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080029 errorToast(message, title = i18n.t('global.status.error')) {
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080030 this.$root.$bvToast.toast(message, {
SurenNewarec2862dc2020-09-11 18:02:42 +053031 title: this.toastTitle(title, 'danger'),
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080032 variant: 'danger',
33 noAutoHide: true,
34 isStatus: true,
35 solid: true
36 });
Yoshie Muranaka183c2752020-02-12 11:30:49 -080037 },
Yoshie Muranaka547b5fc2020-02-24 15:42:40 -080038 warningToast(message, title = i18n.t('global.status.warning')) {
Yoshie Muranaka183c2752020-02-12 11:30:49 -080039 this.$root.$bvToast.toast(message, {
SurenNewarec2862dc2020-09-11 18:02:42 +053040 title: this.toastTitle(title, 'warning'),
Yoshie Muranaka183c2752020-02-12 11:30:49 -080041 variant: 'warning',
42 noAutoHide: true,
43 isStatus: true,
44 solid: true
45 });
Derick Montague4e90eed2020-03-03 18:11:44 -060046 },
47 infoToast(message, title = i18n.t('global.status.informational')) {
48 this.$root.$bvToast.toast(message, {
SurenNewarec2862dc2020-09-11 18:02:42 +053049 title: this.toastTitle(title, 'info'),
Derick Montague4e90eed2020-03-03 18:11:44 -060050 variant: 'info',
51 noAutoHide: true,
52 isStatus: true,
53 solid: true
54 });
Yoshie Muranaka0fc91e72020-02-05 11:23:06 -080055 }
56 }
57};
58
59export default BVToastMixin;