2020-05-11 18:05:34 +02:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
:style="{display: isVisible ? 'flex' : 'none'}"
|
|
|
|
class="toast mt-2"
|
|
|
|
:class="toastStatus.className"
|
|
|
|
>
|
2021-06-25 09:35:20 +02:00
|
|
|
<span class="p-vcentered text-left"><i class="mdi mdi-24px mr-1" :class="toastStatus.iconName" /> {{ message }}</span>
|
2020-05-11 18:05:34 +02:00
|
|
|
<button class="btn btn-clear" @click="hideToast" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'BaseToast',
|
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
status: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
},
|
2022-04-22 12:16:02 +02:00
|
|
|
emits: ['close'],
|
2020-05-11 18:05:34 +02:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
isVisible: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
toastStatus () {
|
|
|
|
let className = '';
|
2021-06-25 09:35:20 +02:00
|
|
|
let iconName = '';
|
2020-05-11 18:05:34 +02:00
|
|
|
switch (this.status) {
|
|
|
|
case 'success':
|
|
|
|
className = 'toast-success';
|
2021-06-25 09:35:20 +02:00
|
|
|
iconName = 'mdi-check';
|
2020-05-11 18:05:34 +02:00
|
|
|
break;
|
|
|
|
case 'error':
|
|
|
|
className = 'toast-error';
|
2021-06-25 09:35:20 +02:00
|
|
|
iconName = 'mdi-alert-rhombus';
|
2020-05-11 18:05:34 +02:00
|
|
|
break;
|
|
|
|
case 'warning':
|
|
|
|
className = 'toast-warning';
|
2021-06-25 09:35:20 +02:00
|
|
|
iconName = 'mdi-alert';
|
2020-05-11 18:05:34 +02:00
|
|
|
break;
|
|
|
|
case 'primary':
|
|
|
|
className = 'toast-primary';
|
2021-06-25 09:35:20 +02:00
|
|
|
iconName = 'mdi-information-outline';
|
2020-05-11 18:05:34 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-06-25 09:35:20 +02:00
|
|
|
return { className, iconName };
|
2020-05-11 18:05:34 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
message: function () {
|
|
|
|
if (this.message)
|
|
|
|
this.isVisible = true;
|
|
|
|
else
|
|
|
|
this.isVisible = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
hideToast () {
|
|
|
|
this.isVisible = false;
|
2020-05-15 17:52:59 +02:00
|
|
|
this.$emit('close');
|
2020-05-11 18:05:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style scoped>
|
2020-07-31 18:16:28 +02:00
|
|
|
.toast {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
user-select: text;
|
|
|
|
word-break: break-all;
|
|
|
|
}
|
2020-05-11 18:05:34 +02:00
|
|
|
</style>
|