This commit is contained in:
@@ -119,6 +119,20 @@ export default {
|
|||||||
window.$gz.errorHandler.handleFormError(err);
|
window.$gz.errorHandler.handleFormError(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
beforeRouteLeave(to, from, next) {
|
||||||
|
//var vm = this;
|
||||||
|
if (this.formState.dirty) {
|
||||||
|
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
|
||||||
|
if (dialogResult == true) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
next(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
||||||
//modify the menu as necessary
|
//modify the menu as necessary
|
||||||
@@ -143,41 +157,14 @@ export default {
|
|||||||
},
|
},
|
||||||
formState: {
|
formState: {
|
||||||
ready: false,
|
ready: false,
|
||||||
errorBoxMessage: null
|
errorBoxMessage: null,
|
||||||
|
dirty: false
|
||||||
},
|
},
|
||||||
rights: window.$gz.role.getRights(window.$gz.type.FormCustom)
|
rights: window.$gz.role.getRights(window.$gz.type.FormCustom)
|
||||||
//,tempTemplate: window.$gz.store.state.formCustomTemplate["widget"]
|
//,tempTemplate: window.$gz.store.state.formCustomTemplate["widget"]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// //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
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// computed: {
|
|
||||||
// canSave: function() {
|
|
||||||
// return this.formState.valid && this.formState.dirty;
|
|
||||||
// },
|
|
||||||
// canDuplicate: function() {
|
|
||||||
// return this.formState.valid && !this.formState.dirty;
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// components: {},
|
|
||||||
methods: {
|
methods: {
|
||||||
lt: function(ltkey) {
|
lt: function(ltkey) {
|
||||||
return window.$gz.locale.get(ltkey);
|
return window.$gz.locale.get(ltkey);
|
||||||
@@ -187,6 +174,7 @@ export default {
|
|||||||
if (item.required && item.visible == false) {
|
if (item.required && item.visible == false) {
|
||||||
item.required = false;
|
item.required = false;
|
||||||
}
|
}
|
||||||
|
this.formState.dirty = true;
|
||||||
enableSaveButton();
|
enableSaveButton();
|
||||||
},
|
},
|
||||||
requiredChanged: function(item) {
|
requiredChanged: function(item) {
|
||||||
@@ -194,10 +182,12 @@ export default {
|
|||||||
if (item.required && item.visible == false) {
|
if (item.required && item.visible == false) {
|
||||||
item.visible = true;
|
item.visible = true;
|
||||||
}
|
}
|
||||||
|
this.formState.dirty = true;
|
||||||
enableSaveButton();
|
enableSaveButton();
|
||||||
},
|
},
|
||||||
dataTypeChanged: function(item) {
|
dataTypeChanged: function(item) {
|
||||||
//nothing to scan here just set form dirty
|
//nothing to scan here just set form dirty
|
||||||
|
this.formState.dirty = true;
|
||||||
enableSaveButton();
|
enableSaveButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user