diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index bf14c287..0228aae9 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -397,23 +397,6 @@ TODO: V7 features on wo I haven't coded yet UPC select by UPC (just confirm this) -todo: DEFAULT TIME SPAN / AUTO SET workorderitemlabor / scheduled user - - HOW IT SHOULD WORK IN V8 - Existing - update quantity when dates change or update stop date when quantity changes to match - no consideration for global default, once it's made that shit doesn't apply - NEW - First - update global settings, add schedule/labor default minutes and separately Travel default minutes - No auto date set on new, just leave empty - (ONLY IF GLOBAL DEFAULT QTY) enter start date when stop date is null then it will add global default to start and set stop and qty - (ONLY IF GLOBAL DEFAULT QTY) enter stop date when start date is null then it will back calc and set start and qty based on global default - If no global default then it acts like existing and updates qty or stop date when qty changes (if there are dates to go on) - - - - -todo: seeder stock data / translations: loanunit "Units" have extraneous "rate" in them, i.e. "Hourly rate", sb just "Hourly" todo: workorder main data lists, flesh out, finish links from related objects diff --git a/ayanova/src/views/svc-workorder.vue b/ayanova/src/views/svc-workorder.vue index 382abaa9..ed9576fc 100644 --- a/ayanova/src/views/svc-workorder.vue +++ b/ayanova/src/views/svc-workorder.vue @@ -746,21 +746,22 @@ async function saveItems(vm) { //SAVE WOITEMS for (let i = 0; i < vm.obj.items.length; i++) { - //get copy of item without child collections for independant submit - const { - expenses: removedKey1, - labors: removedKey2, - loans: removedKey3, - parts: removedKey4, - partRequests: removedKey5, - scheduledUsers: removedKey6, - tasks: removedKey7, - travels: removedKey8, - units: removedKey9, - outsideServices: removedKey10, - ...o - } = vm.obj.items[i]; - if (o.isDirty) { + if (vm.obj.items[i].isDirty) { + //get copy of item without child collections for independant submit + const { + expenses: removedKey1, + labors: removedKey2, + loans: removedKey3, + parts: removedKey4, + partRequests: removedKey5, + scheduledUsers: removedKey6, + tasks: removedKey7, + travels: removedKey8, + units: removedKey9, + outsideServices: removedKey10, + ...o + } = vm.obj.items[i]; + const isPost = o.id == 0; let res = await window.$gz.api.upsert(`${API_BASE_URL}items`, o); if (res.error) { @@ -823,9 +824,8 @@ async function saveItems(vm) { ); } } - } else { - // Item not dirty skipping save } + //------ //save grandchildren if (!vm.saveResult.fatal) { @@ -902,16 +902,20 @@ async function saveUnits(vm, woItemIndex) { } for (let i = 0; i < vm.obj.items[woItemIndex].units.length; i++) { - let o = vm.obj.items[woItemIndex].units[i]; - if (o.isDirty) { - //const isPost = o.id == 0; + if (vm.obj.items[woItemIndex].units[i].isDirty) { + const o = vm.obj.items[woItemIndex].units[i]; + const uid = o.uid; + //strip out viz fields before sending + o.isDirty = undefined; + o.uid = undefined; + o.unitViz = undefined; let res = await window.$gz.api.upsert(`${API_BASE_URL}items/units`, o); if (res.error) { handleSaveError(vm, { error: res.error, itemUid: vm.obj.items[woItemIndex].uid, childKey: "units", - childUid: o.uid + childUid: uid }); } else { //Server will update fields on put or post for most workorder graph objecs so need to update entire object here @@ -933,10 +937,15 @@ async function saveScheduledUsers(vm, woItemIndex) { } for (let i = 0; i < vm.obj.items[woItemIndex].scheduledUsers.length; i++) { - let o = vm.obj.items[woItemIndex].scheduledUsers[i]; - if (o.isDirty) { - const isPost = o.id == 0; - let res = await window.$gz.api.upsert( + if (vm.obj.items[woItemIndex].scheduledUsers[i].isDirty) { + const o = vm.obj.items[woItemIndex].scheduledUsers[i]; + const uid = o.uid; + //strip out viz fields before sending + o.isDirty = undefined; + o.uid = undefined; + o.serviceRateViz = undefined; + o.userViz = undefined; + const res = await window.$gz.api.upsert( `${API_BASE_URL}items/scheduled-users`, o ); @@ -945,7 +954,7 @@ async function saveScheduledUsers(vm, woItemIndex) { error: res.error, itemUid: vm.obj.items[woItemIndex].uid, childKey: "scheduledUsers", - childUid: o.uid + childUid: uid }); } else { //Server will update fields on put or post for most workorder graph objecs so need to update entire object here @@ -999,16 +1008,22 @@ async function saveTasks(vm, woItemIndex) { } for (let i = 0; i < vm.obj.items[woItemIndex].tasks.length; i++) { - let o = vm.obj.items[woItemIndex].tasks[i]; - if (o.isDirty) { - // const isPost = o.id == 0; - let res = await window.$gz.api.upsert(`${API_BASE_URL}items/tasks`, o); + if (vm.obj.items[woItemIndex].tasks[i].isDirty) { + const o = vm.obj.items[woItemIndex].tasks[i]; + const uid = o.uid; + //strip out viz fields before sending + o.isDirty = undefined; + o.uid = undefined; + o.statusViz = undefined; + o.completedByUserViz = undefined; + + const res = await window.$gz.api.upsert(`${API_BASE_URL}items/tasks`, o); if (res.error) { handleSaveError(vm, { error: res.error, itemUid: vm.obj.items[woItemIndex].uid, childKey: "tasks", - childUid: o.uid + childUid: uid }); } else { //Server will update fields on put or post for most workorder graph objecs so need to update entire object here