This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user