This commit is contained in:
2019-11-27 20:55:43 +00:00
parent c3ea911e1e
commit efd602b689
3 changed files with 59 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
/* XXeslint-disable */
/* xeslint-disable */
///////////////////////////////
// gzform
//
@@ -342,6 +342,57 @@ export default {
return err;
},
///////////////////////////////
// USER REQUIRED FIELDS
// (Fields defined by AyaNova users as required on form that are not stock required already)
//
userRequiredFields(vm, ref, userRequiredFieldName) {
if (vm.formState.loading) {
return false;
}
var template =
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
if (template === undefined) {
return false;
}
//See if control ref 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
]);
//templateItem.required is a string value, not a boolean value
if (templateItem === undefined || templateItem.required !== "true") {
return false;
}
var ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") {
return false;
}
var value = getControlValue(ctrl);
if (!isEmpty(value)) {
return false;
}
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
var err = window.$gz.locale.get("ErrorRequiredFieldEmpty");
var fieldName = getControlLabel(ctrl);
err = window.$gz._.replace(err, "{0}", fieldName);
//lodash replace only replaces first instance so need to do it twice
err = window.$gz._.replace(err, "{0}", fieldName);
//Update the form status
this.setFormState({
vm: vm,
valid: false
});
return err;
},
///////////////////////////////
// CUSTOMFIELDS
// For now the only rule is that they can be required or not
//