This commit is contained in:
@@ -422,7 +422,7 @@ export default {
|
||||
fatal: false, //fatal error, further save is pointless, bail early and report
|
||||
error: false, //true if any error to be displayed regardless if fatal, set by each save / delete
|
||||
header: null, //res.error collections exactly as provided by server to be synthesized later
|
||||
states: [],
|
||||
state: null, //only saves one state at a time never more than one so this is like header a singleton
|
||||
items: [],
|
||||
scheduledUsers: []
|
||||
};
|
||||
@@ -488,9 +488,102 @@ export default {
|
||||
if (err.error) {
|
||||
//# FAIL ROUTE
|
||||
console.log("DISPLAY RES ERROR: ", err);
|
||||
//TODO: COMPILE ERRORS AND SET THIS
|
||||
// vm.formState.serverError = res.error;
|
||||
// window.$gz.form.setErrorBoxErrors(vm);
|
||||
//REHYDRATE ERRORS
|
||||
//convert to form() error handling understood format
|
||||
let compiledError = {
|
||||
code: "2200",
|
||||
message: "ErrorAPI2200",
|
||||
details: []
|
||||
};
|
||||
if (err.header != null) {
|
||||
compiledError.details.push(err.header);
|
||||
}
|
||||
if (err.state != null) {
|
||||
compiledError.details.push(err.state);
|
||||
}
|
||||
err.items.forEach(z =>
|
||||
compiledError.details.push({
|
||||
message: z.e.details.message,
|
||||
error: z.e.details.error,
|
||||
target: `Items[${z.objectIndex}].${z.e.details.target}`
|
||||
})
|
||||
);
|
||||
|
||||
err.scheduledUsers.forEach(z =>
|
||||
compiledError.details.push({
|
||||
message: z.e.details.message,
|
||||
error: z.e.details.error,
|
||||
target: `Items[${z.woItemIndex}].scheduledUsers[${z.objectIndex}].${z.e.details.target}`
|
||||
})
|
||||
);
|
||||
|
||||
vm.formState.serverError = compiledError;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
|
||||
/*
|
||||
`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:
|
||||
error: {
|
||||
code: "2200",
|
||||
details: [
|
||||
{
|
||||
message:
|
||||
"LT:PurchaseOrderReceiptItemQuantityReceivedErrorInvalid",
|
||||
target: "Items[1].QuantityReceived",
|
||||
error: "2203"
|
||||
},
|
||||
{
|
||||
message:
|
||||
"LT:PurchaseOrderReceiptItemQuantityReceivedErrorInvalid",
|
||||
target: "Items[3].QuantityReceived",
|
||||
error: "2203"
|
||||
}
|
||||
],
|
||||
message: "ErrorAPI2200"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//TODO: If it's a fatal error set accordingly and bail out here
|
||||
// if (err.fatal) {
|
||||
@@ -668,7 +761,7 @@ async function saveState(vm, err) {
|
||||
//it's new so save it
|
||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}states`, o);
|
||||
if (res.error) {
|
||||
err.states.push(res.error); //only saves one at a time so no need for collection stuff here
|
||||
err.states = res.error; //only saves one at a time so no need for collection stuff here
|
||||
err.error = true;
|
||||
} else {
|
||||
vm.obj.states[i] = res.data;
|
||||
|
||||
Reference in New Issue
Block a user