This commit is contained in:
@@ -781,8 +781,12 @@ export default {
|
|||||||
},
|
},
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// On fieldValueChanged handler
|
// 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) {
|
fieldValueChanged(vm, ref, formReference) {
|
||||||
let that = this;
|
let that = this;
|
||||||
let formControl = null;
|
let formControl = null;
|
||||||
@@ -814,23 +818,30 @@ export default {
|
|||||||
//m is a mutated array with only the remaining (not removed) elements left
|
//m is a mutated array with only the remaining (not removed) elements left
|
||||||
//that did NOT pass the truthy test function
|
//that did NOT pass the truthy test function
|
||||||
|
|
||||||
//de-lodash
|
//might be an indexed item
|
||||||
// let m = window.$gz. _.remove(vm.formState.serverError.details, function(
|
//this is what we're dealing with
|
||||||
// o
|
// { "code": "2200", "details": [ { "message": "LT:PurchaseOrderReceiptItemQuantityReceivedErrorInvalid", "target": "Items[0].QuantityReceived", "error": "2203" } ], "message": "ErrorAPI2200" }
|
||||||
// ) {
|
//let rowErrorTargetStart = `${collectionName}[${rowIndex}].`.toLowerCase();
|
||||||
// if (!o.target) {
|
|
||||||
// return false;
|
let targetRef = ref.toLowerCase();
|
||||||
// }
|
// if(targetRef.includes("].")){
|
||||||
// return o.target.toLowerCase() == ref;
|
// //it's an indexed reference so change
|
||||||
// });
|
// }
|
||||||
|
|
||||||
let m = [];
|
let m = [];
|
||||||
|
console.log("details", vm.formState.serverError.details);
|
||||||
if (vm.formState.serverError.details) {
|
if (vm.formState.serverError.details) {
|
||||||
m = vm.formState.serverError.details.filter(function(o) {
|
m = vm.formState.serverError.details.filter(function(o) {
|
||||||
if (o.target) {
|
if (o.target) {//<----WTF? Shouldn't this be the opposite?
|
||||||
return false;
|
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
|
//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) {
|
if (m.length > 0) {
|
||||||
triggeringChange = true;
|
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;
|
||||||
@@ -861,11 +884,6 @@ export default {
|
|||||||
|
|
||||||
//Update the form status
|
//Update the form status
|
||||||
let formValid = formControl.validate();
|
let formValid = formControl.validate();
|
||||||
//let formValid = vm.$refs.form.validate();//##FORM REFERENCE
|
|
||||||
// console.log(
|
|
||||||
// "gzform:fieldValueChanged - form validity being set to ",
|
|
||||||
// formValid
|
|
||||||
// );
|
|
||||||
that.setFormState({
|
that.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
dirty: true,
|
dirty: true,
|
||||||
|
|||||||
@@ -415,6 +415,11 @@
|
|||||||
form().decimalValid(this, 'Items.QuantityReceived'),
|
form().decimalValid(this, 'Items.QuantityReceived'),
|
||||||
form().required(this, 'Items.QuantityReceived')
|
form().required(this, 'Items.QuantityReceived')
|
||||||
]"
|
]"
|
||||||
|
@input="
|
||||||
|
fieldValueChanged(
|
||||||
|
`Items[${editPoItemIndex}].QuantityReceived`
|
||||||
|
)
|
||||||
|
"
|
||||||
></gz-decimal>
|
></gz-decimal>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
@@ -448,6 +453,10 @@
|
|||||||
form().decimalValid(this, 'Items.PurchaseOrderCost'),
|
form().decimalValid(this, 'Items.PurchaseOrderCost'),
|
||||||
form().required(this, 'Items.PurchaseOrderCost')
|
form().required(this, 'Items.PurchaseOrderCost')
|
||||||
]"
|
]"
|
||||||
|
:error-messages="
|
||||||
|
form().serverErrors(this, 'Items.PurchaseOrderCost')
|
||||||
|
"
|
||||||
|
@input="fieldValueChanged('Items.ReceivedDate')"
|
||||||
></gz-currency>
|
></gz-currency>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user