This commit is contained in:
2021-02-23 22:37:11 +00:00
parent c7c2893ce6
commit 035a03545c
2 changed files with 29 additions and 44 deletions

View File

@@ -782,9 +782,9 @@ export default {
/////////////////////////////// ///////////////////////////////
// On fieldValueChanged handler // On fieldValueChanged handler
// formReference is an optional string name of the form ref property if alternative named form // formReference is an optional string name of the form ref property if alternative named form
// - Clear server errrors // - Clear server errrors for this field
// - Flag dirty // - Flag form dirty
// - check and flag validity // - check and flag form validity
// //
// //
fieldValueChanged(vm, ref, formReference) { fieldValueChanged(vm, ref, formReference) {
@@ -808,43 +808,36 @@ export default {
return; return;
} }
// console.log("gzform::fieldValueChanged, values:", {
// ref: ref,
// objValue: vm[ref],
// refValue: vm.$refs[ref].value
// });
//If ref appears in the formState.serverErrors details collection, remove each one
//m is a mutated array with only the remaining (not removed) elements left
//that did NOT pass the truthy test function
//might be an indexed item //might be an indexed item
//this is what we're dealing with //this is what we're dealing with
// { "code": "2200", "details": [ { "message": "LT:PurchaseOrderReceiptItemQuantityReceivedErrorInvalid", "target": "Items[0].QuantityReceived", "error": "2203" } ], "message": "ErrorAPI2200" } // { "code": "2200", "details": [ { "message": "LT:PurchaseOrderReceiptItemQuantityReceivedErrorInvalid", "target": "Items[0].QuantityReceived", "error": "2203" } ], "message": "ErrorAPI2200" }
//let rowErrorTargetStart = `${collectionName}[${rowIndex}].`.toLowerCase(); //let rowErrorTargetStart = `${collectionName}[${rowIndex}].`.toLowerCase();
//# REMOVE SERVER ERRORS FOR THIS FIELD REF
let targetRef = ref.toLowerCase(); let targetRef = ref.toLowerCase();
// if(targetRef.includes("].")){
// //it's an indexed reference so change
// }
let m = []; //NOTE: This block of code is meant to remove all detailed server errors where the Target matches the current referenced control
console.log("details", vm.formState.serverError.details); //Then it checks to see if there is anything left in details as this might have been all there was and if so removes that whole thing
//leaving only errors for other fields or nothing if this ref field was all the errors left
//Remove any server errors that are for our target ref field
//and also set a flag if there *are* any server errors for our target field
let targetFieldHasServerError = false;
if (vm.formState.serverError.details) { if (vm.formState.serverError.details) {
m = vm.formState.serverError.details.filter(function(o) { let i = vm.formState.serverError.details.length;
if (o.target) {//<----WTF? Shouldn't this be the opposite? //iterate backwards so we can mutate the array in place
return false; while (i--) {
var o = vm.formState.serverError.details[i];
if (o.target && o.target.toLowerCase() == targetRef) {
//remove it, it's for our ref field
vm.formState.serverError.details.splice(i, 1);
targetFieldHasServerError = true;
} }
}
console.log("comparing values:", {
errorTarget: o.target.toLowerCase(),
targetRef: targetRef
});
return o.target.toLowerCase() != targetRef;
});
} }
//# CLEAN UP SERVER ERRORS IF NONE LEFT
//If there are no more errors in details then remove the whole thing as it's no longer required //If there are no more errors in details then remove the whole thing as it's no longer required
if ( if (
vm.formState.serverError.details && vm.formState.serverError.details &&
@@ -858,31 +851,23 @@ export default {
} }
} }
//TODO: find a cleaner way to remove old validation on the control, why can't it just be set on the control referenced?? //# CLEAR OUT STALE VALIDATION ERRORS FOR CONTROL
//Clear out old validation display in form by forcing the control's data to change //Clear out old validation display in form by forcing the control's data to change
//I tried calling form validate and reset and all that bullshit but it did nothing //I tried calling form validate and reset and all that bullshit but it did nothing
//probably because it has safeguards to prevent excess validation, this works though so far //probably because it has safeguards to prevent excess validation, this works though so far
//I added the triggering change guard but it actually doesn't seem to be required here, more investigation is required //I added the triggering change guard but it actually doesn't seem to be required here, more investigation is required
console.log("about to clear old validation values are: ", {
ref: ref,
m: m
});
if (m.length > 0) {
triggeringChange = true;
//TODO: find a cleaner way to remove old validation on the control, why can't it just be set on the control referenced??
if (targetFieldHasServerError) {
triggeringChange = true;
let val = vm.obj[ref]; let val = vm.obj[ref];
console.log("clearning old validation values are: ", {
val: val,
ref: ref,
m: m
});
vm.obj[ref] = null; vm.obj[ref] = null;
vm.obj[ref] = val; vm.obj[ref] = val;
triggeringChange = false; triggeringChange = false;
} }
//Update the form status //# UPDATE FORM STATUS
let formValid = formControl.validate(); let formValid = formControl.validate();
that.setFormState({ that.setFormState({
vm: vm, vm: vm,

View File

@@ -222,7 +222,7 @@
</v-col> </v-col>
<!-- ################################ PURCHASE ORDER ITEMS LIST ############################### --> <!-- ################################ PURCHASE ORDER ITEMS LIST ############################### -->
{{ formState.serverError }}
<v-col cols="12"> <v-col cols="12">
<v-data-table <v-data-table
:headers="headerList" :headers="headerList"