This commit is contained in:
@@ -121,6 +121,7 @@ export default {
|
||||
generateMenu(vm, false); //default is never read only and passing in this vm
|
||||
//init disable save button so it can be enabled only on edit to show dirty form
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
vm.formState.loading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
vm.formState.ready = true;
|
||||
@@ -153,6 +154,25 @@ export default {
|
||||
},
|
||||
rights: window.$gz.role.getRights(window.$gz.type.FormCustom)
|
||||
};
|
||||
}, //WATCHERS
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
//,oldval is available here too if necessary
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
//enable / disable save button
|
||||
var canSave = val.dirty && val.valid && !val.readOnly;
|
||||
if (canSave) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
t: function(tKey) {
|
||||
@@ -343,10 +363,6 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
function enableSaveButton() {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user