This commit is contained in:
@@ -245,49 +245,34 @@ export default {
|
||||
await initForm(vm);
|
||||
|
||||
vm.rights = window.$gz.role.getRights(window.$gz.type.User);
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
readOnly: !vm.rights.change
|
||||
});
|
||||
|
||||
vm.formState.readOnly = !vm.rights.change;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
|
||||
//id 0 means create a new record don't load one
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
//is there already an obj from a create?
|
||||
//is there already an obj from a prior operation?
|
||||
if (this.$route.params.obj) {
|
||||
//yes, no need to fetch it
|
||||
this.obj = this.$route.params.obj;
|
||||
} else {
|
||||
vm.getDataFromApi(vm.$route.params.recordid);
|
||||
}
|
||||
} else {
|
||||
//setup for new record
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false
|
||||
});
|
||||
|
||||
generateMenu(vm);
|
||||
}
|
||||
//set initial form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false
|
||||
});
|
||||
|
||||
generateMenu(vm);
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
} finally {
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
ready: true
|
||||
});
|
||||
vm.formState.ready = true;
|
||||
}
|
||||
},
|
||||
// beforeRouteUpdate(to, from, next) {
|
||||
// //This triggers a fetch of the data when the ID value changes on the route
|
||||
// //which happens on duplicate, submit new record and change of active record id (backward nav/forward nav etc)
|
||||
// if (to.params.recordid != 0) {
|
||||
// this.getDataFromApi(to.params.recordid);
|
||||
// }
|
||||
// next();
|
||||
// },
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty || JUST_DELETED) {
|
||||
next();
|
||||
|
||||
@@ -286,9 +286,6 @@ export default {
|
||||
loading: false
|
||||
});
|
||||
|
||||
// //bugbug WTF? This doesn't make sense, if it's an attempt to hide delete button then that's wrong
|
||||
// //it's a new record so it can't be deleted so...
|
||||
// vm.rights.delete = false;
|
||||
generateMenu(vm);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user