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