This commit is contained in:
2021-04-13 23:32:42 +00:00
parent 8fd1023ecc
commit 20f74cd231

View File

@@ -412,26 +412,21 @@ export default {
// ╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝ // ╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝
//walk the tree and save dirty //walk the tree and save dirty
//items in correct order //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; const isPost = vm.obj.id == 0;
let err = { let err = {
fatal: false, //fatal error, further save is pointless, bail early and report 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 header: null, //res.error collections exactly as provided by server to be synthesized later
states: [], states: [],
items: [], items: [],
scheduledUsers: [] 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 //UNSAVED HEADER MUST BE FIRST
//(otherwise there's nothing to hang the other things off of) //(otherwise there's nothing to hang the other things off of)
let headerSaved = false; let headerSaved = false;
@@ -469,7 +464,7 @@ export default {
//############ SAVE GRAPH ############### //############ SAVE GRAPH ###############
//NOTE: Plan is save from top down //NOTE: Plan is save from top down
//HEADER //HEADER
if (!err.fata && !headerSaved) { if (!err.fatal && !headerSaved) {
err = await saveHeader(vm, err); err = await saveHeader(vm, err);
} }
@@ -489,25 +484,28 @@ export default {
} }
//## ALL PARTIAL UPDATES COMPLETED //## ALL PARTIAL UPDATES COMPLETED
//todo: walk the err object extract errors and set for display HERE regardless if fatal or not //handle errors
//todo: how to proceed? if (err.error) {
//if it's a post and partially successful then what? //# FAIL ROUTE
//samesies, if the post partially succeeded that means at least the header succeeded because nothing else would console.log("DISPLAY RES ERROR: ", err);
//so nothing need be done other than route will show weird (0) in address bar, but object is consistent since //TODO: COMPILE ERRORS AND SET THIS
//the concurrency and id would be set on the header // vm.formState.serverError = res.error;
//if its' an update easier to just display and bail otu // window.$gz.form.setErrorBoxErrors(vm);
if (err.fatal) { //TODO: If it's a fatal error set accordingly and bail out here
//save failed fataly so just set the state and bail out // if (err.fatal) {
window.$gz.form.setFormState({ // //save failed fataly so just set the state and bail out
vm: vm, // window.$gz.form.setFormState({
dirty: true, // vm: vm,
valid: false // dirty: true,
}); // valid: false
// });
// }
} else { } else {
//# SUCCESS ROUTE
if (isPost) { if (isPost) {
//nav to id'd url //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({ this.$router.push({
name: "workorder-edit", name: "workorder-edit",
params: { params: {
@@ -759,7 +757,7 @@ async function saveItems(vm) {
} }
//------ //------
//save grandchildren //save grandchildren
err = await saveScheduledUsers(vm, i.err); err = await saveScheduledUsers(vm, i, err);
if (err.fatal) { if (err.fatal) {
return err; return err;
} }
@@ -825,15 +823,6 @@ async function saveScheduledUsers(vm, woitemindex, err) {
//todo: other grandchildren //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 ########################################### //######################################### UTILITY METHODS ###########################################
///////////////////////////// /////////////////////////////
// //