2022-09-20 19:59:52 +00:00
|
|
|
/**
|
|
|
|
* Base mixin for all Vue components
|
|
|
|
*/
|
|
|
|
import debounce from 'debounce'
|
|
|
|
|
|
|
|
export default {
|
2022-12-22 10:55:17 +00:00
|
|
|
|
2022-12-22 10:54:01 +00:00
|
|
|
computed: {
|
|
|
|
$crisp () {
|
|
|
|
return window.$crisp
|
|
|
|
}
|
|
|
|
},
|
2022-12-22 10:55:17 +00:00
|
|
|
|
2022-09-20 19:59:52 +00:00
|
|
|
methods: {
|
|
|
|
/**
|
|
|
|
* Creates a debounced function that delays invoking a callback.
|
|
|
|
*/
|
|
|
|
debouncer: debounce((callback) => callback(), 500),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show an error message.
|
|
|
|
*/
|
2022-12-22 10:54:01 +00:00
|
|
|
alertError (message, autoClose = 10000) {
|
2022-11-25 09:53:09 +00:00
|
|
|
this.$notify(
|
|
|
|
{
|
|
|
|
title: 'Error',
|
|
|
|
text: message,
|
2022-12-22 10:54:01 +00:00
|
|
|
type: 'error'
|
2022-11-25 09:53:09 +00:00
|
|
|
}, autoClose)
|
2022-09-20 19:59:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a success message.
|
|
|
|
*/
|
2022-12-22 10:54:01 +00:00
|
|
|
alertSuccess (message, autoClose = 10000) {
|
2022-11-25 09:53:09 +00:00
|
|
|
this.$notify(
|
|
|
|
{
|
|
|
|
title: 'Success',
|
|
|
|
text: message,
|
2022-12-22 10:54:01 +00:00
|
|
|
type: 'success'
|
2022-11-25 09:53:09 +00:00
|
|
|
}, autoClose)
|
2022-09-20 19:59:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a warning message.
|
|
|
|
*/
|
2022-12-22 10:54:01 +00:00
|
|
|
alertWarning (message, autoClose = 10000) {
|
2022-11-25 09:53:09 +00:00
|
|
|
this.$notify(
|
|
|
|
{
|
|
|
|
title: 'Warning',
|
|
|
|
text: message,
|
2022-12-22 10:54:01 +00:00
|
|
|
type: 'warning'
|
2022-11-25 09:53:09 +00:00
|
|
|
}, autoClose)
|
2022-09-20 19:59:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show confirmation message.
|
|
|
|
*/
|
2022-12-22 10:54:01 +00:00
|
|
|
alertConfirm (message, success, failure = ()=>{}, autoClose = 10000) {
|
2022-11-25 09:53:09 +00:00
|
|
|
this.$notify(
|
|
|
|
{
|
|
|
|
title: 'Confirm',
|
|
|
|
text: message,
|
|
|
|
type: 'confirm',
|
2022-12-22 10:54:01 +00:00
|
|
|
success,
|
|
|
|
failure
|
2022-11-25 09:53:09 +00:00
|
|
|
}, autoClose)
|
2022-09-20 19:59:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show confirmation message.
|
|
|
|
*/
|
|
|
|
closeAlert () {
|
|
|
|
this.$root.alert = {
|
|
|
|
type: null,
|
|
|
|
autoClose: 0,
|
|
|
|
message: '',
|
|
|
|
confirmationProceed: null,
|
|
|
|
confirmationCancel: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|