Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Widgets/ToastMessage.vue
<template> | <template> | ||||
<div :class="toastClassName()" role="alert" aria-live="assertive" aria-atomic="true"> | <div :class="toastClassName()" role="alert" aria-live="assertive" aria-atomic="true"> | ||||
<div class="toast-header" :class="className()"> | <div class="toast-header" :class="className()"> | ||||
<svg-icon icon="info-circle" v-if="data.type == 'info'"></svg-icon> | <svg-icon icon="info-circle" v-if="data.type == 'info'"></svg-icon> | ||||
<svg-icon icon="check-circle" v-else-if="data.type == 'success'"></svg-icon> | <svg-icon icon="check-circle" v-else-if="data.type == 'success'"></svg-icon> | ||||
<svg-icon icon="exclamation-circle" v-else-if="data.type == 'error'"></svg-icon> | <svg-icon icon="exclamation-circle" v-else-if="data.type == 'error'"></svg-icon> | ||||
<svg-icon icon="exclamation-circle" v-else-if="data.type == 'warning'"></svg-icon> | <svg-icon icon="exclamation-circle" v-else-if="data.type == 'warning'"></svg-icon> | ||||
<svg-icon :icon="data.icon" v-else-if="data.type == 'custom' && data.icon"></svg-icon> | <svg-icon :icon="data.icon" v-else-if="data.type == 'custom' && data.icon"></svg-icon> | ||||
<strong>{{ data.title || $t('msg.' + data.type) }}</strong> | <strong>{{ data.title || $t('msg.' + data.type) }}</strong> | ||||
<btn class="btn-close btn-close-white" data-bs-dismiss="toast" :aria-label="$t('btn.close')"></btn> | <btn class="btn-close btn-close-white" data-bs-dismiss="toast" :aria-label="$t('btn.close')"></btn> | ||||
</div> | </div> | ||||
<div v-if="data.body" v-html="data.body" class="toast-body"></div> | <div v-if="data.body" v-html="data.body" class="toast-body"></div> | ||||
<div v-else class="toast-body">{{ data.msg }}</div> | <div v-else class="toast-body">{{ data.msg }}</div> | ||||
<div v-if="'progress' in data" class="toast-progress"> | |||||
<div class="toast-progress-bar" :style="'width: ' + data.progress + '%'"></div> | |||||
</div> | |||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
import { Toast } from 'bootstrap' | import { Toast } from 'bootstrap' | ||||
export default { | export default { | ||||
props: { | props: { | ||||
Show All 25 Lines | export default { | ||||
case 'warning': | case 'warning': | ||||
case 'info': | case 'info': | ||||
case 'success': | case 'success': | ||||
return 'text-' + this.data.type | return 'text-' + this.data.type | ||||
case 'custom': | case 'custom': | ||||
return this.data.titleClassName || '' | return this.data.titleClassName || '' | ||||
} | } | ||||
}, | }, | ||||
delete() { | |||||
new Toast(this.$el).dispose() | |||||
}, | |||||
toastClassName() { | toastClassName() { | ||||
return 'toast hide toast-' + this.data.type | return 'toast hide toast-' + this.data.type | ||||
+ (this.data.className ? ' ' + this.data.className : '') | + (this.data.className ? ' ' + this.data.className : '') | ||||
}, | |||||
updateProgress(percent) { | |||||
$(this.$el).find('.toast-progress-bar').css('width', percent + '%') | |||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |