This commit is contained in:
@@ -167,17 +167,7 @@ export default {
|
|||||||
if ((await window.$gz.dialog.confirmDelete()) != true) {
|
if ((await window.$gz.dialog.confirmDelete()) != true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.value.items.splice(this.pvm.selectedItemIndex, 1);
|
this.pvm.deleteItem(this.pvm.selectedItemIndex);
|
||||||
this.pvm.selectItem(null); //select nothing in essence resetting a child selects and this one too clearing form
|
|
||||||
|
|
||||||
//todo: put this id in a collection at parent to be deleted when it's saved and marked dirty (a function "DeleteItem(index)")
|
|
||||||
//if no concurrency then just remove and ignore, no need to save, if concurrency then it needs to be deleted at the server
|
|
||||||
|
|
||||||
// if (this.value.items.length > 0) {
|
|
||||||
// this.pvm.selectedItemIndex = this.value.items.length - 1;
|
|
||||||
// } else {
|
|
||||||
// this.pvm.selectedItemIndex = null;
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
selectItem: function(item) {
|
selectItem: function(item) {
|
||||||
this.selectedRow = [item];
|
this.selectedRow = [item];
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ export default {
|
|||||||
languageName: window.$gz.locale.getResolvedLanguage(),
|
languageName: window.$gz.locale.getResolvedLanguage(),
|
||||||
hour12: window.$gz.locale.getHour12(),
|
hour12: window.$gz.locale.getHour12(),
|
||||||
selectedItemIndex: null,
|
selectedItemIndex: null,
|
||||||
|
deletedItems: [],
|
||||||
selectedScheduledUserItemIndex: null,
|
selectedScheduledUserItemIndex: null,
|
||||||
selectLists: {
|
selectLists: {
|
||||||
wostatus: [],
|
wostatus: [],
|
||||||
@@ -374,6 +375,18 @@ export default {
|
|||||||
//todo: all children here
|
//todo: all children here
|
||||||
//this.selectedLaborIndex...blahblah etc
|
//this.selectedLaborIndex...blahblah etc
|
||||||
},
|
},
|
||||||
|
deleteItem: function(itemIndex) {
|
||||||
|
if (itemIndex == null) {
|
||||||
|
itemIndex = this.selectedItemIndex;
|
||||||
|
}
|
||||||
|
//add to deleted items if has concurrency / id
|
||||||
|
let o = this.obj.items[itemIndex];
|
||||||
|
if (o.id != 0) {
|
||||||
|
this.deletedItems.push(o.id);
|
||||||
|
}
|
||||||
|
this.obj.items.splice(itemIndex, 1);
|
||||||
|
this.selectItem(null); //select nothing in essence resetting a child selects and this one too clearing form
|
||||||
|
},
|
||||||
canSave: function() {
|
canSave: function() {
|
||||||
return this.formState.valid && this.formState.dirty;
|
return this.formState.valid && this.formState.dirty;
|
||||||
},
|
},
|
||||||
@@ -635,7 +648,7 @@ export default {
|
|||||||
//
|
//
|
||||||
async function saveHeader(vm) {
|
async function saveHeader(vm) {
|
||||||
if (!vm.obj.isDirty) {
|
if (!vm.obj.isDirty) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}`, o);
|
let res = await window.$gz.api.upsert(`${API_BASE_URL}`, o);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
@@ -647,6 +660,7 @@ async function saveHeader(vm) {
|
|||||||
vm.obj.id = res.id;
|
vm.obj.id = res.id;
|
||||||
vm.obj.serial = res.serial;
|
vm.obj.serial = res.serial;
|
||||||
vm.obj.isDirty = false;
|
vm.obj.isDirty = false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,15 +669,29 @@ async function saveHeader(vm) {
|
|||||||
//
|
//
|
||||||
async function saveItems(vm) {
|
async function saveItems(vm) {
|
||||||
let totalItems = vm.obj.items.length;
|
let totalItems = vm.obj.items.length;
|
||||||
if (totalItems == 0) {
|
let totalDeletedItems = vm.deletedItems.length;
|
||||||
return;
|
if (totalItems == 0 && totalDeletedItems == 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//delete
|
||||||
|
for (let i = 0; i < totalDeletedItems; i++) {
|
||||||
|
let res = await window.$gz.api.remove(
|
||||||
|
`${API_BASE_URL}${this.deletedItems[i]}`
|
||||||
|
);
|
||||||
|
if (res.error) {
|
||||||
|
displayResError(vm, res);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//upsert
|
||||||
console.log("saveItems processing this many items: ", totalItems);
|
console.log("saveItems processing this many items: ", totalItems);
|
||||||
for (let i = 0; i < totalItems; i++) {
|
for (let i = 0; i < totalItems; i++) {
|
||||||
let o = vm.obj.items[i];
|
let o = vm.obj.items[i];
|
||||||
console.log("checking for save item: ", { item: o, index: i });
|
console.log("checking for save item: ", { item: o, index: i });
|
||||||
if (o.isDirty) {
|
if (o.isDirty) {
|
||||||
console.log("Is dirty, saving now");
|
console.log("Is dirty, saving now for ", i);
|
||||||
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) {
|
||||||
displayResError(vm, res);
|
displayResError(vm, res);
|
||||||
@@ -676,7 +704,7 @@ async function saveItems(vm) {
|
|||||||
o.isDirty = false;
|
o.isDirty = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("Item not dirty skipping save");
|
console.log("Item not dirty skipping save of ", i);
|
||||||
}
|
}
|
||||||
//------
|
//------
|
||||||
//save grandchildren
|
//save grandchildren
|
||||||
@@ -693,18 +721,18 @@ async function saveItems(vm) {
|
|||||||
// SCHEDULED USERS
|
// SCHEDULED USERS
|
||||||
//
|
//
|
||||||
async function saveScheduledUsers(vm, woitemindex) {
|
async function saveScheduledUsers(vm, woitemindex) {
|
||||||
console.log("SaveSchedUsersProcessing for woitemindex:", woitemindex);
|
// console.log("SaveSchedUsersProcessing for woitemindex:", woitemindex);
|
||||||
let totalItems = vm.obj.items[woitemindex].scheduledUsers.length;
|
let totalItems = vm.obj.items[woitemindex].scheduledUsers.length;
|
||||||
if (totalItems == 0) {
|
if (totalItems == 0) {
|
||||||
console.log("saveschedusers no items to save bailing");
|
// console.log("saveschedusers no items to save bailing");
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
console.log("saveschedusers processing this many items: ", totalItems);
|
// console.log("saveschedusers processing this many items: ", totalItems);
|
||||||
for (let i = 0; i < totalItems; i++) {
|
for (let i = 0; i < totalItems; i++) {
|
||||||
let o = vm.obj.items[woitemindex].scheduledUsers[i];
|
let o = vm.obj.items[woitemindex].scheduledUsers[i];
|
||||||
console.log("checking for save item: ", { item: o, index: i });
|
// console.log("checking for save scheduseritem: ", { item: o, index: i });
|
||||||
if (o.isDirty) {
|
if (o.isDirty) {
|
||||||
console.log("sched user Is dirty, saving now");
|
// console.log("sched user Is dirty, saving now");
|
||||||
let res = await window.$gz.api.upsert(
|
let res = await window.$gz.api.upsert(
|
||||||
`${API_BASE_URL}items/scheduledusers`,
|
`${API_BASE_URL}items/scheduledusers`,
|
||||||
o
|
o
|
||||||
@@ -720,7 +748,7 @@ async function saveScheduledUsers(vm, woitemindex) {
|
|||||||
o.isDirty = false;
|
o.isDirty = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("schedUserItem not dirty skipping save");
|
// console.log("schedUserItem not dirty skipping save");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true; //made it
|
return true; //made it
|
||||||
|
|||||||
Reference in New Issue
Block a user