This commit is contained in:
@@ -16,6 +16,9 @@ function addDataKeyNames(obj) {
|
||||
}
|
||||
|
||||
export default {
|
||||
// cache the form customization data if it's not already present
|
||||
//cache invalidation is hard, this needs it...hmmm....
|
||||
//for now will rely on logout and back in to clear up any customization issues
|
||||
get(formKey) {
|
||||
return new Promise(function getFormTemplate(resolve) {
|
||||
if (
|
||||
|
||||
@@ -47,6 +47,21 @@ function isNumber(n) {
|
||||
//
|
||||
function getControl(vm, ref) {
|
||||
var ctrl = vm.$refs[ref];
|
||||
if (ctrl === undefined) {
|
||||
//it's either a sub field in custom fields component or it's a coding error
|
||||
var customFields = vm.$refs["customFields"];
|
||||
if (customFields !== undefined) {
|
||||
ctrl = customFields.$refs[ref];
|
||||
}
|
||||
}
|
||||
|
||||
//can't do it like this because during init undefined is normal apparently
|
||||
// if (ctrl === undefined && window.$gz.errorHandler.devMode()) {
|
||||
// debugger;
|
||||
// throw "DEV ERROR gzform::formState.getControl -> control ref of [" +
|
||||
// ref +
|
||||
// "] was not found in the form or in the custom fields";
|
||||
// }
|
||||
|
||||
return ctrl;
|
||||
}
|
||||
@@ -63,11 +78,12 @@ function getControlValue(ctrl) {
|
||||
// Get field name from control
|
||||
//
|
||||
function getControlLabel(ctrl) {
|
||||
if (window.$gz.errorHandler.developmentModeShowErrorsImmediately) {
|
||||
if (!ctrl.label) {
|
||||
throw "gzform:getControlLabel - the control has no label " + ctrl;
|
||||
}
|
||||
}
|
||||
// if (window.$gz.errorHandler.developmentModeShowErrorsImmediately) {
|
||||
// if (!ctrl.label) {
|
||||
// debugger;
|
||||
// throw "gzform:getControlLabel - the control has no label " + ctrl;
|
||||
// }
|
||||
// }
|
||||
return ctrl.label;
|
||||
}
|
||||
|
||||
@@ -82,16 +98,15 @@ function getErrorsForField(vm, ref) {
|
||||
return !o.target;
|
||||
});
|
||||
} else {
|
||||
|
||||
ret = window.$gz._.filter(vm.formState.serverError.details, function(o) {
|
||||
if (!o.target) {
|
||||
return false;
|
||||
}
|
||||
//server error fields are capitalized
|
||||
//server error fields are capitalized
|
||||
//client field names are generally lower case except for custom fields
|
||||
//so we need to normalize them all to lower case to match
|
||||
//they will always differ by more than case so this is fine
|
||||
console.log("getErrorsForField finding matches, comparing serverErrorField:["+o.target.toLowerCase() + "] to form field ref:["+ref.toLowerCase()+"]");
|
||||
// console.log("getErrorsForField finding matches, comparing serverErrorField:["+o.target.toLowerCase() + "] to form field ref:["+ref.toLowerCase()+"]");
|
||||
return o.target.toLowerCase() == ref.toLowerCase();
|
||||
});
|
||||
}
|
||||
@@ -134,6 +149,7 @@ export default {
|
||||
if (vm.formState.loading) {
|
||||
return false;
|
||||
}
|
||||
//debugger;
|
||||
var ctrl = getControl(vm, ref);
|
||||
if (typeof ctrl == "undefined") {
|
||||
return false;
|
||||
@@ -324,10 +340,8 @@ export default {
|
||||
// Process and return server errors if any for form and field specified
|
||||
//
|
||||
serverErrors(vm, ref) {
|
||||
|
||||
//CHECK PREREQUISITES IN DEV MODE TO ENSURE FORM ISN"T MISSING NEEDED DATA ATTRIBUTES ETC
|
||||
if (window.$gz.errorHandler.devMode()) {
|
||||
|
||||
//make sure formState.serverErrors is defined on data
|
||||
if (!window.$gz._.has(vm, "formState.serverError")) {
|
||||
throw "DEV ERROR gzform::formState.serverErrors -> formState.serverError seems to be missing from form's vue data object";
|
||||
@@ -355,7 +369,6 @@ export default {
|
||||
|
||||
//check for errors if we have any errors
|
||||
if (!window.$gz._.isEmpty(vm.formState.serverError)) {
|
||||
|
||||
//First let's get the top level error code
|
||||
|
||||
var apiErrorCode = parseInt(vm.formState.serverError.code);
|
||||
@@ -443,7 +456,8 @@ export default {
|
||||
//
|
||||
onChange(vm, ref) {
|
||||
//xeslint-disable-next-line
|
||||
//console.log("GZFORM::onChange triggered!");
|
||||
//WidgetCustom2
|
||||
//console.log("GZFORM::onChange triggered for field " + ref);
|
||||
if (triggeringChange || vm.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user