summaryrefslogtreecommitdiff
path: root/docs/.vuepress/components/app-imports/BVToastMixin.js
blob: 100756583f579cbab562854cfdfdc86d8e98baca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import StatusIcon from './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 = '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 = 'Error') {
      this.$root.$bvToast.toast(message, {
        title: this.toastTitle(title, 'danger'),
        variant: 'danger',
        noAutoHide: true,
        isStatus: true,
        solid: true
      });
    },
    warningToast(message, title = 'Warning') {
      this.$root.$bvToast.toast(message, {
        title: this.toastTitle(title, 'warning'),
        variant: 'warning',
        noAutoHide: true,
        isStatus: true,
        solid: true
      });
    },
    infoToast(message, title = 'Informational') {
      this.$root.$bvToast.toast(message, {
        title: this.toastTitle(title, 'info'),
        variant: 'info',
        noAutoHide: true,
        isStatus: true,
        solid: true
      });
    }
  }
};

export default BVToastMixin;