This commit is contained in:
@@ -14,6 +14,14 @@ TODO CLIENT STUFF
|
||||
|
||||
TODO NEXT
|
||||
|
||||
Issues:
|
||||
|
||||
won't show multiple lines in v-alert from my code but will if static element with <br/> at end of each line
|
||||
Not sure this is the correct approach, it's needing to iterate the return error object multiple times which is a code smell
|
||||
- Once to see if there are errors and another time to build up the errors
|
||||
- Maybe it should be called once only as a method after the server returns the results and the gzvalidate populates a key on the data object in the form which in turn drives the error box?
|
||||
|
||||
|
||||
|
||||
|
||||
Get broken server rule to display in vue properly
|
||||
@@ -39,6 +47,10 @@ Simulate server broken rules so can integrate into ui and rule system
|
||||
- Test on mobile and desktop all browsers before moving on, it must be solid with error handling (required, after before etc) and etc and then if all is well we can move on to the other field types
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DON'T code the user options with the currency symbol etc until after it's all been worked out client side. Use static values instad in locale.
|
||||
Locale should fetch those settings the first time it sees they are not present so that they are refreshed upon use and are not stored in localstorage
|
||||
(or should they be? anyway, can work that out later)
|
||||
|
||||
@@ -328,27 +328,37 @@ Here are all the API level error codes that can be returned by the API server:
|
||||
|
||||
var apiErrorCode = parseInt(v.serverError.code);
|
||||
|
||||
//OBJECT ERROR
|
||||
if (ref == "apierrors" && apiErrorCode < 2201) {
|
||||
//we have a general error, format for return
|
||||
// "ErrorFieldValueNotInteger": "Value must be an integer"
|
||||
//TODO: This logic is faulty, there could be overall errors that are not field specific, however there are also field ones that trigger overall errors.
|
||||
//Keep top part if statement for gathering all overall errors, but then also run the field errors block and check for field errors where "target" is empty and add them in to the return as well
|
||||
|
||||
//GENERAL ERROR
|
||||
if (ref == "errorbox") {
|
||||
//Add any general errors to ret
|
||||
var err = v.$gzlocale.get("ErrorAPI" + apiErrorCode.toString());
|
||||
if (v.serverError.message) {
|
||||
err = err + "\r\n" + v.serverError.message;
|
||||
}
|
||||
ret = [err];
|
||||
} else {
|
||||
//FIELD ERROR
|
||||
ret.push(err);
|
||||
}
|
||||
//DETAIL ERRORS
|
||||
//{"error":{"code":"2200","details":[{"message":"Exception: Error converting value \"\" to type 'AyaNova.Biz.AuthorizationRoles'. Path 'roles', line 1, position 141.","target":"roles","error":"2203"}],"message":"Object did not pass validation"}}
|
||||
//Specific field validation errors are in an array in "details" key
|
||||
if (!v.$_.isEmpty(v.serverError.details)) {
|
||||
//See if this key is in the details array
|
||||
var errorsForField = v.$_.filter(v.serverError.details, {
|
||||
var errorsForField = [];
|
||||
|
||||
if (ref == "errorbox") {
|
||||
errorsForField = v.$_.filter(v.serverError.details, function(o) {
|
||||
return !o.target;
|
||||
});
|
||||
} else {
|
||||
errorsForField = v.$_.filter(v.serverError.details, {
|
||||
target: ref
|
||||
});
|
||||
}
|
||||
|
||||
if (errorsForField.length > 0) {
|
||||
var allFldErrors = "";
|
||||
//iterate the errorsForField objects, build a return message for each error separated by a newline and Bob's your lobster
|
||||
//iterate the errorsForField object and add each to return array of errors
|
||||
v.$_.each(errorsForField, function(ve) {
|
||||
var fldErr = "";
|
||||
var fldErrorCode = parseInt(ve.error);
|
||||
@@ -358,24 +368,18 @@ Here are all the API level error codes that can be returned by the API server:
|
||||
ve.error +
|
||||
"]";
|
||||
if (ve.message) {
|
||||
fldErr += " - \"" + ve.message + "\"";
|
||||
fldErr += ' - "' + ve.message + '"';
|
||||
}
|
||||
allFldErrors += fldErr + "\n";
|
||||
ret.push(fldErr);
|
||||
});
|
||||
|
||||
return allFldErrors.trimRight("\n");
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
if (v.$gzdevmode()) {
|
||||
throw "DEV ERROR gzvalidate::ServerErrors -> on field validation error no 'details' key was found to show which field had the error";
|
||||
}
|
||||
}
|
||||
|
||||
//example
|
||||
if (ref == "xroles") {
|
||||
return ["Test error from GZVALIDATE::ServerErrors"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//default if no error message to display
|
||||
@@ -399,5 +403,22 @@ Here are all the API level error codes that can be returned by the API server:
|
||||
// var err = v.$gzlocale.get("ErrorFieldValueNotInteger");
|
||||
|
||||
// return err;
|
||||
},
|
||||
///////////////////////////////
|
||||
// ERROR BOX ERRORS
|
||||
// displays any messages for error box on form which is the generic catch all for non field specific errors from server
|
||||
ErrorBoxErrors(v) {
|
||||
var errs = this.ServerErrors(v, "errorbox");
|
||||
if (errs.length < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var ret = "";
|
||||
//loop array and append each error to a return string
|
||||
for (var i = 0; i < errs.length; i++) {
|
||||
ret += errs[i] + "\r\n";
|
||||
}
|
||||
ret=ret.replace("\r\n"," <br/> ");
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,6 +3,31 @@
|
||||
<v-flex>
|
||||
<v-form ref="form">
|
||||
<v-layout align-center justify-left row wrap>
|
||||
<v-flex xs12 px-2>
|
||||
<v-alert
|
||||
color="warning"
|
||||
icon="fa-exclamation-circle "
|
||||
value="true"
|
||||
transition="scale-transition"
|
||||
outline
|
||||
>
|
||||
|
||||
line one<br/>
|
||||
line two
|
||||
|
||||
</v-alert>
|
||||
</v-flex>
|
||||
<v-flex xs12 px-2>
|
||||
<v-alert
|
||||
ref="errorbox"
|
||||
v-show="this.$gzv.ErrorBoxErrors(this)"
|
||||
color="error"
|
||||
icon="fa-exclamation-circle "
|
||||
value="true"
|
||||
transition="scale-transition"
|
||||
outline
|
||||
>{{this.$gzv.ErrorBoxErrors(this)}}</v-alert>
|
||||
</v-flex>
|
||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||
<v-text-field
|
||||
v-model="obj.name"
|
||||
|
||||
Reference in New Issue
Block a user