130 lines
3.2 KiB
JavaScript
130 lines
3.2 KiB
JavaScript
import reportChooser from "../components/report-chooser.vue";
|
|
|
|
/* Xeslint-disable */
|
|
|
|
/////////////////////////////////
|
|
// Dialog, toast, notification
|
|
// utils and handlers
|
|
//
|
|
export default {
|
|
///////////////////////////////////
|
|
// WIRE UP DIALOG EVENTS
|
|
//
|
|
// called once from app.vue only
|
|
//
|
|
wireUpEventHandlers(vm) {
|
|
//Notifications: pops up and slowly disappears
|
|
|
|
///////////
|
|
//ERROR
|
|
vm.$gzevent.$on("notify-error", function handleNotifyWarn(msg) {
|
|
vm.$dialog.notify.info(msg, {
|
|
position: "top-right",
|
|
icon: "fa-exclamation-triangle",
|
|
timeout: 8000
|
|
});
|
|
});
|
|
|
|
///////////
|
|
//WARNING
|
|
vm.$gzevent.$on("notify-warning", function handleNotifyWarn(msg) {
|
|
vm.$dialog.notify.warning(msg, {
|
|
position: "top-right",
|
|
icon: "fa-exclamation",
|
|
timeout: 7000
|
|
});
|
|
});
|
|
|
|
///////////
|
|
//INFO
|
|
vm.$gzevent.$on("notify-info", function handleNotifyWarn(msg) {
|
|
vm.$dialog.notify.info(msg, {
|
|
position: "top-right",
|
|
icon: "fa-info-circle",
|
|
timeout: 6000
|
|
});
|
|
});
|
|
|
|
///////////
|
|
//SUCCESS
|
|
vm.$gzevent.$on("notify-success", function handleNotifyWarn(msg) {
|
|
vm.$dialog.notify.success(msg, {
|
|
position: "top-right",
|
|
icon: "fa-check-circle ",
|
|
timeout: 5000
|
|
});
|
|
});
|
|
},
|
|
/////////////////////////////////////
|
|
// Are you sure you want to delete?
|
|
//
|
|
confirmDelete(vm) {
|
|
//https://github.com/yariksav/vuetify-dialog#readme
|
|
return vm.$dialog.warning({
|
|
text: vm.$gzlocale.get("DeletePrompt"),
|
|
title: vm.$gzlocale.get("Delete"),
|
|
icon: "fa-exclamation-triangle",
|
|
actions: [
|
|
{
|
|
text: vm.$gzlocale.get("Cancel"),
|
|
key: false
|
|
},
|
|
{
|
|
text: vm.$gzlocale.get("Delete"),
|
|
color: "red",
|
|
key: true
|
|
}
|
|
]
|
|
});
|
|
}, /////////////////////////////////////
|
|
// Are you sure you want to delete?
|
|
//
|
|
confirmLeaveUnsaved(vm) {
|
|
return vm.$dialog.warning({
|
|
text: vm.$gzlocale.get("AreYouSureUnsavedChanges"),
|
|
title: vm.$gzlocale.get("Leave"),
|
|
icon: "fa-exclamation-triangle",
|
|
actions: [
|
|
{
|
|
text: vm.$gzlocale.get("Cancel"),
|
|
key: false
|
|
},
|
|
{
|
|
text: vm.$gzlocale.get("Leave"),
|
|
color: "red",
|
|
key: true
|
|
}
|
|
]
|
|
});
|
|
},
|
|
/////////////////////////////////////
|
|
// Display LT message with wait for ok
|
|
//
|
|
displayLTErrorMessage(vm, ltKeyText, ltKeyTitle = undefined) {
|
|
//https://github.com/yariksav/vuetify-dialog#readme
|
|
return vm.$dialog.error({
|
|
text: ltKeyText ? vm.$gzlocale.get(ltKeyText) : "",
|
|
title: ltKeyTitle ? vm.$gzlocale.get(ltKeyTitle) : "",
|
|
icon: "fa-exclamation-triangle",
|
|
actions: [
|
|
{
|
|
text: vm.$gzlocale.get("OK"),
|
|
key: true
|
|
}
|
|
]
|
|
});
|
|
}, /////////////////////////////////////
|
|
// Show a report list
|
|
//
|
|
async getReportChoice(vm, reports) {
|
|
const result = await vm.$dialog.showAndWait(reportChooser, {
|
|
reports: reports,
|
|
title: vm.$gzlocale.get("Report"),
|
|
oktext: vm.$gzlocale.get("Print"),
|
|
canceltext: vm.$gzlocale.get("Cancel")
|
|
});
|
|
return result;
|
|
}
|
|
//new functions above here
|
|
};
|