This commit is contained in:
2021-04-15 23:50:54 +00:00
parent 0caa09b763
commit 26bfb58a81
2 changed files with 81 additions and 24 deletions

View File

@@ -234,8 +234,11 @@ OVERALL
TODO: move to a "soft delete" get rid of the deleted items separate array
- on delete flag an item as "deleted=true"
- modify the Items method that provides the array to the table so hide "deleted=true" items
or....maybe show them as read only grayed out??
if this, then delete would be wrong term, should be "mark for delete"
- on save iterate the graph looking for deleted=true and attempt delete
- on fail of delete set deleted=true to false so it will show but make sure to do it *IN* the delete method so it's ready for later to show the error
- test partial save (### and delete ###) with fail at each level (make up a fail if have to at server)
- Error messages should display correctly both in alert box and in each item's controls

View File

@@ -79,6 +79,7 @@
"
></gz-decimal>
</v-col>
<!-- {{ value.items[activeWoItemIndex].scheduledUsers[activeItemIndex] }} -->
</template>
</div>
</template>
@@ -111,6 +112,13 @@ export default {
type: Number
}
},
watch: {
activeWoItemIndex(val, oldVal) {
if (val != oldVal) {
this.setDefaultView();
}
}
},
methods: {
newItem() {
let newIndex = this.value.items[this.activeWoItemIndex].scheduledUsers
@@ -132,28 +140,54 @@ export default {
this.activeItemIndex = newIndex;
},
async deleteItem() {
if ((await window.$gz.dialog.confirmDelete()) != true) {
return;
}
// if ((await window.$gz.dialog.confirmDelete()) != true) {
// return;
// }
let o = this.value.items[this.activeWoItemIndex].scheduledUsers[
// let o = this.value.items[this.activeWoItemIndex].scheduledUsers[
// this.activeItemIndex
// ];
// if (o.id != 0) {
// //it's a previously saved item so it needs to be removed at the server too
// this.$emit("graph-item-deleted", {
// atype: window.$gz.type.WorkOrderItemScheduledUser,
// id: o.id,
// objectIndex: this.activeItemIndex,
// woItemIndex: this.activeWoItemIndex
// });
// }
// this.value.items[this.activeWoItemIndex].scheduledUsers.splice(
// this.activeItemIndex,
// 1
// );
// this.setDefaultView();
//SOFT DELETE TEST
//NO need to confirm, it's apparent?
//or maybe it's a big enough deal it should be confirmed
//or maybe on save it should prompt that some items will be deleted is this ok etc??
// if ((await window.$gz.dialog.confirmDelete()) != true) {
// return;
// }
this.value.items[this.activeWoItemIndex].scheduledUsers[
this.activeItemIndex
];
if (o.id != 0) {
//it's a previously saved item so it needs to be removed at the server too
this.$emit("graph-item-deleted", {
atype: window.$gz.type.WorkOrderItemScheduledUser,
id: o.id,
objectIndex: this.activeItemIndex,
woItemIndex: this.activeWoItemIndex
});
}
this.value.items[this.activeWoItemIndex].scheduledUsers.splice(
this.activeItemIndex,
1
);
this.setDefaultView();
].deleted = true;
// if (o.id != 0) {
// //it's a previously saved item so it needs to be removed at the server too
// this.$emit("graph-item-deleted", {
// atype: window.$gz.type.WorkOrderItemScheduledUser,
// id: o.id,
// objectIndex: this.activeItemIndex,
// woItemIndex: this.activeWoItemIndex
// });
// }
// this.value.items[this.activeWoItemIndex].scheduledUsers.splice(
// this.activeItemIndex,
// 1
// );
// this.setDefaultView();
},
setDefaultView: function() {
//if only one record left then display it otherwise just let the datatable show what the user can click on
@@ -182,11 +216,31 @@ export default {
}
},
itemRowClasses: function(item) {
//"Items[3].scheduledUsers[1].
const path = `Items[${this.activeWoItemIndex}].ScheduledUsers[${item.index}].`;
if (this.form().childRowHasError(this, path)) {
return "font-weight-black font-italic error--text";
if (this.activeItemIndex == null) {
return;
}
let ret = "";
console.log("scheduseritemrowclass:", {
activewoitemindex: this.activeWoItemIndex,
activeItem: this.activeItemIndex
});
const isDeleted =
this.value.items[this.activeWoItemIndex].scheduledUsers[
this.activeItemIndex
].deleted === true;
const hasError = this.form().childRowHasError(
this,
`Items[${this.activeWoItemIndex}].ScheduledUsers[${item.index}].`
);
if (hasError) {
ret = "font-weight-black font-italic error--text ";
}
if (isDeleted) {
ret += "text-decoration-line-through text--disabled";
}
return ret;
}
},
computed: {