This commit is contained in:
@@ -397,23 +397,6 @@ TODO: V7 features on wo I haven't coded yet
|
|||||||
UPC select by UPC (just confirm this)
|
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
|
todo: workorder main data lists, flesh out, finish links from related objects
|
||||||
|
|
||||||
|
|||||||
@@ -746,21 +746,22 @@ async function saveItems(vm) {
|
|||||||
|
|
||||||
//SAVE WOITEMS
|
//SAVE WOITEMS
|
||||||
for (let i = 0; i < vm.obj.items.length; i++) {
|
for (let i = 0; i < vm.obj.items.length; i++) {
|
||||||
//get copy of item without child collections for independant submit
|
if (vm.obj.items[i].isDirty) {
|
||||||
const {
|
//get copy of item without child collections for independant submit
|
||||||
expenses: removedKey1,
|
const {
|
||||||
labors: removedKey2,
|
expenses: removedKey1,
|
||||||
loans: removedKey3,
|
labors: removedKey2,
|
||||||
parts: removedKey4,
|
loans: removedKey3,
|
||||||
partRequests: removedKey5,
|
parts: removedKey4,
|
||||||
scheduledUsers: removedKey6,
|
partRequests: removedKey5,
|
||||||
tasks: removedKey7,
|
scheduledUsers: removedKey6,
|
||||||
travels: removedKey8,
|
tasks: removedKey7,
|
||||||
units: removedKey9,
|
travels: removedKey8,
|
||||||
outsideServices: removedKey10,
|
units: removedKey9,
|
||||||
...o
|
outsideServices: removedKey10,
|
||||||
} = vm.obj.items[i];
|
...o
|
||||||
if (o.isDirty) {
|
} = vm.obj.items[i];
|
||||||
|
|
||||||
const isPost = o.id == 0;
|
const isPost = o.id == 0;
|
||||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}items`, o);
|
let res = await window.$gz.api.upsert(`${API_BASE_URL}items`, o);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
@@ -823,9 +824,8 @@ async function saveItems(vm) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Item not dirty skipping save
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------
|
//------
|
||||||
//save grandchildren
|
//save grandchildren
|
||||||
if (!vm.saveResult.fatal) {
|
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++) {
|
for (let i = 0; i < vm.obj.items[woItemIndex].units.length; i++) {
|
||||||
let o = vm.obj.items[woItemIndex].units[i];
|
if (vm.obj.items[woItemIndex].units[i].isDirty) {
|
||||||
if (o.isDirty) {
|
const o = vm.obj.items[woItemIndex].units[i];
|
||||||
//const isPost = o.id == 0;
|
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);
|
let res = await window.$gz.api.upsert(`${API_BASE_URL}items/units`, o);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
handleSaveError(vm, {
|
handleSaveError(vm, {
|
||||||
error: res.error,
|
error: res.error,
|
||||||
itemUid: vm.obj.items[woItemIndex].uid,
|
itemUid: vm.obj.items[woItemIndex].uid,
|
||||||
childKey: "units",
|
childKey: "units",
|
||||||
childUid: o.uid
|
childUid: uid
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
|
//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++) {
|
for (let i = 0; i < vm.obj.items[woItemIndex].scheduledUsers.length; i++) {
|
||||||
let o = vm.obj.items[woItemIndex].scheduledUsers[i];
|
if (vm.obj.items[woItemIndex].scheduledUsers[i].isDirty) {
|
||||||
if (o.isDirty) {
|
const o = vm.obj.items[woItemIndex].scheduledUsers[i];
|
||||||
const isPost = o.id == 0;
|
const uid = o.uid;
|
||||||
let res = await window.$gz.api.upsert(
|
//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`,
|
`${API_BASE_URL}items/scheduled-users`,
|
||||||
o
|
o
|
||||||
);
|
);
|
||||||
@@ -945,7 +954,7 @@ async function saveScheduledUsers(vm, woItemIndex) {
|
|||||||
error: res.error,
|
error: res.error,
|
||||||
itemUid: vm.obj.items[woItemIndex].uid,
|
itemUid: vm.obj.items[woItemIndex].uid,
|
||||||
childKey: "scheduledUsers",
|
childKey: "scheduledUsers",
|
||||||
childUid: o.uid
|
childUid: uid
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
|
//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++) {
|
for (let i = 0; i < vm.obj.items[woItemIndex].tasks.length; i++) {
|
||||||
let o = vm.obj.items[woItemIndex].tasks[i];
|
if (vm.obj.items[woItemIndex].tasks[i].isDirty) {
|
||||||
if (o.isDirty) {
|
const o = vm.obj.items[woItemIndex].tasks[i];
|
||||||
// const isPost = o.id == 0;
|
const uid = o.uid;
|
||||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}items/tasks`, o);
|
//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) {
|
if (res.error) {
|
||||||
handleSaveError(vm, {
|
handleSaveError(vm, {
|
||||||
error: res.error,
|
error: res.error,
|
||||||
itemUid: vm.obj.items[woItemIndex].uid,
|
itemUid: vm.obj.items[woItemIndex].uid,
|
||||||
childKey: "tasks",
|
childKey: "tasks",
|
||||||
childUid: o.uid
|
childUid: uid
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
|
//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