summaryrefslogtreecommitdiff
path: root/src/components/Mixins
diff options
context:
space:
mode:
authorSurenNeware <sneware9@in.ibm.com>2020-09-11 15:32:42 +0300
committerDerick Montague <derick.montague@ibm.com>2020-09-27 19:19:14 +0300
commitc2862dcc2a3e531a58b50b31ad18a3597303c7ac (patch)
tree7711507816561380000a84665c4dd312a57f056e /src/components/Mixins
parent7ad48b126f9df728ec0984933235441aa7688c2e (diff)
downloadwebui-vue-c2862dcc2a3e531a58b50b31ad18a3597303c7ac.tar.xz
Add icon to the toast component
- Add status icon to the toast component. - Add a method that return title with associated icon. Signed-off-by: Suren Neware <sneware9@in.ibm.com> Change-Id: Iae75e3eec7317af6b25a0ed1bfa4cc72644f7cd7
Diffstat (limited to 'src/components/Mixins')
-rw-r--r--src/components/Mixins/BVToastMixin.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/components/Mixins/BVToastMixin.js b/src/components/Mixins/BVToastMixin.js
index 538bb93c..95ac5312 100644
--- a/src/components/Mixins/BVToastMixin.js
+++ b/src/components/Mixins/BVToastMixin.js
@@ -1,10 +1,25 @@
-import i18n from '../../i18n';
-
+import i18n from '@/i18n';
+import StatusIcon from '../Global/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 = i18n.t('global.status.success')) {
this.$root.$bvToast.toast(message, {
- title,
+ title: this.toastTitle(title, 'success'),
variant: 'success',
autoHideDelay: 10000, //auto hide in milliseconds
isStatus: true,
@@ -13,7 +28,7 @@ const BVToastMixin = {
},
errorToast(message, title = i18n.t('global.status.error')) {
this.$root.$bvToast.toast(message, {
- title,
+ title: this.toastTitle(title, 'danger'),
variant: 'danger',
noAutoHide: true,
isStatus: true,
@@ -22,7 +37,7 @@ const BVToastMixin = {
},
warningToast(message, title = i18n.t('global.status.warning')) {
this.$root.$bvToast.toast(message, {
- title,
+ title: this.toastTitle(title, 'warning'),
variant: 'warning',
noAutoHide: true,
isStatus: true,
@@ -31,7 +46,7 @@ const BVToastMixin = {
},
infoToast(message, title = i18n.t('global.status.informational')) {
this.$root.$bvToast.toast(message, {
- title,
+ title: this.toastTitle(title, 'info'),
variant: 'info',
noAutoHide: true,
isStatus: true,