This commit is contained in:
@@ -225,11 +225,14 @@ todo: many biz objects are not using new PUT methodology
|
||||
|
||||
|
||||
|
||||
CURRENTLY DOING: implement actual delete of soft delete, if it works then port up to woitem and then strip out the old delete graph stuff
|
||||
CURRENTLY DOING: save (and delete), then error handling (move to individual saves the formatting / compilation), then resume list
|
||||
|
||||
|
||||
OVERALL
|
||||
ORDERING AND ERRORS
|
||||
- DELETE ISSUE:
|
||||
- if woitem is flagged for delete all children should be as well
|
||||
just flag them in the tree when the woitem is flagged toggle children
|
||||
- SOFT DELETE ISSUE:
|
||||
because it's removing the row on delete but not deleting until save, any errors can't be displayed correctly
|
||||
TODO: move to a "soft delete" get rid of the deleted items separate array
|
||||
|
||||
@@ -248,6 +251,9 @@ OVERALL
|
||||
- load and stress test on client
|
||||
- ## Try to find every thing that will matter when more collections are added now, ensure a full flow from start to stop and everything in between to try to catch any gotchas now before get too deep into it ##
|
||||
|
||||
todo: deleted wo
|
||||
todo: update on save??
|
||||
can it fetch down changes or does that even make sense bandwidth wise
|
||||
|
||||
|
||||
todo: WorkOrderItemTask??
|
||||
|
||||
@@ -427,6 +427,24 @@ export default {
|
||||
scheduledUsers: []
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
On save
|
||||
Save unsaved header
|
||||
Save state if locked
|
||||
Save header
|
||||
Save woitems
|
||||
iterate and deletes woitems first
|
||||
iterate remainding woitems
|
||||
save woitem if dirty or new
|
||||
walk children and call save on each collection
|
||||
childredn then delete first any flagged to delete
|
||||
save second any new or dirty
|
||||
Save state if not saved yet
|
||||
DONE
|
||||
|
||||
*/
|
||||
|
||||
//UNSAVED HEADER MUST BE FIRST
|
||||
//(otherwise there's nothing to hang the other things off of)
|
||||
let headerSaved = false;
|
||||
@@ -447,22 +465,6 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
//############# DELETE GRAPH ###############
|
||||
//NOTE: Plan is delete from bottom up
|
||||
//SCHEDULED USERS
|
||||
if (!err.fatal) {
|
||||
err = await deleteScheduledUsers(vm, err);
|
||||
}
|
||||
|
||||
//todo: other grandchildren
|
||||
|
||||
//WOITEMS
|
||||
if (!err.fatal) {
|
||||
err = await deleteItems(vm, err);
|
||||
}
|
||||
|
||||
//############ SAVE GRAPH ###############
|
||||
//NOTE: Plan is save from top down
|
||||
//HEADER
|
||||
if (!err.fatal && !headerSaved) {
|
||||
err = await saveHeader(vm, err);
|
||||
@@ -487,7 +489,7 @@ export default {
|
||||
//handle errors
|
||||
if (err.error) {
|
||||
//# FAIL ROUTE
|
||||
// console.log("RAW ERROR OBJECT: ", err);
|
||||
// console.log("RAW ERROR OBJECT: ", err);
|
||||
//REHYDRATE ERRORS
|
||||
//convert to form() error handling understood format
|
||||
let compiledError = {
|
||||
@@ -502,6 +504,7 @@ export default {
|
||||
compiledError.details.push(err.state);
|
||||
}
|
||||
|
||||
//##### TODO: Move error compilation into saves, no need for this complex rigamarole
|
||||
//bugbug: details is an array inside so there could be multiple errors for that target so need to iterate it inside the iteration
|
||||
//wouldn't this just be easier to do directly inside the saves themselves??
|
||||
//why compile it at all, why not make it directly ready to display at the end, there's no other use for this info really
|
||||
@@ -783,12 +786,12 @@ async function saveState(vm, err) {
|
||||
// ITEMS
|
||||
//
|
||||
async function deleteItems(vm, err) {
|
||||
if (vm.deletedGraphItems.items.length == 0) {
|
||||
return err;
|
||||
}
|
||||
//walk the array backwards as items may or may not be spliced out
|
||||
for (var i = vm.deletedGraphItems.items.length - 1; i >= 0; i--) {
|
||||
const d = vm.deletedGraphItems.items[i];
|
||||
for (var i = vm.obj.items.length - 1; i >= 0; i--) {
|
||||
const d = vm.obj.items[i];
|
||||
if (!d.deleted) {
|
||||
continue;
|
||||
}
|
||||
let res = await window.$gz.api.remove(`${API_BASE_URL}items/${d.id}`);
|
||||
if (res.error) {
|
||||
err.items.push({
|
||||
@@ -798,18 +801,21 @@ async function deleteItems(vm, err) {
|
||||
});
|
||||
err.error = true;
|
||||
} else {
|
||||
vm.deletedGraphItems.items.splice(i, 1);
|
||||
vm.obj.items.splice(i, 1);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveItems(vm, err) {
|
||||
let totalItems = vm.obj.items.length;
|
||||
if (totalItems == 0) {
|
||||
return true;
|
||||
//DELETE FLAGGED WOITEMS FIRST
|
||||
err = await deleteItems(vm, err);
|
||||
if (err.fatal) {
|
||||
return err;
|
||||
}
|
||||
|
||||
for (let i = 0; i < totalItems; i++) {
|
||||
//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,
|
||||
@@ -873,10 +879,17 @@ async function saveItems(vm, err) {
|
||||
/////////////////////////////
|
||||
// SCHEDULED USERS
|
||||
//
|
||||
async function deleteScheduledUsers(vm, err) {
|
||||
//walk the array backwards as items may or may not be spliced out
|
||||
for (var i = vm.deletedGraphItems.scheduledUsers.length - 1; i >= 0; i--) {
|
||||
const d = vm.deletedGraphItems.scheduledUsers[i];
|
||||
async function deleteScheduledUsers(vm, woItemIndex, err) {
|
||||
//walk the array backwards as items may be spliced out
|
||||
for (
|
||||
var i = vm.obj.items[woItemIndex].scheduledUsers.length - 1;
|
||||
i >= 0;
|
||||
i--
|
||||
) {
|
||||
const d = vm.obj.items[woItemIndex].scheduledUsers[i];
|
||||
if (!d.deleted) {
|
||||
continue;
|
||||
}
|
||||
let res = await window.$gz.api.remove(
|
||||
`${API_BASE_URL}items/scheduledusers/${d.id}`
|
||||
);
|
||||
@@ -888,18 +901,22 @@ async function deleteScheduledUsers(vm, err) {
|
||||
});
|
||||
err.error = true;
|
||||
} else {
|
||||
vm.deletedGraphItems.scheduledUsers.splice(i, 1);
|
||||
vm.obj.items[woItemIndex].scheduledUsers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//----
|
||||
return err;
|
||||
}
|
||||
|
||||
async function saveScheduledUsers(vm, woItemIndex, err) {
|
||||
let totalItems = vm.obj.items[woItemIndex].scheduledUsers.length;
|
||||
if (totalItems == 0) {
|
||||
//DELETE FLAGGED ITEMS FIRST
|
||||
err = await deleteScheduledUsers(vm, woItemIndex, err);
|
||||
if (err.fatal) {
|
||||
return err;
|
||||
}
|
||||
for (let i = 0; i < totalItems; i++) {
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user