From 20f74cd2319e807ecece2bdef527df8b30e9366f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 13 Apr 2021 23:32:42 +0000 Subject: [PATCH] --- ayanova/src/views/svc-workorder.vue | 57 ++++++++++++----------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/ayanova/src/views/svc-workorder.vue b/ayanova/src/views/svc-workorder.vue index 6b014054..2e831186 100644 --- a/ayanova/src/views/svc-workorder.vue +++ b/ayanova/src/views/svc-workorder.vue @@ -412,26 +412,21 @@ 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 //######################################################## const isPost = vm.obj.id == 0; let err = { fatal: false, //fatal error, further save is pointless, bail early and report - error: false, //true if any error regardless if fatal, set by each save / delete + 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: [], items: [], scheduledUsers: [] }; - /* - TODO: collect return errors but continue to try to save unless fatal error then bail - report cumulative errors at end as if a single save - - return object with format: {fatalError:true/false, errors:[collection of errors ]} - - */ - //UNSAVED HEADER MUST BE FIRST //(otherwise there's nothing to hang the other things off of) let headerSaved = false; @@ -469,7 +464,7 @@ export default { //############ SAVE GRAPH ############### //NOTE: Plan is save from top down //HEADER - if (!err.fata && !headerSaved) { + if (!err.fatal && !headerSaved) { err = await saveHeader(vm, err); } @@ -489,25 +484,28 @@ export default { } //## ALL PARTIAL UPDATES COMPLETED - //todo: walk the err object extract errors and set for display HERE regardless if fatal or not - //todo: how to proceed? - //if it's a post and partially successful then what? - //samesies, if the post partially succeeded that means at least the header succeeded because nothing else would - //so nothing need be done other than route will show weird (0) in address bar, but object is consistent since - //the concurrency and id would be set on the header - //if its' an update easier to just display and bail otu + //handle errors + 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); - if (err.fatal) { - //save failed fataly so just set the state and bail out - window.$gz.form.setFormState({ - vm: vm, - dirty: true, - valid: false - }); + //TODO: If it's a fatal error set accordingly and bail out here + // if (err.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) { //nav to id'd url - + //note that an isPost will never be here if there is a fatal error so this is safe to do this.$router.push({ name: "workorder-edit", params: { @@ -759,7 +757,7 @@ async function saveItems(vm) { } //------ //save grandchildren - err = await saveScheduledUsers(vm, i.err); + err = await saveScheduledUsers(vm, i, err); if (err.fatal) { return err; } @@ -825,15 +823,6 @@ async function saveScheduledUsers(vm, woitemindex, err) { //todo: other grandchildren -// ///////////////////////////// -// // Error display -// // -// function displayResError(vm, res) { -// console.log("DISPLAY RES ERROR: ", res); -// vm.formState.serverError = res.error; -// window.$gz.form.setErrorBoxErrors(vm); -// } - //######################################### UTILITY METHODS ########################################### ///////////////////////////// //