This commit is contained in:
2021-05-17 21:32:14 +00:00
parent bc054ebe90
commit 4590caed1d
2 changed files with 26 additions and 25 deletions

View File

@@ -348,7 +348,7 @@ CURRENTLY DOING: labors
Test by changing customer or contract and save should show new alert notes Test by changing customer or contract and save should show new alert notes
(same as done in svc-workorder.vue line 947 with labor, replicate that shit everywhere) (same as done in svc-workorder.vue line 947 with labor, replicate that shit everywhere)
CHANGED PUT ITEMS: expenses, workorder header, loans,outsideservice,parts, scheduledusers CHANGED PUT ITEMS: header plus all children of woitem but not woitem (only excluded one)
todo: check contract expiry for applying!! todo: check contract expiry for applying!!

View File

@@ -645,11 +645,28 @@ async function saveHeader(vm) {
//} //}
} else { } else {
//update any server changed fields //update any server changed fields
vm.obj.concurrency = res.data.concurrency; //Server will update fields on put or post for most workorder graph objecs so need to update entire object here
vm.obj.isDirty = false; //TODO: update header fields only, not collections here:
//see technique used elsewhere with this same need already done was it woitem??
//get copy of item without child collections for independant submit
//this is it for woitem:
//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);
//vm.obj.items[woItemIndex].labors.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
if (isPost) { if (isPost) {
vm.obj.id = res.data.id;
vm.obj.serial = res.data.serial;
//walk all unsaved direct children and set the workorder id so they can save //walk all unsaved direct children and set the workorder id so they can save
vm.obj.states.forEach(z => (z.workOrderId = vm.obj.id)); vm.obj.states.forEach(z => (z.workOrderId = vm.obj.id));
vm.obj.items.forEach(z => (z.workOrderId = vm.obj.id)); vm.obj.items.forEach(z => (z.workOrderId = vm.obj.id));
@@ -833,16 +850,8 @@ async function saveExpenses(vm, woItemIndex) {
childUid: o.uid childUid: o.uid
}); });
} else { } else {
//update any server changed fields //Server will update fields on put or post for most workorder graph objecs so need to update entire object here
//always updated: vm.obj.items[woItemIndex].expenses.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
o.concurrency = res.data.concurrency;
o.isDirty = false;
//new records only...
if (isPost) {
o.id = res.data.id;
o.workOrderItemId = res.data.workOrderItemId;
}
} }
} }
} }
@@ -875,16 +884,8 @@ async function saveScheduledUsers(vm, woItemIndex) {
childUid: o.uid childUid: o.uid
}); });
} else { } else {
//update any server changed fields //Server will update fields on put or post for most workorder graph objecs so need to update entire object here
//always updated: vm.obj.items[woItemIndex].scheduledUsers.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
o.concurrency = res.data.concurrency;
o.isDirty = false;
//new records only...
if (isPost) {
o.id = res.data.id;
o.workOrderItemId = res.data.workOrderItemId;
}
} }
} }
} }