This commit is contained in:
@@ -406,7 +406,7 @@ export default {
|
||||
vm: vm,
|
||||
loading: true
|
||||
});
|
||||
//const url = API_BASE_URL; // + vm.$route.params.recordid;
|
||||
|
||||
//clear any errors vm might be around from previous submit
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
@@ -417,39 +417,14 @@ export default {
|
||||
// ╚════██║██╔══██║╚██╗ ██╔╝██╔══╝
|
||||
// ███████║██║ ██║ ╚████╔╝ ███████╗
|
||||
// ╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝
|
||||
//walk the tree and save dirty
|
||||
//items in correct order
|
||||
//save up errors for each separate save then synthesize
|
||||
//into a single error collection for display as normal
|
||||
//########################################################
|
||||
|
||||
// //first of all reset all selections (toggle) so that children aren't stuck with an active item that is going to be deleted
|
||||
// this.resetSelections = !this.resetSelections;
|
||||
|
||||
const isPost = vm.obj.id == 0;
|
||||
|
||||
//reset error object
|
||||
this.saveResult.fatal = false;
|
||||
this.saveResult.errors = null;
|
||||
|
||||
/*
|
||||
|
||||
On save
|
||||
Save unsaved header
|
||||
Save state if locked
|
||||
Save header
|
||||
Save woitems
|
||||
iterate and deletes woitems first
|
||||
iterate remainding woitems
|
||||
save woitem if dirty or new
|
||||
walk children and call save on each collection
|
||||
childredn then delete first any flagged to delete
|
||||
save second any new or dirty
|
||||
Save state if not saved yet
|
||||
DONE
|
||||
|
||||
*/
|
||||
|
||||
//UNSAVED HEADER MUST BE FIRST
|
||||
//(otherwise there's nothing to hang the other things off of)
|
||||
let headerSaved = false;
|
||||
@@ -496,19 +471,8 @@ export default {
|
||||
//handle errors
|
||||
if (this.saveResult.errors != null) {
|
||||
//# FAIL ROUTE
|
||||
|
||||
vm.formState.serverError = formErrorFromSaveResult(this);
|
||||
vm.formState.serverError = formErrorFromSaveResult(this); //this is the bit that triggers field and row errors to display as they pickup from this setting
|
||||
window.$gz.form.setErrorBoxErrors(vm); //set generalerror errors in error box at top, not related to form field errors which happen alternatively based on formState.serverError which is confusing
|
||||
|
||||
//TODO: If it's a fatal error set accordingly and bail out here
|
||||
// if (this.saveResult.fatal) {
|
||||
// //save failed fataly so just set the state and bail out
|
||||
// window.$gz.form.setFormState({
|
||||
// vm: vm,
|
||||
// dirty: true,
|
||||
// valid: false
|
||||
// });
|
||||
// }
|
||||
} else {
|
||||
//# SUCCESS ROUTE
|
||||
if (isPost) {
|
||||
@@ -846,16 +810,8 @@ async function saveScheduledUsers(vm, woItemIndex) {
|
||||
//######################################### UTILITY METHODS ###########################################
|
||||
|
||||
function handleSaveError(vm, e) {
|
||||
//TODO: decide if fatal here and set accordingly
|
||||
/**
|
||||
* {
|
||||
error: res.error,
|
||||
itemUid: item.uid, //uid of item
|
||||
childKey: "scheduledUsers",
|
||||
childUid: i //uid of child item will be located later as index
|
||||
}
|
||||
*
|
||||
*/
|
||||
//### NOTE: Nothing using FATAL yet, but if necessary here is where it should be determined and set
|
||||
|
||||
if (vm.saveResult.errors == null) {
|
||||
vm.saveResult.errors = [];
|
||||
}
|
||||
@@ -888,18 +844,20 @@ function errorTargetFromSaveResult(vm, r, t) {
|
||||
}
|
||||
|
||||
function formErrorFromSaveResult(vm) {
|
||||
//digest saveresult and compile into standard form error and return
|
||||
/**
|
||||
/**
|
||||
* convention:
|
||||
* {
|
||||
error: res.error,
|
||||
itemUid: item.uid, //uid of item
|
||||
itemUid: item.uid, //uid of item none means it's a header error
|
||||
childKey: "scheduledUsers",
|
||||
childUid: i //uid of child item will be located later as index
|
||||
}
|
||||
*
|
||||
*/
|
||||
//Note: re code 2200 hard coded here below -- if for some reason it becomes necessary there is the idea of making an envelope error to contain variety of errors,
|
||||
//but so far I think they are all server errors (that go in the error box) or validation errors that work here
|
||||
let ret = {
|
||||
code: "2200", //todo: maybe an alternate error code and message indicating a package of errors (envelope?)
|
||||
code: "2200",
|
||||
details: [],
|
||||
message: "ErrorAPI2200"
|
||||
};
|
||||
@@ -918,96 +876,6 @@ function formErrorFromSaveResult(vm) {
|
||||
|
||||
console.log(Object.assign({}, ret));
|
||||
return ret;
|
||||
|
||||
/*
|
||||
source: {"fatal":false,"errors":[{"error":{"code":"2200","details":[{"message":"SAVE TEST ERROR","target":"Notes","error":"2203"}],"message":"ErrorAPI2200"},"itemUid":0}]}
|
||||
result: {"error":{"code":"2200","details":[{"message":"SAVE TEST ERROR","error":"2203","target":"Items[0].Notes"}],"message":"ErrorAPI2200"}}
|
||||
|
||||
{"error":{"code":"2200","details":[{"message":"SAVE TEST ERROR","target":"Notes","error":"2203"}],"message":"ErrorAPI2200"}
|
||||
{"error":{"code":"2200","details":[{"message":"SAVE TEST ERROR","error":"2203","target":"Items[0].Notes"}],"message":"ErrorAPI2200"}}
|
||||
|
||||
{error: {code: "2200",details: [{ message: "SAVE TEST ERROR", target: "Notes", error: "2203" }],message: "ErrorAPI2200"}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].estimatedQuantity`
|
||||
|
||||
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
e:{
|
||||
fatal:true/false,//override, normally this function would determine this on it's own
|
||||
error:res.error,//server error
|
||||
itemUid:null,//if has parent woitem this is its UID which is used to determine actual index
|
||||
childKey:"scheduledUsers"/"Items",//name of child collection
|
||||
childIndex:null,//if it's a child this is the index
|
||||
}
|
||||
|
||||
//old compiledError code
|
||||
err.items.forEach(z =>
|
||||
compiledError.details.push({
|
||||
message: z.e.details[0].message,
|
||||
error: z.e.details[0].error,
|
||||
target: `Items[${z.objectIndex}].${z.e.details[0].target}`
|
||||
})
|
||||
);
|
||||
|
||||
err.scheduledUsers.forEach(z =>
|
||||
compiledError.details.push({
|
||||
message: z.e.details[0].message,
|
||||
error: z.e.details[0].error,
|
||||
target: `Items[${z.woItemIndex}].scheduledUsers[${z.objectIndex}].${z.e.details[0].target}`
|
||||
})
|
||||
);
|
||||
|
||||
//Goes into this.saveResult.errors ultimately
|
||||
saveResult: {
|
||||
fatal: false, //fatal error, further save is pointless, bail early and report
|
||||
error: null //contains error object
|
||||
}
|
||||
|
||||
|
||||
|
||||
//bugbug: details is an array inside so there could be multiple errors for that target so need to iterate it inside the iteration
|
||||
//bugbug: on a server error there is no details so dont' code to expect it
|
||||
/*i.e.
|
||||
{
|
||||
error: {
|
||||
code: "2002",
|
||||
message: "See server log for details",
|
||||
target: "Server internal error"
|
||||
}
|
||||
}
|
||||
*/
|
||||
//TODO: compile is back on the menu
|
||||
//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
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
@@ -1027,9 +895,6 @@ function updateRights(vm, forceGenerateMenu) {
|
||||
if (readOnlyBefore != vm.formState.readOnly || forceGenerateMenu === true) {
|
||||
generateMenu(vm);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user