This commit is contained in:
@@ -171,6 +171,19 @@ export default {
|
||||
|
||||
//IN ADDITION: on submit needs to clear serverErrors
|
||||
|
||||
/*
|
||||
Steps to completion:
|
||||
|
||||
On submit show server errors for fields in their fields, show general errors at the top of form in an error box
|
||||
When a field is edited any *server* errors must clear for that field right away
|
||||
When the form is submitted all server errors cleared if any from previous submit
|
||||
|
||||
|
||||
//example error when submit when there are no roles set at all (blank)
|
||||
//{"error":{"code":"2200","details":[{"code":"2200","message":"","target":"roles","error":"VALIDATION_FAILED"}],"message":"Object did not pass validation"}}
|
||||
|
||||
*/
|
||||
|
||||
if (this.$_.isEmpty(this.serverErrors)) return [];
|
||||
|
||||
if (fieldName == "roles") {
|
||||
@@ -194,31 +207,27 @@ export default {
|
||||
},
|
||||
submit() {
|
||||
// debugger;
|
||||
//Submit the form data to the api
|
||||
|
||||
//Check for broken rules, do not submit with broken rules
|
||||
//No broken rules then:
|
||||
//Gather up the form data into a submitable object (can I just submit the existing object??)
|
||||
//Post it
|
||||
//Update the local object with the returned result
|
||||
//Check the return object for broken rules
|
||||
//TODO: CHECK FOR BROKEN RULES AND DON'T SUBMIT IF THERE ARE ANY HERE
|
||||
|
||||
var that = this;
|
||||
var url = "Widget/" + this.$route.params.id;
|
||||
//clear any errors that might be around from previous submit
|
||||
this.serverErrors = [];
|
||||
this.$gzapi
|
||||
.upsert(url, this.obj)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
//debugger;
|
||||
//Set errors so form can pick them up for controls in canHasServerErrors
|
||||
that.serverErrors = res.error;
|
||||
// that.$refs.form.resetValidation();
|
||||
// that.$refs.form.validate();
|
||||
//example error when submit when there are no roles set at all (blank)
|
||||
//{"error":{"code":"2200","details":[{"code":"2200","message":"","target":"roles","error":"VALIDATION_FAILED"}],"message":"Object did not pass validation"}}
|
||||
//todo: integrate validation error into form so user can see it
|
||||
//User can only submit if no existing errors so should be starting with a clean error free form and then will see validation errors under appropriate fields
|
||||
//if a user makes a change to a control then that control being changed should remove the rule from the server until the next submit happens
|
||||
|
||||
} else {
|
||||
//Logic for detecing if a post or put: if id then it was a post, if no id then it was a put
|
||||
//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.id) {
|
||||
//Handle "post" of new record
|
||||
that.obj = res.data;
|
||||
|
||||
Reference in New Issue
Block a user