This commit is contained in:
2020-04-02 14:08:12 +00:00
parent 1384aef052
commit d212bd5524
2 changed files with 57 additions and 57 deletions

View File

@@ -1,5 +1,5 @@
/* Xeslint-disable */ /* Xeslint-disable */
var VM_LOCAL = null; let VM_LOCAL = null;
//Calculate a reasonable time to show the alert based on the size of the message and some sane bounds //Calculate a reasonable time to show the alert based on the size of the message and some sane bounds
//https://ux.stackexchange.com/a/85898 //https://ux.stackexchange.com/a/85898

View File

@@ -11,7 +11,7 @@
// Add any new keys used to the block in translation.js=>commonKeysEditForm // Add any new keys used to the block in translation.js=>commonKeysEditForm
import Vue from "vue"; import Vue from "vue";
var triggeringChange = false; let triggeringChange = false;
function isEmpty(o) { function isEmpty(o) {
if (typeof o == "number" && o == 0) { if (typeof o == "number" && o == 0) {
@@ -26,7 +26,7 @@ function isEmpty(o) {
//FROM HERE: https://stackoverflow.com/a/14794066/8939 //FROM HERE: https://stackoverflow.com/a/14794066/8939
//fast test if is an integer: //fast test if is an integer:
function isInt(value) { function isInt(value) {
var x; let x;
if (isNaN(value)) { if (isNaN(value)) {
return false; return false;
} }
@@ -46,12 +46,12 @@ function isNumber(n) {
// Get control from ref // Get control from ref
// //
function getControl(vm, ref) { function getControl(vm, ref) {
var ctrl = vm.$refs[ref]; let ctrl = vm.$refs[ref];
//I don't think this is reauired anymore //I don't think this is reauired anymore
// if (ctrl === undefined) { // if (ctrl === undefined) {
// //it's either a sub field in custom fields component or it's a coding error // //it's either a sub field in custom fields component or it's a coding error
// var customFields = vm.$refs["customFields"]; // let customFields = vm.$refs["customFields"];
// if (customFields !== undefined) { // if (customFields !== undefined) {
// ctrl = customFields.$refs[ref]; // ctrl = customFields.$refs[ref];
// } // }
@@ -64,11 +64,11 @@ function getControl(vm, ref) {
// Get value from control // Get value from control
// //
function getControlValue(ctrl) { function getControlValue(ctrl) {
var value = ctrl.value; let value = ctrl.value;
// if(value==undefined){ // if(value==undefined){
// debugger; // debugger;
// if(ctrl._props){ // if(ctrl._props){
// var subvalue=ctrl._props; // let subvalue=ctrl._props;
// } // }
// } // }
@@ -92,7 +92,7 @@ function getControlLabel(ctrl) {
// from server error collection // from server error collection
// //
function getErrorsForField(vm, ref) { function getErrorsForField(vm, ref) {
var ret = []; let ret = [];
if (ref == "errorbox") { if (ref == "errorbox") {
ret = window.$gz._.filter(vm.formState.serverError.details, function(o) { ret = window.$gz._.filter(vm.formState.serverError.details, function(o) {
return !o.target; return !o.target;
@@ -118,12 +118,12 @@ function getErrorsForField(vm, ref) {
// gathers any messages for error box on form which is the generic catch all for non field specific errors from server // gathers any messages for error box on form which is the generic catch all for non field specific errors from server
// and application itself locally // and application itself locally
function getErrorBoxErrors(vm, errs) { function getErrorBoxErrors(vm, errs) {
var hasErrors = false; let hasErrors = false;
var ret = ""; let ret = "";
if (errs.length > 0) { if (errs.length > 0) {
hasErrors = true; hasErrors = true;
//loop array and append each error to a return string //loop array and append each error to a return string
for (var i = 0; i < errs.length; i++) { for (let i = 0; i < errs.length; i++) {
ret += errs[i] + "\r\n"; ret += errs[i] + "\r\n";
} }
} }
@@ -150,19 +150,19 @@ export default {
return true; return true;
} }
var ctrl = getControl(vm, ref); let ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return true; return true;
} }
var value = getControlValue(ctrl); let value = getControlValue(ctrl);
if (!isEmpty(value)) { if (!isEmpty(value)) {
return true; return true;
} }
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
var err = window.$gz.translation.get("ErrorRequiredFieldEmpty"); let err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
var fieldName = getControlLabel(ctrl); let fieldName = getControlLabel(ctrl);
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
//lodash replace only replaces first instance so need to do it twice //lodash replace only replaces first instance so need to do it twice
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
@@ -180,12 +180,12 @@ export default {
if (vm.formState.loading) { if (vm.formState.loading) {
return true; return true;
} }
var ctrl = getControl(vm, ref); let ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return true; return true;
} }
var value = getControlValue(ctrl); let value = getControlValue(ctrl);
if (isEmpty(value)) { if (isEmpty(value)) {
return true; return true;
} }
@@ -193,8 +193,8 @@ export default {
if (value.length > max) { if (value.length > max) {
//get the translated rule text //get the translated rule text
// "ErrorFieldLengthExceeded": "{0} can not exceed {1} characters.", // "ErrorFieldLengthExceeded": "{0} can not exceed {1} characters.",
var err = window.$gz.translation.get("ErrorFieldLengthExceeded"); let err = window.$gz.translation.get("ErrorFieldLengthExceeded");
var fieldName = getControlLabel(ctrl); let fieldName = getControlLabel(ctrl);
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
err = window.$gz._.replace(err, "{1}", max); err = window.$gz._.replace(err, "{1}", max);
//Update the form status //Update the form status
@@ -224,22 +224,22 @@ export default {
if (vm.formState.loading) { if (vm.formState.loading) {
return true; return true;
} }
var ctrlStart = getControl(vm, refStart); let ctrlStart = getControl(vm, refStart);
if (typeof ctrlStart == "undefined") { if (typeof ctrlStart == "undefined") {
return true; return true;
} }
var ctrlEnd = getControl(vm, refEnd); let ctrlEnd = getControl(vm, refEnd);
if (typeof ctrlEnd == "undefined") { if (typeof ctrlEnd == "undefined") {
return true; return true;
} }
var valueStart = getControlValue(ctrlStart); let valueStart = getControlValue(ctrlStart);
if (isEmpty(valueStart)) { if (isEmpty(valueStart)) {
return true; return true;
} }
var valueEnd = getControlValue(ctrlEnd); let valueEnd = getControlValue(ctrlEnd);
if (isEmpty(valueEnd)) { if (isEmpty(valueEnd)) {
return true; return true;
} }
@@ -255,7 +255,7 @@ export default {
if (valueStart > valueEnd) { if (valueStart > valueEnd) {
// "ErrorStartDateAfterEndDate": "Start date must be earlier than stop / end date", // "ErrorStartDateAfterEndDate": "Start date must be earlier than stop / end date",
var err = window.$gz.translation.get("ErrorStartDateAfterEndDate"); let err = window.$gz.translation.get("ErrorStartDateAfterEndDate");
//Update the form status //Update the form status
this.setFormState({ this.setFormState({
vm: vm, vm: vm,
@@ -274,20 +274,20 @@ export default {
if (vm.formState.loading) { if (vm.formState.loading) {
return true; return true;
} }
var ctrlFirst = getControl(vm, refFirst); let ctrlFirst = getControl(vm, refFirst);
if (typeof ctrlFirst == "undefined") { if (typeof ctrlFirst == "undefined") {
return true; return true;
} }
var ctrlSecond = getControl(vm, refSecond); let ctrlSecond = getControl(vm, refSecond);
if (typeof ctrlSecond == "undefined") { if (typeof ctrlSecond == "undefined") {
return true; return true;
} }
var valueFirst = getControlValue(ctrlFirst); let valueFirst = getControlValue(ctrlFirst);
var valueSecond = getControlValue(ctrlSecond); let valueSecond = getControlValue(ctrlSecond);
if (valueFirst != valueSecond) { if (valueFirst != valueSecond) {
var err = window.$gz.translation.get("ErrorNoMatch"); let err = window.$gz.translation.get("ErrorNoMatch");
//Update the form status //Update the form status
this.setFormState({ this.setFormState({
vm: vm, vm: vm,
@@ -305,7 +305,7 @@ export default {
if (vm.formState.loading) { if (vm.formState.loading) {
return true; return true;
} }
var ctrl = getControl(vm, ref); let ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return true; return true;
} }
@@ -313,7 +313,7 @@ export default {
//DEBUG //DEBUG
//logControl("integerValid", ctrl, ref); //logControl("integerValid", ctrl, ref);
var value = getControlValue(ctrl); let value = getControlValue(ctrl);
if (isEmpty(value)) { if (isEmpty(value)) {
return true; return true;
} }
@@ -323,7 +323,7 @@ export default {
} }
// "ErrorFieldValueNotInteger": "Value must be an integer" // "ErrorFieldValueNotInteger": "Value must be an integer"
var err = window.$gz.translation.get("ErrorFieldValueNotInteger"); let err = window.$gz.translation.get("ErrorFieldValueNotInteger");
//Update the form status //Update the form status
this.setFormState({ this.setFormState({
vm: vm, vm: vm,
@@ -342,7 +342,7 @@ export default {
//TODO: Handle commas and spaces in numbers //TODO: Handle commas and spaces in numbers
//as per window.$gz.translation rules for numbers //as per window.$gz.translation rules for numbers
var ctrl = getControl(vm, ref); let ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return true; return true;
} }
@@ -350,7 +350,7 @@ export default {
//DEBUG //DEBUG
//logControl("decimalValid", ctrl, ref); //logControl("decimalValid", ctrl, ref);
var value = getControlValue(ctrl); let value = getControlValue(ctrl);
if (isEmpty(value)) { if (isEmpty(value)) {
return true; return true;
} }
@@ -360,7 +360,7 @@ export default {
} }
// "ErrorFieldValueNotDecimal": "Value must be a number" // "ErrorFieldValueNotDecimal": "Value must be a number"
var err = window.$gz.translation.get("ErrorFieldValueNotDecimal"); let err = window.$gz.translation.get("ErrorFieldValueNotDecimal");
//Update the form status //Update the form status
this.setFormState({ this.setFormState({
vm: vm, vm: vm,
@@ -377,7 +377,7 @@ export default {
return true; return true;
} }
var template = let template =
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey]; window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
if (template === undefined) { if (template === undefined) {
return true; return true;
@@ -386,7 +386,7 @@ export default {
//this is a collection of both custom field definitions and standard form fields that are required //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 //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 //_https://lodash.com/docs#find
var templateItem = window.$gz._.find(template, [ let templateItem = window.$gz._.find(template, [
"fld", "fld",
formCustomTemplateFieldName formCustomTemplateFieldName
]); ]);
@@ -396,19 +396,19 @@ export default {
return true; return true;
} }
var ctrl = getControl(vm, ref); let ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return true; return true;
} }
var value = getControlValue(ctrl); let value = getControlValue(ctrl);
if (!isEmpty(value)) { if (!isEmpty(value)) {
return true; return true;
} }
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
var err = window.$gz.translation.get("ErrorRequiredFieldEmpty"); let err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
var fieldName = getControlLabel(ctrl); let fieldName = getControlLabel(ctrl);
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
//lodash replace only replaces first instance so need to do it twice //lodash replace only replaces first instance so need to do it twice
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
@@ -439,7 +439,7 @@ export default {
return true; return true;
} }
var value = subvm.GetValueForField(templateItem.dataKey); let value = subvm.GetValueForField(templateItem.dataKey);
if (!isEmpty(value)) { if (!isEmpty(value)) {
return true; return true;
} }
@@ -447,8 +447,8 @@ export default {
//It's empty and it's required so return error //It's empty and it's required so return error
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
var err = window.$gz.translation.get("ErrorRequiredFieldEmpty"); let err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
//var fieldName = getControlLabel(ctrl); //let fieldName = getControlLabel(ctrl);
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
//lodash replace only replaces first instance so need to do it twice //lodash replace only replaces first instance so need to do it twice
err = window.$gz._.replace(err, "{0}", fieldName); err = window.$gz._.replace(err, "{0}", fieldName);
@@ -489,18 +489,18 @@ export default {
} }
} }
} }
var ret = []; let ret = [];
//check for errors if we have any errors //check for errors if we have any errors
if (!window.$gz._.isEmpty(vm.formState.serverError)) { if (!window.$gz._.isEmpty(vm.formState.serverError)) {
//First let's get the top level error code //First let's get the top level error code
var apiErrorCode = parseInt(vm.formState.serverError.code); let apiErrorCode = parseInt(vm.formState.serverError.code);
//GENERAL ERROR //GENERAL ERROR
if (ref == "errorbox") { if (ref == "errorbox") {
//Add any general errors to ret //Add any general errors to ret
var err = window.$gz.translation.get( let err = window.$gz.translation.get(
"ErrorAPI" + apiErrorCode.toString() "ErrorAPI" + apiErrorCode.toString()
); );
if (vm.formState.serverError.message) { if (vm.formState.serverError.message) {
@@ -518,13 +518,13 @@ export default {
//Specific field validation errors are in an array in "details" key //Specific field validation errors are in an array in "details" key
if (!window.$gz._.isEmpty(vm.formState.serverError.details)) { if (!window.$gz._.isEmpty(vm.formState.serverError.details)) {
//See if this key is in the details array //See if this key is in the details array
var errorsForField = getErrorsForField(vm, ref); let errorsForField = getErrorsForField(vm, ref);
if (errorsForField.length > 0) { if (errorsForField.length > 0) {
//iterate the errorsForField object and add each to return array of errors //iterate the errorsForField object and add each to return array of errors
window.$gz._.each(errorsForField, function(ve) { window.$gz._.each(errorsForField, function(ve) {
var fldErr = ""; let fldErr = "";
var fldErrorCode = parseInt(ve.error); let fldErrorCode = parseInt(ve.error);
fldErr = fldErr =
window.$gz.translation.get("ErrorAPI" + fldErrorCode.toString()) + window.$gz.translation.get("ErrorAPI" + fldErrorCode.toString()) +
" [" + " [" +
@@ -555,7 +555,7 @@ export default {
// NOTE: that in a form this should only be used with non stock-required fields, if they are already required they cannot be hidden // 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) { showMe(vm, formCustomTemplateFieldName) {
var template = let template =
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey]; window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
if (template === undefined) { if (template === undefined) {
return true; return true;
@@ -564,7 +564,7 @@ export default {
//this is a collection of both custom field definitions and standard form fields that are required //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 //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 //_https://lodash.com/docs#find
var templateItem = window.$gz._.find(template, [ let templateItem = window.$gz._.find(template, [
"fld", "fld",
formCustomTemplateFieldName formCustomTemplateFieldName
]); ]);
@@ -599,8 +599,8 @@ export default {
// Gather server errors and set the appropriate keys // Gather server errors and set the appropriate keys
// //
setErrorBoxErrors(vm) { setErrorBoxErrors(vm) {
var errs = this.serverErrors(vm, "errorbox"); let errs = this.serverErrors(vm, "errorbox");
var ret = getErrorBoxErrors(vm, errs); let ret = getErrorBoxErrors(vm, errs);
vm.formState.errorBoxMessage = ret; vm.formState.errorBoxMessage = ret;
}, },
/////////////////////////////// ///////////////////////////////
@@ -612,7 +612,7 @@ export default {
return; return;
} }
//If ref appears in the formState.serverErrors details collection, remove each one //If ref appears in the formState.serverErrors details collection, remove each one
var m = window.$gz._.remove(vm.formState.serverError.details, function(o) { let m = window.$gz._.remove(vm.formState.serverError.details, function(o) {
if (!o.target) { if (!o.target) {
return false; return false;
} }
@@ -636,7 +636,7 @@ export default {
//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
if (m.length > 0) { if (m.length > 0) {
triggeringChange = true; triggeringChange = true;
var val = vm.obj[ref]; let val = vm.obj[ref];
vm.obj[ref] = null; vm.obj[ref] = null;
vm.obj[ref] = val; vm.obj[ref] = val;
triggeringChange = false; triggeringChange = false;
@@ -685,7 +685,7 @@ export default {
// and temporary ones are stored in session storage and don't persist a refresh // and temporary ones are stored in session storage and don't persist a refresh
// //
getFormSettings(formKey) { getFormSettings(formKey) {
var formSettings = { let formSettings = {
temp: JSON.parse(sessionStorage.getItem(formKey)), temp: JSON.parse(sessionStorage.getItem(formKey)),
saved: window.$gz.store.state.formSettings[formKey] saved: window.$gz.store.state.formSettings[formKey]
}; };