This commit is contained in:
@@ -193,6 +193,47 @@ export default {
|
||||
//nothing to scan here just set form dirty
|
||||
this.formState.dirty = true;
|
||||
enableSaveButton();
|
||||
},
|
||||
submit() {
|
||||
var vm = this;
|
||||
var url = API_BASE_URL + this.$route.params.id;
|
||||
|
||||
//clear any errors vm might be around from previous submit
|
||||
window.$gz.form.deleteAllErrorBoxErrors(this);
|
||||
window.$gz.api
|
||||
.upsert(url, this.obj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error != undefined) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
|
||||
if (res.data.id) {
|
||||
//Handle "post" of new record (CREATE)
|
||||
vm.obj = res.data;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
readOnly: res.readOnly ? true : false
|
||||
});
|
||||
|
||||
//change url to new record but don't actually navigate, replace current url with same url but with the actual id at the end instead of zero:
|
||||
vm.$router.replace(vm.$route.fullPath.slice(0, -1) + res.data.id);
|
||||
} else {
|
||||
//Handle "put" of an existing record (UPDATE)
|
||||
vm.obj.concurrencyToken = res.data.concurrencyToken;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function handleSubmitError(error) {
|
||||
vm.formState.loading = false;
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user