From 1a3be02aa4c27b0546e1f426c5fd86c07e030031 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 22 May 2021 00:15:26 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 5 +++- ayanova/src/views/svc-workorder.vue | 36 ++++++++++++----------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 28a970ce..b2ae04c6 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -339,7 +339,9 @@ todo: many biz objects are not using new PUT methodology -CURRENTLY DOING: WorkOrderItemTravel +CURRENTLY DOING: bugbug: saving header only (setting onsite for example) is triggering a full fetch of entire workorder every time...WTF, supposed to be just a few fields that cause that + +Next: WorkOrderItemTravel ORDER: Travel, tasks, parts, loans, units, outside service @@ -353,6 +355,7 @@ todo: "DispatchFull" and "DispatchLimited" roles MUST be renamed to "ServiceFull Rename at both ends and all translations and docs as well. todo: strip all *viz fields from object before sending over the wire from client to server + Setting their value to undefined stops them being sent so do that, but remember they then need to be updated on the return record TODO: test new from scratch wo regularly diff --git a/ayanova/src/views/svc-workorder.vue b/ayanova/src/views/svc-workorder.vue index e1ea7450..232fe030 100644 --- a/ayanova/src/views/svc-workorder.vue +++ b/ayanova/src/views/svc-workorder.vue @@ -371,6 +371,7 @@ export default { window.$gz.form.setErrorBoxErrors(vm); } else { vm.obj = res.data; + vm.lastGetContractId = vm.obj.contractId; //preserve for triggering full update if something changes it later vm.lastGetCustomerId = vm.obj.customerId; //preserve for triggering full update if something changes it later @@ -527,8 +528,8 @@ export default { //check if full refresh is necessary if ( - vm.obj.contractId != vm.obj.lastGetContractId || - vm.obj.customerId != vm.obj.lastGetCustomerId + vm.obj.contractId != vm.lastGetContractId || + vm.obj.customerId != vm.lastGetCustomerId ) { //there may be others which is why I'm doing it this way with the extra variable forceFullRefresh = true; @@ -654,35 +655,28 @@ async function saveHeader(vm) { //https://stackoverflow.com/a/58206483/8939 const { items: removedKey1, states: removedKey2, ...headerOnly } = vm.obj; + //remove *Viz keys so they don't generate traffic + headerOnly.alertViz = undefined; + headerOnly.projectViz = undefined; + headerOnly.contractViz = undefined; + headerOnly.customerViz = undefined; + let res = await window.$gz.api.upsert(`${API_BASE_URL}`, headerOnly); if (res.error) { - //if (isPost) { //NO IDEA WHY THIS WAS HERE< NEEDS REVISIT PROBABLY handleSaveError(vm, { fatal: true, error: res.error }); - // }else - //{ - - //} } else { //update any server changed fields vm.obj.concurrency = res.data.concurrency; vm.obj.isDirty = false; - vm.obj.alertViz = res.data.alertViz; + vm.obj.customerId = res.data.customerId; vm.obj.contractId = res.data.contractId; //may or may not have changed at server, this will ensure entire ui gets updated if it has as all prices may have changed and other stuff - // //this sets 'o' to all values in assigned *except* the ones itemized with removedKey which is a fake key and just used for this trick to work - // //as undefined won't - // console.log("Header save, return data is: ", res.data); - // //copy return data into a variable called 'o' but exclude states and items keys - // const { states: removedKey1, items: removedKey2, ...o } = res.data; - - // console.log("Header save, o is: ", o); - - // //now we can set the header to o safely without wiping the child collections - // //this will only copy the existing properties in o to vm.obj - // Object.assign(vm.obj, o); - - // console.log("Header save, vm.obj is: ", vm.obj); + //repopulate *viz fields from return value + vm.obj.alertViz = res.data.alertViz; + vm.obj.projectViz = res.data.projectViz; + vm.obj.contractViz = res.data.contractViz; + vm.obj.customerViz = res.data.customerViz; if (isPost) { vm.obj.id = res.data.id;