This commit is contained in:
@@ -781,8 +781,12 @@ export default {
|
||||
},
|
||||
///////////////////////////////
|
||||
// On fieldValueChanged handler
|
||||
// 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
|
||||
// formReference is an optional string name of the form ref property if alternative named form
|
||||
// - Clear server errrors
|
||||
// - Flag dirty
|
||||
// - check and flag validity
|
||||
//
|
||||
//
|
||||
fieldValueChanged(vm, ref, formReference) {
|
||||
let that = this;
|
||||
let formControl = null;
|
||||
@@ -814,23 +818,30 @@ export default {
|
||||
//m is a mutated array with only the remaining (not removed) elements left
|
||||
//that did NOT pass the truthy test function
|
||||
|
||||
//de-lodash
|
||||
// let m = window.$gz. _.remove(vm.formState.serverError.details, function(
|
||||
// o
|
||||
// ) {
|
||||
// if (!o.target) {
|
||||
// return false;
|
||||
// }
|
||||
// return o.target.toLowerCase() == ref;
|
||||
// });
|
||||
//might be an indexed item
|
||||
//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();
|
||||
|
||||
let targetRef = ref.toLowerCase();
|
||||
// if(targetRef.includes("].")){
|
||||
// //it's an indexed reference so change
|
||||
// }
|
||||
|
||||
let m = [];
|
||||
console.log("details", vm.formState.serverError.details);
|
||||
if (vm.formState.serverError.details) {
|
||||
m = vm.formState.serverError.details.filter(function(o) {
|
||||
if (o.target) {
|
||||
if (o.target) {//<----WTF? Shouldn't this be the opposite?
|
||||
return false;
|
||||
}
|
||||
return o.target.toLowerCase() != ref;
|
||||
|
||||
console.log("comparing values:", {
|
||||
errorTarget: o.target.toLowerCase(),
|
||||
targetRef: targetRef
|
||||
});
|
||||
|
||||
return o.target.toLowerCase() != targetRef;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -847,13 +858,25 @@ 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 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
|
||||
//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
|
||||
console.log("about to clear old validation values are: ", {
|
||||
ref: ref,
|
||||
m: m
|
||||
});
|
||||
if (m.length > 0) {
|
||||
triggeringChange = true;
|
||||
|
||||
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] = val;
|
||||
triggeringChange = false;
|
||||
@@ -861,11 +884,6 @@ export default {
|
||||
|
||||
//Update the form status
|
||||
let formValid = formControl.validate();
|
||||
//let formValid = vm.$refs.form.validate();//##FORM REFERENCE
|
||||
// console.log(
|
||||
// "gzform:fieldValueChanged - form validity being set to ",
|
||||
// formValid
|
||||
// );
|
||||
that.setFormState({
|
||||
vm: vm,
|
||||
dirty: true,
|
||||
|
||||
@@ -415,6 +415,11 @@
|
||||
form().decimalValid(this, 'Items.QuantityReceived'),
|
||||
form().required(this, 'Items.QuantityReceived')
|
||||
]"
|
||||
@input="
|
||||
fieldValueChanged(
|
||||
`Items[${editPoItemIndex}].QuantityReceived`
|
||||
)
|
||||
"
|
||||
></gz-decimal>
|
||||
</v-col>
|
||||
|
||||
@@ -448,6 +453,10 @@
|
||||
form().decimalValid(this, 'Items.PurchaseOrderCost'),
|
||||
form().required(this, 'Items.PurchaseOrderCost')
|
||||
]"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'Items.PurchaseOrderCost')
|
||||
"
|
||||
@input="fieldValueChanged('Items.ReceivedDate')"
|
||||
></gz-currency>
|
||||
</v-col>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user