From 26bfb58a81a3782490a0ab8d0ccae15ec86c46c5 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 15 Apr 2021 23:50:54 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 3 + .../work-order-item-scheduled-users.vue | 102 +++++++++++++----- 2 files changed, 81 insertions(+), 24 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 6434fa9e..d0ffa921 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -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 diff --git a/ayanova/src/components/work-order-item-scheduled-users.vue b/ayanova/src/components/work-order-item-scheduled-users.vue index 501f23b2..b83956f8 100644 --- a/ayanova/src/components/work-order-item-scheduled-users.vue +++ b/ayanova/src/components/work-order-item-scheduled-users.vue @@ -79,6 +79,7 @@ " > + @@ -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: {