This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
data-cy="scheduledUsersTable"
|
||||
dense
|
||||
:item-class="itemRowClasses"
|
||||
item-key="id"
|
||||
item-key="index"
|
||||
@click:row="selectItem"
|
||||
:show-select="$vuetify.breakpoint.xs"
|
||||
single-select
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
:pvm="this"
|
||||
data-cy="woItems"
|
||||
/>
|
||||
{{ obj }}
|
||||
</v-form>
|
||||
</div>
|
||||
<template v-if="!formState.ready">
|
||||
@@ -318,9 +319,6 @@ export default {
|
||||
return false;
|
||||
},
|
||||
woItemCount: function() {
|
||||
if (!this.obj.items) {
|
||||
return 0;
|
||||
}
|
||||
return this.obj.items.length;
|
||||
},
|
||||
hasSelectedScheduledUserItem: function() {
|
||||
@@ -369,6 +367,12 @@ export default {
|
||||
if (itemIndex == this.selectedItemIndex) {
|
||||
return;
|
||||
}
|
||||
if (itemIndex == null) {
|
||||
//if there is only one then it should be selected otherwise null is ok for a bunch
|
||||
if (this.woItemCount == 1) {
|
||||
itemIndex = 0;
|
||||
}
|
||||
}
|
||||
this.selectedItemIndex = itemIndex;
|
||||
//reset all children
|
||||
this.selectedScheduledUserItemIndex = null;
|
||||
@@ -383,6 +387,7 @@ export default {
|
||||
let o = this.obj.items[itemIndex];
|
||||
if (o.id != 0) {
|
||||
this.deletedItems.push(o.id);
|
||||
this.formState.dirty = true;
|
||||
}
|
||||
this.obj.items.splice(itemIndex, 1);
|
||||
this.selectItem(null); //select nothing in essence resetting a child selects and this one too clearing form
|
||||
@@ -677,7 +682,7 @@ async function saveItems(vm) {
|
||||
//delete
|
||||
for (let i = 0; i < totalDeletedItems; i++) {
|
||||
let res = await window.$gz.api.remove(
|
||||
`${API_BASE_URL}${this.deletedItems[i]}`
|
||||
`${API_BASE_URL}items/${vm.deletedItems[i]}`
|
||||
);
|
||||
if (res.error) {
|
||||
displayResError(vm, res);
|
||||
@@ -692,16 +697,22 @@ async function saveItems(vm) {
|
||||
// console.log("checking for save item: ", { item: o, index: i });
|
||||
if (o.isDirty) {
|
||||
// console.log("Is dirty, saving now for ", i);
|
||||
let isPost = o.id == 0;
|
||||
let res = await window.$gz.api.upsert(`${API_BASE_URL}items`, o);
|
||||
if (res.error) {
|
||||
displayResError(vm, res);
|
||||
return false;
|
||||
} else {
|
||||
//update any server changed fields
|
||||
//put fields
|
||||
o.concurrency = res.concurrency;
|
||||
o.id = res.id;
|
||||
o.workorderId = res.workorderId;
|
||||
o.isDirty = false;
|
||||
|
||||
//fields to update if post
|
||||
if (isPost) {
|
||||
o.id = res.id;
|
||||
o.workorderId = res.workorderId;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// console.log("Item not dirty skipping save of ", i);
|
||||
@@ -732,6 +743,7 @@ async function saveScheduledUsers(vm, woitemindex) {
|
||||
let o = vm.obj.items[woitemindex].scheduledUsers[i];
|
||||
// console.log("checking for save scheduseritem: ", { item: o, index: i });
|
||||
if (o.isDirty) {
|
||||
let isPost = o.id == 0;
|
||||
// console.log("sched user Is dirty, saving now");
|
||||
let res = await window.$gz.api.upsert(
|
||||
`${API_BASE_URL}items/scheduledusers`,
|
||||
@@ -742,10 +754,15 @@ async function saveScheduledUsers(vm, woitemindex) {
|
||||
return false;
|
||||
} else {
|
||||
//update any server changed fields
|
||||
//always updated:
|
||||
o.concurrency = res.concurrency;
|
||||
o.id = res.id;
|
||||
o.workOrderItemId = res.workOrderItemId;
|
||||
o.isDirty = false;
|
||||
|
||||
//new records only...
|
||||
if (isPost) {
|
||||
o.id = res.id;
|
||||
o.workOrderItemId = res.workOrderItemId;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// console.log("schedUserItem not dirty skipping save");
|
||||
|
||||
Reference in New Issue
Block a user