From b8453f0aec0e3803c9c582f01fb1a19361277283 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 16 Apr 2021 22:39:00 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 8 ++- ayanova/src/views/svc-workorder.vue | 97 ++++++++++++++++------------- 2 files changed, 62 insertions(+), 43 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index bb4b8acd..408e1c5d 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -110,7 +110,13 @@ todo: remove widget now? Back and front (comment out obvs not remove entirely) ## SERVER MISC ITEMS - +todo: errors are inconsistent some use "error" some use "code" to mean the same thing + this is likely becuase "code" is used in the outer wrapper and "error" is used in the individual "details" validation errors + however it would be much cleaner if it was the same thing at all levels + Settle on "Code" only, change "error" to "code" + some things are producing {message:"blah",target:"blah",error:"blah"} + controller apierror + and validation errors are : {message:"blah", target:"blah", code:"blah"} todo: server boot log should show exact .net framework version in use, currently shows nothing so if there is a bug fix release or something we'd not know for support todo: reconsider "DispatchFull" and "DispatchLimited" roles should be renamed to "ServiceFull" and "ServiceLimited" to match other roles and intent diff --git a/ayanova/src/views/svc-workorder.vue b/ayanova/src/views/svc-workorder.vue index 14317f6a..49d56e2b 100644 --- a/ayanova/src/views/svc-workorder.vue +++ b/ayanova/src/views/svc-workorder.vue @@ -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; } /////////////////////////////