This commit is contained in:
2021-05-22 00:15:26 +00:00
parent a4579c93c6
commit 1a3be02aa4
2 changed files with 19 additions and 22 deletions

View File

@@ -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;