This commit is contained in:
2020-02-21 20:37:42 +00:00
parent 664d6e1a12
commit ab355de84d

View File

@@ -512,6 +512,40 @@ export default {
rights: window.$gz.role.getRights(window.$gz.type.DataListView)
};
},
//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");
}
//enable / disable duplicate button
var canDuplicate = !val.dirty && val.valid && !val.readOnly;
if (canDuplicate) {
window.$gz.eventBus.$emit(
"menu-enable-item",
FORM_KEY + ":duplicate"
);
} else {
window.$gz.eventBus.$emit(
"menu-disable-item",
FORM_KEY + ":duplicate"
);
}
},
deep: true
}
},
computed: {
canSave: function() {
return this.formState.valid && this.formState.dirty;
@@ -803,10 +837,6 @@ export default {
}
};
function enableSaveButton() {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
}
/////////////////////////////
//
//
@@ -1303,7 +1333,6 @@ function updateEditedListView(vm) {
//compare it with the effectiveListView to see if there are any changes between the two
//set the form to dirty if there are changes and can save
//this.formState.dirty = true;
// enableSaveButton();
//this way user can build their way back to the same view and then no need to save if no changes
//build an array of all enums then execute method
}