This commit is contained in:
@@ -32,9 +32,10 @@ FIX:
|
|||||||
- DONE whole object ones at top
|
- DONE whole object ones at top
|
||||||
- Server form validation errors cleared in individual inputs upon any change to them (but form overall ones stay until submitted)
|
- Server form validation errors cleared in individual inputs upon any change to them (but form overall ones stay until submitted)
|
||||||
- ###### HERE!!!!!!!!
|
- ###### HERE!!!!!!!!
|
||||||
- Current issue: can't seem to remove the error from the control
|
- Current issue: Found a way to trigger clearing but
|
||||||
- The code to remove the server error from the data works fine, however it doesn't update the control and remove the server error until I edit any field to trigger validation again
|
- does it cause excessive re-validation??
|
||||||
- Possible solutions:
|
- Remove server errors entirely if they were only related to the fields that are now removed from the details collection
|
||||||
|
- NOT NEEDED? - Possible solutions to old problem of not removing old server validation msgs:
|
||||||
- LAST DITCH BEFORE ABANDONING THIS SYSTEM: Try making the whole form validate in the component and separately in gzvalidate
|
- LAST DITCH BEFORE ABANDONING THIS SYSTEM: Try making the whole form validate in the component and separately in gzvalidate
|
||||||
- Move all server errors to the server error box and don't put them into the fields local validation errors (keep the two separate and try to avoid as many server errors as possible)
|
- Move all server errors to the server error box and don't put them into the fields local validation errors (keep the two separate and try to avoid as many server errors as possible)
|
||||||
- This might make sense since in reality we should almost never see a server error for a field unless a complex business rule is being broken or something, low level validation should handle it at the form level
|
- This might make sense since in reality we should almost never see a server error for a field unless a complex business rule is being broken or something, low level validation should handle it at the form level
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
//import _ from "../libs/lodash.min.js";
|
//import _ from "../libs/lodash.min.js";
|
||||||
import errorHandler from "./errorhandler";
|
import errorHandler from "./errorhandler";
|
||||||
|
|
||||||
|
var triggeringChange = false;
|
||||||
|
|
||||||
function isEmpty(o) {
|
function isEmpty(o) {
|
||||||
if (typeof o == "number" && o == 0) {
|
if (typeof o == "number" && o == 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -472,24 +474,44 @@ Here are all the API level error codes that can be returned by the API server:
|
|||||||
// On Change handler
|
// On Change handler
|
||||||
// This is required so that server errors can be cleared when input is changed
|
// This is required so that server errors can be cleared when input is changed
|
||||||
Change(v, ref) {
|
Change(v, ref) {
|
||||||
|
if (triggeringChange) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//If ref appears in the servererrors details collection, remove each one
|
//If ref appears in the servererrors details collection, remove each one
|
||||||
var m = v.$_.remove(v.serverError.details, function(o) {
|
var m = v.$_.remove(v.serverError.details, function(o) {
|
||||||
return o.target == ref;
|
return o.target == ref;
|
||||||
});
|
});
|
||||||
|
|
||||||
// //if a target was hit then need to trigger validate again for it to remove the error message
|
//If there are no more errors in details then remove the whole thing as it's no longer required
|
||||||
//NOTHING SEEMS TO BE ABLE TO TRIGGER THIS
|
if (v.serverError.details && v.serverError.details.length < 1) {
|
||||||
|
if (v.serverError.code == "2200") {
|
||||||
// if (m.length > 0) {
|
this.RemoveAllProperties(v.serverError);
|
||||||
// var ctrl = getControl(v, ref);
|
}
|
||||||
// //ctrl.validate(true);
|
}
|
||||||
// // ctrl.errorMessages.length=0;
|
|
||||||
|
|
||||||
// // var frm=getControl(v,"form");
|
|
||||||
// // frm.validate();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Clear out old validation display in form by forcing the control's data to change
|
||||||
|
//I tried calling form validate and reset and all that bullshit but it did nothing
|
||||||
|
//probably because it has safeguards to prevent excess validation, this works though so far
|
||||||
|
//I added the triggering change guard but it actually doesn't seem to be required here, more investigation is required
|
||||||
|
if (m.length > 0) {
|
||||||
|
triggeringChange = true;
|
||||||
|
var val = v.obj[ref];
|
||||||
|
v.obj[ref] = null;
|
||||||
|
v.obj[ref] = val;
|
||||||
|
triggeringChange = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
///////////////////////////////
|
||||||
|
// Clean out server errors
|
||||||
|
// This is called both from the form immediately before submit and here in Change handler
|
||||||
|
// It's purpose is to more efficiently clear out the object even though I could set it to an empty object, this way it just keeps the same object
|
||||||
|
// avoiding some potential issues
|
||||||
|
RemoveAllProperties(o) {
|
||||||
|
//clear any errors that might be around from previous submit
|
||||||
|
for (var variableKey in o) {
|
||||||
|
if (o.hasOwnProperty(variableKey)) {
|
||||||
|
delete o[variableKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -184,6 +184,9 @@ export default {
|
|||||||
//debugger;
|
//debugger;
|
||||||
//console.log("CHANGE - " + ref);
|
//console.log("CHANGE - " + ref);
|
||||||
this.$gzv.Change(this, ref);
|
this.$gzv.Change(this, ref);
|
||||||
|
//Make form re-validate here and if it works then make it do it only if gzv.change returns true or something indicating it's required to re-validate or clear that input's errors
|
||||||
|
// this.$refs.form.resetValidation();
|
||||||
|
// this.$refs.form.validate();
|
||||||
},
|
},
|
||||||
getDataFromApi() {
|
getDataFromApi() {
|
||||||
var url = "Widget/" + this.$route.params.id;
|
var url = "Widget/" + this.$route.params.id;
|
||||||
@@ -200,11 +203,7 @@ export default {
|
|||||||
var url = "Widget/" + this.$route.params.id;
|
var url = "Widget/" + this.$route.params.id;
|
||||||
|
|
||||||
//clear any errors that might be around from previous submit
|
//clear any errors that might be around from previous submit
|
||||||
for (var variableKey in this.serverError) {
|
this.$gzv.RemoveAllProperties(this.serverError);
|
||||||
if (this.serverError.hasOwnProperty(variableKey)) {
|
|
||||||
delete this.serverError[variableKey];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$gzapi
|
this.$gzapi
|
||||||
.upsert(url, this.obj)
|
.upsert(url, this.obj)
|
||||||
@@ -215,8 +214,6 @@ export default {
|
|||||||
that.serverError = res.error;
|
that.serverError = res.error;
|
||||||
// that.$refs.form.resetValidation();
|
// that.$refs.form.resetValidation();
|
||||||
// that.$refs.form.validate();
|
// 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"}}
|
|
||||||
} else {
|
} else {
|
||||||
//Logic for detecting 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) {
|
if (res.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user