This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div v-resize="onResize">
|
||||
{{ formState }}
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6" class="py-2">
|
||||
<v-btn-toggle
|
||||
@@ -115,8 +116,7 @@ import * as monaco from "monaco-editor";
|
||||
//https://github.com/egoist/vue-monaco/blob/master/src/MonacoEditor.js
|
||||
|
||||
/*TODO:
|
||||
Get data from list
|
||||
needs work at this end in widget list form (or is it in the data-list control?)
|
||||
|
||||
|
||||
template roundtrip save and open template from server
|
||||
|
||||
@@ -231,8 +231,19 @@ export default {
|
||||
vm.formState.ready = true;
|
||||
}
|
||||
},
|
||||
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty || JUST_DELETED) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
//TODO: dispose all models and editor
|
||||
editor && editor.dispose();
|
||||
},
|
||||
@@ -304,6 +315,40 @@ Handlebars.registerHelper('loud', function (aString) {
|
||||
ayaType: window.$gz.type.Report
|
||||
};
|
||||
},
|
||||
//WATCHERS
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
//,oldval is available here too if necessary
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
//enable / disable save button
|
||||
if (val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
|
||||
//enable / disable duplicate / new button
|
||||
if (!val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-enable-item",
|
||||
FORM_KEY + ":duplicate"
|
||||
);
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-disable-item",
|
||||
FORM_KEY + ":duplicate"
|
||||
);
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//alternate method, one editor with tabs example
|
||||
//probably should do this way
|
||||
|
||||
Reference in New Issue
Block a user