This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* 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
|
||||
//https://ux.stackexchange.com/a/85898
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// Add any new keys used to the block in translation.js=>commonKeysEditForm
|
||||
import Vue from "vue";
|
||||
|
||||
var triggeringChange = false;
|
||||
let triggeringChange = false;
|
||||
|
||||
function isEmpty(o) {
|
||||
if (typeof o == "number" && o == 0) {
|
||||
@@ -26,7 +26,7 @@ function isEmpty(o) {
|
||||
//FROM HERE: https://stackoverflow.com/a/14794066/8939
|
||||
//fast test if is an integer:
|
||||
function isInt(value) {
|
||||
var x;
|
||||
let x;
|
||||
if (isNaN(value)) {
|
||||
return false;
|
||||
}
|
||||
@@ -46,12 +46,12 @@ function isNumber(n) {
|
||||
// Get control from ref
|
||||
//
|
||||
function getControl(vm, ref) {
|
||||
var ctrl = vm.$refs[ref];
|
||||
let ctrl = vm.$refs[ref];
|
||||
|
||||
//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"];
|
||||
// let customFields = vm.$refs["customFields"];
|
||||
// if (customFields !== undefined) {
|
||||
// ctrl = customFields.$refs[ref];
|
||||
// }
|
||||
@@ -64,11 +64,11 @@ function getControl(vm, ref) {
|
||||
// Get value from control
|
||||
//
|
||||
function getControlValue(ctrl) {
|
||||
var value = ctrl.value;
|
||||
let value = ctrl.value;
|
||||
// if(value==undefined){
|
||||
// debugger;
|
||||
// if(ctrl._props){
|
||||
// var subvalue=ctrl._props;
|
||||
// let subvalue=ctrl._props;
|
||||
|
||||
// }
|
||||
// }
|
||||
@@ -92,7 +92,7 @@ function getControlLabel(ctrl) {
|
||||
// from server error collection
|
||||
//
|
||||
function getErrorsForField(vm, ref) {
|
||||
var ret = [];
|
||||
let ret = [];
|
||||
if (ref == "errorbox") {
|
||||
ret = window.$gz._.filter(vm.formState.serverError.details, function(o) {
|
||||
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
|
||||
// and application itself locally
|
||||
function getErrorBoxErrors(vm, errs) {
|
||||
var hasErrors = false;
|
||||
var ret = "";
|
||||
let hasErrors = false;
|
||||
let ret = "";
|
||||
if (errs.length > 0) {
|
||||
hasErrors = true;
|
||||
//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";
|
||||
}
|
||||
}
|
||||
@@ -150,19 +150,19 @@ export default {
|
||||
return true;
|
||||
}
|
||||
|
||||
var ctrl = getControl(vm, ref);
|
||||
let ctrl = getControl(vm, ref);
|
||||
if (typeof ctrl == "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var value = getControlValue(ctrl);
|
||||
let value = getControlValue(ctrl);
|
||||
if (!isEmpty(value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
||||
var err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
|
||||
var fieldName = getControlLabel(ctrl);
|
||||
let err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
|
||||
let 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);
|
||||
@@ -180,12 +180,12 @@ export default {
|
||||
if (vm.formState.loading) {
|
||||
return true;
|
||||
}
|
||||
var ctrl = getControl(vm, ref);
|
||||
let ctrl = getControl(vm, ref);
|
||||
if (typeof ctrl == "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var value = getControlValue(ctrl);
|
||||
let value = getControlValue(ctrl);
|
||||
if (isEmpty(value)) {
|
||||
return true;
|
||||
}
|
||||
@@ -193,8 +193,8 @@ export default {
|
||||
if (value.length > max) {
|
||||
//get the translated rule text
|
||||
// "ErrorFieldLengthExceeded": "{0} can not exceed {1} characters.",
|
||||
var err = window.$gz.translation.get("ErrorFieldLengthExceeded");
|
||||
var fieldName = getControlLabel(ctrl);
|
||||
let err = window.$gz.translation.get("ErrorFieldLengthExceeded");
|
||||
let fieldName = getControlLabel(ctrl);
|
||||
err = window.$gz._.replace(err, "{0}", fieldName);
|
||||
err = window.$gz._.replace(err, "{1}", max);
|
||||
//Update the form status
|
||||
@@ -224,22 +224,22 @@ export default {
|
||||
if (vm.formState.loading) {
|
||||
return true;
|
||||
}
|
||||
var ctrlStart = getControl(vm, refStart);
|
||||
let ctrlStart = getControl(vm, refStart);
|
||||
if (typeof ctrlStart == "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var ctrlEnd = getControl(vm, refEnd);
|
||||
let ctrlEnd = getControl(vm, refEnd);
|
||||
if (typeof ctrlEnd == "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var valueStart = getControlValue(ctrlStart);
|
||||
let valueStart = getControlValue(ctrlStart);
|
||||
if (isEmpty(valueStart)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var valueEnd = getControlValue(ctrlEnd);
|
||||
let valueEnd = getControlValue(ctrlEnd);
|
||||
if (isEmpty(valueEnd)) {
|
||||
return true;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ export default {
|
||||
|
||||
if (valueStart > valueEnd) {
|
||||
// "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
|
||||
this.setFormState({
|
||||
vm: vm,
|
||||
@@ -274,20 +274,20 @@ export default {
|
||||
if (vm.formState.loading) {
|
||||
return true;
|
||||
}
|
||||
var ctrlFirst = getControl(vm, refFirst);
|
||||
let ctrlFirst = getControl(vm, refFirst);
|
||||
if (typeof ctrlFirst == "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var ctrlSecond = getControl(vm, refSecond);
|
||||
let ctrlSecond = getControl(vm, refSecond);
|
||||
if (typeof ctrlSecond == "undefined") {
|
||||
return true;
|
||||
}
|
||||
var valueFirst = getControlValue(ctrlFirst);
|
||||
var valueSecond = getControlValue(ctrlSecond);
|
||||
let valueFirst = getControlValue(ctrlFirst);
|
||||
let valueSecond = getControlValue(ctrlSecond);
|
||||
|
||||
if (valueFirst != valueSecond) {
|
||||
var err = window.$gz.translation.get("ErrorNoMatch");
|
||||
let err = window.$gz.translation.get("ErrorNoMatch");
|
||||
//Update the form status
|
||||
this.setFormState({
|
||||
vm: vm,
|
||||
@@ -305,7 +305,7 @@ export default {
|
||||
if (vm.formState.loading) {
|
||||
return true;
|
||||
}
|
||||
var ctrl = getControl(vm, ref);
|
||||
let ctrl = getControl(vm, ref);
|
||||
if (typeof ctrl == "undefined") {
|
||||
return true;
|
||||
}
|
||||
@@ -313,7 +313,7 @@ export default {
|
||||
//DEBUG
|
||||
//logControl("integerValid", ctrl, ref);
|
||||
|
||||
var value = getControlValue(ctrl);
|
||||
let value = getControlValue(ctrl);
|
||||
if (isEmpty(value)) {
|
||||
return true;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ export default {
|
||||
}
|
||||
|
||||
// "ErrorFieldValueNotInteger": "Value must be an integer"
|
||||
var err = window.$gz.translation.get("ErrorFieldValueNotInteger");
|
||||
let err = window.$gz.translation.get("ErrorFieldValueNotInteger");
|
||||
//Update the form status
|
||||
this.setFormState({
|
||||
vm: vm,
|
||||
@@ -342,7 +342,7 @@ export default {
|
||||
//TODO: Handle commas and spaces in numbers
|
||||
//as per window.$gz.translation rules for numbers
|
||||
|
||||
var ctrl = getControl(vm, ref);
|
||||
let ctrl = getControl(vm, ref);
|
||||
if (typeof ctrl == "undefined") {
|
||||
return true;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ export default {
|
||||
//DEBUG
|
||||
//logControl("decimalValid", ctrl, ref);
|
||||
|
||||
var value = getControlValue(ctrl);
|
||||
let value = getControlValue(ctrl);
|
||||
if (isEmpty(value)) {
|
||||
return true;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ export default {
|
||||
}
|
||||
|
||||
// "ErrorFieldValueNotDecimal": "Value must be a number"
|
||||
var err = window.$gz.translation.get("ErrorFieldValueNotDecimal");
|
||||
let err = window.$gz.translation.get("ErrorFieldValueNotDecimal");
|
||||
//Update the form status
|
||||
this.setFormState({
|
||||
vm: vm,
|
||||
@@ -377,7 +377,7 @@ export default {
|
||||
return true;
|
||||
}
|
||||
|
||||
var template =
|
||||
let template =
|
||||
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
|
||||
if (template === undefined) {
|
||||
return true;
|
||||
@@ -386,7 +386,7 @@ export default {
|
||||
//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, [
|
||||
let templateItem = window.$gz._.find(template, [
|
||||
"fld",
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
@@ -396,19 +396,19 @@ export default {
|
||||
return true;
|
||||
}
|
||||
|
||||
var ctrl = getControl(vm, ref);
|
||||
let ctrl = getControl(vm, ref);
|
||||
if (typeof ctrl == "undefined") {
|
||||
return true;
|
||||
}
|
||||
|
||||
var value = getControlValue(ctrl);
|
||||
let value = getControlValue(ctrl);
|
||||
if (!isEmpty(value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
||||
var err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
|
||||
var fieldName = getControlLabel(ctrl);
|
||||
let err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
|
||||
let 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);
|
||||
@@ -439,7 +439,7 @@ export default {
|
||||
return true;
|
||||
}
|
||||
|
||||
var value = subvm.GetValueForField(templateItem.dataKey);
|
||||
let value = subvm.GetValueForField(templateItem.dataKey);
|
||||
if (!isEmpty(value)) {
|
||||
return true;
|
||||
}
|
||||
@@ -447,8 +447,8 @@ export default {
|
||||
//It's empty and it's required so return error
|
||||
|
||||
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
||||
var err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
|
||||
//var fieldName = getControlLabel(ctrl);
|
||||
let err = window.$gz.translation.get("ErrorRequiredFieldEmpty");
|
||||
//let 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);
|
||||
@@ -489,18 +489,18 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
var ret = [];
|
||||
let ret = [];
|
||||
|
||||
//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);
|
||||
let apiErrorCode = parseInt(vm.formState.serverError.code);
|
||||
|
||||
//GENERAL ERROR
|
||||
if (ref == "errorbox") {
|
||||
//Add any general errors to ret
|
||||
var err = window.$gz.translation.get(
|
||||
let err = window.$gz.translation.get(
|
||||
"ErrorAPI" + apiErrorCode.toString()
|
||||
);
|
||||
if (vm.formState.serverError.message) {
|
||||
@@ -518,13 +518,13 @@ export default {
|
||||
//Specific field validation errors are in an array in "details" key
|
||||
if (!window.$gz._.isEmpty(vm.formState.serverError.details)) {
|
||||
//See if this key is in the details array
|
||||
var errorsForField = getErrorsForField(vm, ref);
|
||||
let errorsForField = getErrorsForField(vm, ref);
|
||||
|
||||
if (errorsForField.length > 0) {
|
||||
//iterate the errorsForField object and add each to return array of errors
|
||||
window.$gz._.each(errorsForField, function(ve) {
|
||||
var fldErr = "";
|
||||
var fldErrorCode = parseInt(ve.error);
|
||||
let fldErr = "";
|
||||
let fldErrorCode = parseInt(ve.error);
|
||||
fldErr =
|
||||
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
|
||||
//
|
||||
showMe(vm, formCustomTemplateFieldName) {
|
||||
var template =
|
||||
let template =
|
||||
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
|
||||
if (template === undefined) {
|
||||
return true;
|
||||
@@ -564,7 +564,7 @@ export default {
|
||||
//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, [
|
||||
let templateItem = window.$gz._.find(template, [
|
||||
"fld",
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
@@ -599,8 +599,8 @@ export default {
|
||||
// Gather server errors and set the appropriate keys
|
||||
//
|
||||
setErrorBoxErrors(vm) {
|
||||
var errs = this.serverErrors(vm, "errorbox");
|
||||
var ret = getErrorBoxErrors(vm, errs);
|
||||
let errs = this.serverErrors(vm, "errorbox");
|
||||
let ret = getErrorBoxErrors(vm, errs);
|
||||
vm.formState.errorBoxMessage = ret;
|
||||
},
|
||||
///////////////////////////////
|
||||
@@ -612,7 +612,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
//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) {
|
||||
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
|
||||
if (m.length > 0) {
|
||||
triggeringChange = true;
|
||||
var val = vm.obj[ref];
|
||||
let val = vm.obj[ref];
|
||||
vm.obj[ref] = null;
|
||||
vm.obj[ref] = val;
|
||||
triggeringChange = false;
|
||||
@@ -685,7 +685,7 @@ export default {
|
||||
// and temporary ones are stored in session storage and don't persist a refresh
|
||||
//
|
||||
getFormSettings(formKey) {
|
||||
var formSettings = {
|
||||
let formSettings = {
|
||||
temp: JSON.parse(sessionStorage.getItem(formKey)),
|
||||
saved: window.$gz.store.state.formSettings[formKey]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user