This commit is contained in:
@@ -373,7 +373,6 @@ export default {
|
|||||||
z.outsideServices.forEach((x, index) => (x.uid = index));
|
z.outsideServices.forEach((x, index) => (x.uid = index));
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("getdata items indexed:", vm.obj.items);
|
|
||||||
//modify the menu as necessary
|
//modify the menu as necessary
|
||||||
generateMenu(vm);
|
generateMenu(vm);
|
||||||
//update which areas are available to user
|
//update which areas are available to user
|
||||||
@@ -642,7 +641,7 @@ async function saveHeader(vm) {
|
|||||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}`, headerOnly);
|
let res = await window.$gz.api.upsert(`${API_BASE_URL}`, headerOnly);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
if (isPost) {
|
if (isPost) {
|
||||||
handleSaveError(res.error, true);
|
handleSaveError({ fatal: true, error: res.error });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//update any server changed fields
|
//update any server changed fields
|
||||||
@@ -673,7 +672,7 @@ async function saveState(vm) {
|
|||||||
//it's new so save it
|
//it's new so save it
|
||||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}states`, o);
|
let res = await window.$gz.api.upsert(`${API_BASE_URL}states`, o);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
handleSaveError(res.error);
|
handleSaveError({ error: res.error });
|
||||||
} else {
|
} else {
|
||||||
vm.obj.states[i] = res.data;
|
vm.obj.states[i] = res.data;
|
||||||
|
|
||||||
@@ -688,7 +687,6 @@ async function saveState(vm) {
|
|||||||
// ITEMS
|
// ITEMS
|
||||||
//
|
//
|
||||||
async function deleteItems(vm) {
|
async function deleteItems(vm) {
|
||||||
//TODO: MUST OPERATE IN SEQUENCE ORDER TO MATCH VIEW
|
|
||||||
//walk the array backwards as items may or may not be spliced out
|
//walk the array backwards as items may or may not be spliced out
|
||||||
for (var i = vm.obj.items.length - 1; i >= 0; i--) {
|
for (var i = vm.obj.items.length - 1; i >= 0; i--) {
|
||||||
const d = vm.obj.items[i];
|
const d = vm.obj.items[i];
|
||||||
@@ -697,7 +695,7 @@ async function deleteItems(vm) {
|
|||||||
}
|
}
|
||||||
let res = await window.$gz.api.remove(`${API_BASE_URL}items/${d.id}`);
|
let res = await window.$gz.api.remove(`${API_BASE_URL}items/${d.id}`);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
handleSaveError({ fatal: true, error: res.error, itemIndex: i });
|
handleSaveError({ error: res.error, itemUid: d.uid });
|
||||||
} else {
|
} else {
|
||||||
vm.obj.items.splice(i, 1);
|
vm.obj.items.splice(i, 1);
|
||||||
}
|
}
|
||||||
@@ -713,7 +711,6 @@ async function saveItems(vm, err) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//SAVE WOITEMS
|
//SAVE WOITEMS
|
||||||
//TODO: MUST OPERATE IN SEQUENCE ORDER TO MATCH VIEW
|
|
||||||
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
|
//get copy of item without child collections for independant submit
|
||||||
const {
|
const {
|
||||||
@@ -733,7 +730,7 @@ async function saveItems(vm, err) {
|
|||||||
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) {
|
||||||
handleSaveError({ error: res.error, itemIndex: i });
|
handleSaveError({ error: res.error, itemUid: o.uid });
|
||||||
if (isPost) {
|
if (isPost) {
|
||||||
//a post error precludes further operations on this item below
|
//a post error precludes further operations on this item below
|
||||||
//however, an update error doesn't necessarily because it's still a existing workorder item
|
//however, an update error doesn't necessarily because it's still a existing workorder item
|
||||||
@@ -762,14 +759,12 @@ async function saveItems(vm, err) {
|
|||||||
}
|
}
|
||||||
//------
|
//------
|
||||||
//save grandchildren
|
//save grandchildren
|
||||||
err = await saveScheduledUsers(vm, i, err);
|
if (!this.saveResult.fatal) {
|
||||||
if (err.fatal) {
|
await saveScheduledUsers(vm, i);
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
//todo: other grandchildren
|
//todo: other grandchildren
|
||||||
//------
|
//------
|
||||||
}
|
}
|
||||||
return err; //made it through
|
|
||||||
}
|
}
|
||||||
//####################################################################################
|
//####################################################################################
|
||||||
//## GRANDCHILDREN
|
//## GRANDCHILDREN
|
||||||
@@ -868,10 +863,10 @@ function handleSaveError(e) {
|
|||||||
}
|
}
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (this.errors == null) {
|
if (this.saveResult.errors == null) {
|
||||||
this.errors = [];
|
this.saveResult.errors = [];
|
||||||
}
|
}
|
||||||
this.errors.push(e);
|
this.saveResult.errors.push(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
function formErrorFromSaveResult() {
|
function formErrorFromSaveResult() {
|
||||||
|
|||||||
Reference in New Issue
Block a user