This commit is contained in:
2021-04-09 18:27:57 +00:00
parent ca9a46ab97
commit a18be17451
2 changed files with 32 additions and 16 deletions

View File

@@ -81,7 +81,7 @@
</v-col>
<GzWoItemScheduledUsers
v-if="pvm.subRights.scheduledUsers.visible"
v-if="subRights.scheduledUsers.visible"
v-model="value"
:pvm="pvm"
data-cy="woItemScheduledUsers"
@@ -126,6 +126,10 @@ export default {
pvm: {
default: null,
type: Object
},
subRights: {
default: null,
type: Object
}
},
@@ -165,7 +169,19 @@ export default {
if ((await window.$gz.dialog.confirmDelete()) != true) {
return;
}
this.pvm.deleteItem(this.activeItemIndex);
let o = this.value.items[this.activeItemIndex];
if (o.id != 0) {
//it's a previously saved item so it needs to be removed at the server too
//todo: event delete graphitem - this.deletedItems.push(o.id);
this.$emit("graph-item-deleted", {
atype: window.$gz.type.WorkOrderItem,
id: o.id
});
}
this.value.items.splice(this.activeItemIndex, 1);
this.selectedRow = [];
this.activeItemIndex = null; //select nothing in essence resetting a child selects and this one too clearing form
},
handleRowClick: function(item) {
this.activeItemIndex = item.index;

View File

@@ -17,8 +17,10 @@
:form-key="formCustomTemplateKey"
:readonly="formState.readOnly"
:pvm="this"
:sub-rights="subRights"
data-cy="woItems"
@change="setDirty()"
@graph-item-deleted="flagGraphItemForDelete($event)"
/>
</v-form>
</div>
@@ -197,7 +199,7 @@ export default {
languageName: window.$gz.locale.getResolvedLanguage(),
hour12: window.$gz.locale.getHour12(),
selectedItemIndex: null,
deletedItems: [],
deletedGraphItems: { items: [], scheduledUsers: [] },
selectedScheduledUserItemIndex: null,
selectLists: {
wostatus: [],
@@ -355,18 +357,16 @@ export default {
}
},
methods: {
deleteItem: function(itemIndex) {
if (itemIndex == null) {
throw new Error("svc-workorder: delete item itemIndex is null!");
flagGraphItemForDelete: function(item) {
console.log(item);
switch (item.atype) {
case window.$gz.type.WorkOrderItem:
this.deletedGraphItems.items.push(item.id);
break;
case window.$gz.type.WorkOrderItemScheduledUser:
break;
}
//add to deleted items if has concurrency / id
let o = this.obj.items[itemIndex];
if (o.id != 0) {
this.deletedItems.push(o.id);
this.setDirty();
}
this.obj.items.splice(itemIndex, 1);
this.selectItem(null); //select nothing in essence resetting a child selects and this one too clearing form
this.setDirty();
},
setDirty: function() {
this.formState.dirty = true;
@@ -656,7 +656,7 @@ async function saveHeader(vm) {
//
async function saveItems(vm) {
let totalItems = vm.obj.items.length;
let totalDeletedItems = vm.deletedItems.length;
let totalDeletedItems = vm.deletedGraphItems.items.length;
if (totalItems == 0 && totalDeletedItems == 0) {
return true;
}
@@ -664,7 +664,7 @@ async function saveItems(vm) {
//delete
for (let i = 0; i < totalDeletedItems; i++) {
let res = await window.$gz.api.remove(
`${API_BASE_URL}items/${vm.deletedItems[i]}`
`${API_BASE_URL}items/${vm.deletedGraphItems.items[i]}`
);
if (res.error) {
displayResError(vm, res);