From b259584b8533d5a0fd22f44ee6f2ddfa0a04a74a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 22 Feb 2021 21:06:17 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 5 ++++- ayanova/src/api/gzform.js | 11 +++-------- ayanova/src/views/inv-purchase-order.vue | 7 +++++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 4e5144b0..77145abc 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -56,7 +56,10 @@ todo: child collection items error / rule / customization handling where ParentCollectionName is exactly the same as the Model collection property name and FieldName is exactly the same as the child collection objects Model property name Update RequiredFieldsValidator to look for these period seperated items and navigate through teh collection by name / reflection to step through children and flag errors to include parent - e.g in validation error field name would be "poitems.vendorpartnumber" to indicate poitems collection vendorpartnumber field and set childitems index property (new) to 3 to indicate 4th row (0based) + e.g in purchase order record, validation error for not entering required Ordered quantity + "target" field name would be "items[0].quantityOrdered" to indicate poitems collection quantityOrdered field and items[0] indicates the first record in the collection + Note that this is how the built in validation for Model Required rules operates and that's useful so mirroring it even though it's a little harder to parse it saves a lot of dev time + as data annotations will be supported as is Update ValidationError.cs class, add index property and use it for above Update BizObject.cs add error methods that include index for use with indexed collection item errors Update client gzform.cs server errors handler to handle indexed child collection like that and report error on row and in popup edit form diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index 2fa4550b..544e8d7c 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -83,7 +83,7 @@ function getControlLabel(ctrl) { // Get errors for a particular field // from server error collection // -function getErrorsForField(vm, ref) { +function getErrorsForField(vm, ref, index) { //Note: to debug this on forms just put {{ formState.serverError }} //on the form to see what is actually stored there and should be showing let ret = []; @@ -143,9 +143,7 @@ export default { if (vm.formState.loading) { return true; } - // if (ref == "Items.PartId") { - // debugger; - // } + let ctrl = getControl(vm, ref); if (typeof ctrl == "undefined") { // console.log("gzform:required rule - bailing due to undefined", ref); @@ -683,8 +681,6 @@ export default { // NOTE: that in a form this should only be used with non stock-required fields, if they are already required they cannot be hidden // showMe(vm, formCustomTemplateFieldName) { - //TODO: CHILD COLLECTION MOD handle dot notation path indexed collection etc - // possibly it will just work since the key will match but double check //special check for wiki field //if read only then can't add any content and if no content then no reason to show it at all if (formCustomTemplateFieldName == "wiki") { @@ -748,7 +744,6 @@ export default { // This is required so that server errors can be cleared when input is changed // formReference is an optional string name of the form ref property if alternative named form fieldValueChanged(vm, ref, formReference) { - //TODO: CHILD COLLECTION MOD add error version for indexed child let that = this; let formControl = null; if (formReference == undefined) { @@ -759,7 +754,7 @@ export default { //dev error on form? if (!formControl) { - throw `gzform::fieldVAlueChanged formControl is not found ref:${ref}, formReferences:${formReference} `; + throw `gzform::fieldValueChanged formControl is not found ref:${ref}, formReferences:${formReference} `; } //this is currently required to ensure that this method runs after all the broken rule checks have settled diff --git a/ayanova/src/views/inv-purchase-order.vue b/ayanova/src/views/inv-purchase-order.vue index 64d907ae..7809fd09 100644 --- a/ayanova/src/views/inv-purchase-order.vue +++ b/ayanova/src/views/inv-purchase-order.vue @@ -359,6 +359,12 @@ :label="$ay.t('PurchaseOrderItemQuantityReceived')" ref="Items.QuantityReceived" data-cy="Items.QuantityReceived" + :error-messages=" + form().serverErrors( + this, + `Items[${editPoItemIndex}].QuantityReceived` + ) + " :rules="[ form().decimalValid(this, 'Items.QuantityReceived'), form().required(this, 'Items.QuantityReceived') @@ -452,6 +458,7 @@ > + {{ formState.serverError }}