From 65828614746a0b323de7c56c0f0a01eef3c6764b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 22 Feb 2021 23:47:53 +0000 Subject: [PATCH] --- ayanova/src/api/gzform.js | 44 ++++++++++++++++++++++++ ayanova/src/views/inv-purchase-order.vue | 13 ++++--- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index a3037612..4782e430 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -679,6 +679,50 @@ export default { return ret; }, /////////////////////////////// + // childRowHasError + // returns true if error exists for row + // else returns false + // (actual errors not returned just for row indicator, + // user opens child edit form to see exact error) + // + childRowHasError(vm, collectionName, rowIndex) { + //todo: this just shows server errors, not local form errors + //maybe find if there is any place that records item errors (form?) + + //No server errors? + if (window.$gz.util.objectIsEmpty(vm.formState.serverError)) { + //nothing to process + return null; + } + + //no detail errors? + if (window.$gz.util.objectIsEmpty(vm.formState.serverError.details)) { + //nothing to process + return null; + } + + //Might be an error, check if collectionName is in error collection + //this is what we're dealing with + // { "code": "2200", "details": [ { "message": "LT:PurchaseOrderReceiptItemQuantityReceivedErrorInvalid", "target": "Items[0].QuantityReceived", "error": "2203" } ], "message": "ErrorAPI2200" } + let rowErrorTargetStart = `${collectionName}[${rowIndex}].`.toLowerCase(); + + //filter in items that start with the row collection name and index provided + let ret = vm.formState.serverError.details.some(function(o) { + // console.log("childrowHasError:", { + // tgt: o.target.toLowerCase(), + // tgtstrt: rowErrorTargetStart + // }); + if (!o.target) { + return false; + } + let r = o.target.toLowerCase().includes(rowErrorTargetStart); + + return r; + }); + + return ret; + }, + /////////////////////////////// // ShowMe // (returns false if the field has been set to hidden by the user in the formcustomtemplate) // NOTE: that in a form this should only be used with non stock-required fields, if they are already required they cannot be hidden diff --git a/ayanova/src/views/inv-purchase-order.vue b/ayanova/src/views/inv-purchase-order.vue index 975cb324..609ca5bb 100644 --- a/ayanova/src/views/inv-purchase-order.vue +++ b/ayanova/src/views/inv-purchase-order.vue @@ -222,6 +222,7 @@ + {{ formState.serverError }}