summaryrefslogtreecommitdiff
path: root/docs/.vuepress/components/app-imports/BVToastMixin.js
diff options
context:
space:
mode:
Diffstat (limited to 'docs/.vuepress/components/app-imports/BVToastMixin.js')
-rw-r--r--docs/.vuepress/components/app-imports/BVToastMixin.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/docs/.vuepress/components/app-imports/BVToastMixin.js b/docs/.vuepress/components/app-imports/BVToastMixin.js
new file mode 100644
index 00000000..10075658
--- /dev/null
+++ b/docs/.vuepress/components/app-imports/BVToastMixin.js
@@ -0,0 +1,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;