From 171ae84f5bae3bf2dc16d767b7f0d59ea7831839 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 15 Apr 2021 19:12:14 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 15 ++----- .../work-order-item-scheduled-users.vue | 4 +- ayanova/src/components/work-order-items.vue | 3 +- ayanova/src/views/svc-workorder.vue | 40 ++++++++++++------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 21be94f2..25b2a761 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -229,19 +229,12 @@ CURRENTLY DOING: error and ordering stuff OVERALL ORDERING AND ERRORS - - New idea: since each graph item is saved one by one, the client knows which one it's sending so the Client should hydrate the correct collection error index + - since each graph item is saved one by one, the client knows which one it's sending so the Client should hydrate the correct collection error index server should act like its' a standalone object when reporting errors this way, no need to modify existing code at all (po etc) - - NO WON'T WORK: Must support doing it by ID instead, this is necessary and much better than hoping the order is consistent - NO, this can't work because a collection of new items all have no id so which would be which?? - i.e. the server sets the error index by the ID not the order, the client checks by ID as well, this way it matters not what the physical order is - This would be the definitive resolution since it would then work with re-ordering - would require any currently index style errors to be re-worked (unless I add a new protocol atop i.e. Items[id:23].ScheduledUsers[id:2] which would be interpreted differently by the error system) - The forms though might have a problem with it since they are working very well with indexes right now - perhaps the server returns error in form of id, but the client translates it back to an index for actual display? - ErrorIdToIndex(blah) method - make it consistent with all collections / go back and retro the others (PO, CONTRACT ETC) - + - woitem must show error indicator in row if error is in it's children so user knows where to go + + - test partial save (### and delete ###) with fail at each level (make up a fail if have to at server) diff --git a/ayanova/src/components/work-order-item-scheduled-users.vue b/ayanova/src/components/work-order-item-scheduled-users.vue index 4f884f66..143cd6b8 100644 --- a/ayanova/src/components/work-order-item-scheduled-users.vue +++ b/ayanova/src/components/work-order-item-scheduled-users.vue @@ -146,7 +146,9 @@ export default { //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 + id: o.id, + objectIndex: this.activeItemIndex, + woItemIndex: this.activeWoItemIndex }); } this.value.items[this.activeWoItemIndex].scheduledUsers.splice( diff --git a/ayanova/src/components/work-order-items.vue b/ayanova/src/components/work-order-items.vue index f079ce83..385a5f26 100644 --- a/ayanova/src/components/work-order-items.vue +++ b/ayanova/src/components/work-order-items.vue @@ -163,7 +163,8 @@ export default { //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.WorkOrderItem, - id: o.id + id: o.id, + objectIndex: this.activeItemIndex }); } this.value.items.splice(this.activeItemIndex, 1); diff --git a/ayanova/src/views/svc-workorder.vue b/ayanova/src/views/svc-workorder.vue index 9acb8d23..a88f1a21 100644 --- a/ayanova/src/views/svc-workorder.vue +++ b/ayanova/src/views/svc-workorder.vue @@ -312,10 +312,10 @@ export default { flagGraphItemForDelete: function(item) { switch (item.atype) { case window.$gz.type.WorkOrderItem: - this.deletedGraphItems.items.push(item.id); + this.deletedGraphItems.items.push(item); break; case window.$gz.type.WorkOrderItemScheduledUser: - this.deletedGraphItems.scheduledUsers.push(item.id); + this.deletedGraphItems.scheduledUsers.push(item); break; //todo: other grandchildren @@ -668,7 +668,7 @@ async function saveState(vm, err) { //it's new so save it let res = await window.$gz.api.upsert(`${API_BASE_URL}states`, o); if (res.error) { - err.states.push(res.error); + err.states.push(res.error);//only saves one at a time so no need for collection stuff here err.error = true; } else { vm.obj.states[i] = res.data; @@ -690,11 +690,14 @@ async function deleteItems(vm, err) { } //walk the array backwards as items may or may not be spliced out for (var i = vm.deletedGraphItems.items.length - 1; i >= 0; i--) { - let res = await window.$gz.api.remove( - `${API_BASE_URL}items/${vm.deletedGraphItems.items[i]}` - ); + const d = vm.deletedGraphItems.items[i]; + let res = await window.$gz.api.remove(`${API_BASE_URL}items/${d.id}`); if (res.error) { - err.items.push({ e: res.error, i: i }); + err.items.push({ + e: res.error, + objectIndex: d.objectIndex, + woItemIndex: d.woItemIndex + }); err.error = true; } else { vm.deletedGraphItems.items.splice(i, 1); @@ -727,7 +730,7 @@ async function saveItems(vm, err) { const isPost = o.id == 0; let res = await window.$gz.api.upsert(`${API_BASE_URL}items`, o); if (res.error) { - err.items.push({ e: res.error, i: i }); + err.items.push({ e: res.error, objectIndex: i }); err.error = true; if (isPost) { //a post error precludes further operations on this item below @@ -775,11 +778,16 @@ async function saveItems(vm, err) { async function deleteScheduledUsers(vm, err) { //walk the array backwards as items may or may not be spliced out for (var i = vm.deletedGraphItems.scheduledUsers.length - 1; i >= 0; i--) { + const d = vm.deletedGraphItems.scheduledUsers[i]; let res = await window.$gz.api.remove( - `${API_BASE_URL}items/scheduledusers/${vm.deletedGraphItems.scheduledUsers[i]}` + `${API_BASE_URL}items/scheduledusers/${d.id}` ); if (res.error) { - err.scheduledUsers.push({ e: res.error, i: i }); + err.scheduledUsers.push({ + e: res.error, + objectIndex: d.objectIndex, + woItemIndex: d.woItemIndex + }); err.error = true; } else { vm.deletedGraphItems.scheduledUsers.splice(i, 1); @@ -788,13 +796,13 @@ async function deleteScheduledUsers(vm, err) { return err; } -async function saveScheduledUsers(vm, woitemindex, err) { - let totalItems = vm.obj.items[woitemindex].scheduledUsers.length; +async function saveScheduledUsers(vm, woItemIndex, err) { + let totalItems = vm.obj.items[woItemIndex].scheduledUsers.length; if (totalItems == 0) { return err; } for (let i = 0; i < totalItems; i++) { - let o = vm.obj.items[woitemindex].scheduledUsers[i]; + let o = vm.obj.items[woItemIndex].scheduledUsers[i]; if (o.isDirty) { const isPost = o.id == 0; let res = await window.$gz.api.upsert( @@ -802,7 +810,11 @@ async function saveScheduledUsers(vm, woitemindex, err) { o ); if (res.error) { - err.scheduledUsers.push({ e: res.error, i: i }); + err.scheduledUsers.push({ + e: res.error, + objectIndex: i, + woItemIndex: woItemIndex + }); err.error = true; } else { //update any server changed fields