This commit is contained in:
2021-04-16 22:39:00 +00:00
parent 5783882c02
commit b8453f0aec
2 changed files with 62 additions and 43 deletions

View File

@@ -862,52 +862,66 @@ function handleSaveError(e) {
this.saveResult.errors.push(e);
}
function errorTargetFromSaveResult(r, t) {
//no particular target
//or not a woitem tree error (header)
if (r.itemUid == null || t == null || t == "generalerror") {
return t;
}
let woitemindex = this.obj.items.findIndex(z => z.uid == r.itemUid);
if (woitemindex == -1) {
return null;
}
if (r.childKey == null || r.childUid == null) {
return `Items[${woitemindex}].${t}`;
}
let childindex = this.obj.items[woitemindex][r.childKey].findIndex(
z => z.uid == r.childUid
);
if (childindex == -1) {
return null;
}
return `Items[${woitemindex}].${r.childKey}[${childindex}].${t}`;
}
function formErrorFromSaveResult() {
//digest saveresult and compile into standard form error and return
/**
* {
error: res.error,
itemUid: item.uid, //uid of item
childKey: "scheduledUsers",
childUid: i //uid of child item will be located later as index
}
*
*/
let ret = {
error: {
code: "2200", //todo: maybe an alternate error code and message indicating a package of errors (envelope?)
details: [],
message: "ErrorAPI2200"
}
};
this.saveResult.errors.forEach(z => {
z.error.details.forEach(x => {
let target = errorTargetFromSaveResult(z, x.target);
if (target != null) {
ret.error.details.push({
message: x.message,
error: x.error,
target: target
});
}
});
});
/*
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].estimatedQuantity`
{
"fatal": false,
"error": true,
"header": null,
"states": [],
"items": [
{
"e": {
"code": "2200",
"details": [
{
"message": "SAVE TEST ERROR",
"target": "Notes",
"error": "2203"
}
],
"message": "ErrorAPI2200"
},
"objectIndex": 2
}
],
"scheduledUsers": [
{
"e": {
"code": "2200",
"details": [
{
"message": "◈◈ TEST SAVE ERROR ◈◈",
"target": "EstimatedQuantity",
"error": "2203"
}
],
"message": "ErrorAPI2200"
},
"objectIndex": 0,
"woItemIndex": 3
}
]
}
DESTINATION FORMAT EXAMPLE:
@@ -979,7 +993,6 @@ function formErrorFromSaveResult() {
//iterate saveresult errors and hydrate into a displayable error as expected
//(deal with translate uid's to woitem indexes that still exist)
////set Target properly as requried and push error into the error collection
// this.saveResult.errors;
}
/////////////////////////////