This commit is contained in:
@@ -47,20 +47,14 @@ 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";
|
||||
//I don't think this is reauired anymore
|
||||
// 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];
|
||||
// }
|
||||
// }
|
||||
|
||||
return ctrl;
|
||||
@@ -345,7 +339,7 @@ export default {
|
||||
// USER REQUIRED FIELDS
|
||||
// (Fields defined by AyaNova users as required on form that are not stock required already)
|
||||
//
|
||||
userRequiredFields(vm, ref, userRequiredFieldName) {
|
||||
userRequiredFields(vm, ref, formCustomTemplateFieldName) {
|
||||
if (vm.formState.loading) {
|
||||
return false;
|
||||
}
|
||||
@@ -355,13 +349,13 @@ export default {
|
||||
if (template === undefined) {
|
||||
return false;
|
||||
}
|
||||
//See if control ref is in server required fields collection
|
||||
//See if control formCustomTemplateFieldName is in server required fields collection
|
||||
//this is a collection of both custom field definitions and standard form fields that are required
|
||||
//since all names are unique can just filter out the one we need by name which will inherently ignore custom fields by default
|
||||
//_https://lodash.com/docs#find
|
||||
var templateItem = window.$gz._.find(template, [
|
||||
"fld",
|
||||
userRequiredFieldName
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
|
||||
//templateItem.required is a string value, not a boolean value
|
||||
@@ -521,6 +515,34 @@ export default {
|
||||
//default if no error message to display
|
||||
return ret;
|
||||
},
|
||||
///////////////////////////////
|
||||
// ShowMe
|
||||
// (returns false if the field has been set to hidden by the user in the formcustomtemplate)
|
||||
// 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) {
|
||||
var template =
|
||||
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
|
||||
if (template === undefined) {
|
||||
return true;
|
||||
}
|
||||
//See if control templateFieldName is in server required fields collection
|
||||
//this is a collection of both custom field definitions and standard form fields that are required
|
||||
//since all names are unique can just filter out the one we need by name which will inherently ignore custom fields by default
|
||||
//_https://lodash.com/docs#find
|
||||
var templateItem = window.$gz._.find(template, [
|
||||
"fld",
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
|
||||
//templateItem.required is a string value, not a boolean value
|
||||
if (templateItem === undefined || templateItem.hide !== "true") {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Only here if we have a record in the custom template for this particular field and it's set to hide:"true"
|
||||
return false;
|
||||
},
|
||||
|
||||
///////////////////////////////
|
||||
// ClearformState.serverErrors
|
||||
|
||||
Reference in New Issue
Block a user