refactoring, renaming capitalized functions to proper case, etc

This commit is contained in:
2019-04-18 20:06:53 +00:00
parent 8cdae969fb
commit 5caae16a83
7 changed files with 75 additions and 72 deletions

View File

@@ -30,7 +30,7 @@ function dealWithError(msg, form) {
}
}
form.appError = msg;
form.$gzv.SetErrorBoxErrors(form);
form.$gzv.setErrorBoxErrors(form);
}
}
export default {

View File

@@ -9,7 +9,7 @@ export default {
// Clear all properties from object without resorting to assigning a new object (o={})
// which can be problematic in some cases (IE bugs, watched data items in forms etc)
RemoveAllPropertiesFromObject(o) {
removeAllPropertiesFromObject(o) {
for (var variableKey in o) {
if (o.hasOwnProperty(variableKey)) {
delete o[variableKey];

View File

@@ -95,7 +95,7 @@ function getErrorsForField(v, ref) {
// ERROR BOX ERRORS
// 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(v, errs) {
function getErrorBoxErrors(v, errs) {
var hasErrors = false;
var ret = "";
if (errs.length > 0) {
@@ -123,7 +123,7 @@ export default {
///////////////////////////////
// REQUIRED
//
Required(v, ref) {
required(v, ref) {
var ctrl = getControl(v, ref);
if (typeof ctrl == "undefined") {
return false;
@@ -145,7 +145,7 @@ export default {
///////////////////////////////
// MAXLENGTH
//
MaxLength(v, ref, max) {
maxLength(v, ref, max) {
var ctrl = getControl(v, ref);
if (typeof ctrl == "undefined") {
return false;
@@ -171,12 +171,14 @@ export default {
///////////////////////////////
// MAX 255
//
Max255(v, ref) {
return this.MaxLength(v, ref, 255);
max255(v, ref) {
return this.maxLength(v, ref, 255);
},
///////////////////////////////
// AFTER
After(v, refStart, refEnd) {
// DatePrecedence
// (start date must precede end date)
//
datePrecedence(v, refStart, refEnd) {
var ctrlStart = getControl(v, refStart);
if (typeof ctrlStart == "undefined") {
return false;
@@ -214,16 +216,16 @@ export default {
}
},
///////////////////////////////
// INTEGER
// INTEGER IS VALID
//
Integer(v, ref) {
integerValid(v, ref) {
var ctrl = getControl(v, ref);
if (typeof ctrl == "undefined") {
return false;
}
//DEBUG
//logControl("Integer", ctrl, ref);
//logControl("integerValid", ctrl, ref);
var value = getControlValue(ctrl);
if (isEmpty(value)) {
@@ -242,7 +244,8 @@ export default {
///////////////////////////////
// DECIMAL
// Basically anything that can be a number is valid
Decimal(v, ref) {
//
decimalValid(v, ref) {
//TODO: Handle commas and spaces in numbers
//as per v.$gzlocale rules for numbers
@@ -252,7 +255,7 @@ export default {
}
//DEBUG
//logControl("Decimal", ctrl, ref);
//logControl("decimalValid", ctrl, ref);
var value = getControlValue(ctrl);
if (isEmpty(value)) {
@@ -272,29 +275,29 @@ export default {
// SERVER ERRORS
// Process and return server errors if any for form and field specified
//
ServerErrors(v, ref) {
serverErrors(v, ref) {
//CHECK PREREQUISITES IN DEV MODE TO ENSURE FORM ISN"T MISSING NEEDED DATA ATTRIBUTES ETC
if (v.$gzdevmode()) {
//make sure serverErrors is defined on data
if (!v.$_.has(v, "serverError")) {
throw "DEV ERROR gzvalidate::ServerErrors -> serverError seems to be missing from form's vue data object";
throw "DEV ERROR gzvalidate::serverErrors -> serverError seems to be missing from form's vue data object";
}
//make sure appError is defined on data
if (!v.$_.has(v, "appError")) {
throw "DEV ERROR gzvalidate::ServerErrors -> appError seems to be missing from form's vue data object";
throw "DEV ERROR gzvalidate::serverErrors -> appError seems to be missing from form's vue data object";
}
//make sure errorBoxMessage is defined on data
if (!v.$_.has(v, "errorBoxMessage")) {
throw "DEV ERROR gzvalidate::ServerErrors -> errorBoxMessage seems to be missing from form's vue data object";
throw "DEV ERROR gzvalidate::serverErrors -> errorBoxMessage seems to be missing from form's vue data object";
}
//ensure the error returned is in an expected format to catch coding errors at the server end
if (!v.$_.isEmpty(v.serverError)) {
//Make sure there is an error code if there is an error collection
if (!v.serverError.code) {
throw "DEV ERROR gzvalidate::ServerErrors -> server returned error without code";
throw "DEV ERROR gzvalidate::serverErrors -> server returned error without code";
}
}
}
@@ -317,7 +320,7 @@ export default {
ret.push(err);
}
//DETAIL ERRORS
//{"error":{"code":"2200","details":[{"message":"Exception: Error converting value \"\" to type 'AyaNova.Biz.AuthorizationRoles'. Path 'roles', line 1, position 141.","target":"roles","error":"2203"}],"message":"Object did not pass validation"}}
//{"error":{"code":"2200","details":[{"message":"Exception: Error converting value \"\" to type 'AyaNova.Biz.AUTHORIZATION_ROLES'. Path 'roles', line 1, position 141.","target":"roles","error":"2203"}],"message":"Object did not pass validation"}}
//Specific field validation errors are in an array in "details" key
if (!v.$_.isEmpty(v.serverError.details)) {
//See if this key is in the details array
@@ -352,28 +355,28 @@ export default {
// ClearServerErrors
// Clear all server errors and app errors and ensure error box doesn't show
//
DeleteAllErrorBoxErrors(v) {
deleteAllErrorBoxErrors(v) {
//clear all keys from server error
v.$gzutil.RemoveAllPropertiesFromObject(v.serverError);
v.$gzutil.removeAllPropertiesFromObject(v.serverError);
//clear app errors
v.appError = null;
//clear out actual message box display
v.errorBoxMessage = null;
},
///////////////////////////////
// SetErrorBoxErrors
// setErrorBoxErrors
// Gather server errors and set the appropriate keys
//
SetErrorBoxErrors(v) {
var errs = this.ServerErrors(v, "errorbox");
var ret = GetErrorBoxErrors(v, errs);
setErrorBoxErrors(v) {
var errs = this.serverErrors(v, "errorbox");
var ret = getErrorBoxErrors(v, errs);
v.errorBoxMessage = ret;
},
///////////////////////////////
// On Change handler
// On onChange handler
// This is required so that server errors can be cleared when input is changed
//
Change(v, ref) {
onChange(v, ref) {
if (triggeringChange) {
return;
}
@@ -389,7 +392,7 @@ export default {
if (v.serverError.details && v.serverError.details.length < 1) {
if (v.serverError.code == "2200") {
//clear all keys from server error
v.$gzutil.RemoveAllPropertiesFromObject(v.serverError);
v.$gzutil.removeAllPropertiesFromObject(v.serverError);
}
}

View File

@@ -26,29 +26,29 @@ export default function initialize() {
addNavItem(locale.get("Home"), "home", "/");
if (
roles.hasRole(roles.AuthorizationRoles.TechLimited) ||
roles.hasRole(roles.AuthorizationRoles.TechFull) ||
roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) ||
roles.hasRole(roles.AuthorizationRoles.SubContractorFull)
roles.hasRole(roles.AUTHORIZATION_ROLES.TechLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.TechFull) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.SubContractorLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.SubContractorFull)
) {
addNavItem(locale.get("Service"), "toolbox", "/service");
}
if (
roles.hasRole(roles.AuthorizationRoles.DispatchLimited) ||
roles.hasRole(roles.AuthorizationRoles.DispatchFull)
roles.hasRole(roles.AUTHORIZATION_ROLES.DispatchLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.DispatchFull)
) {
addNavItem(locale.get("Dispatch"), "shipping-fast", "/dispatch");
}
if (
roles.hasRole(roles.AuthorizationRoles.InventoryLimited) ||
roles.hasRole(roles.AuthorizationRoles.InventoryFull)
roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryFull)
) {
addNavItem(locale.get("Inventory"), "dolly", "/inventory");
}
if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) {
if (roles.hasRole(roles.AUTHORIZATION_ROLES.AccountingFull)) {
addNavItem(
locale.get("Accounting"),
"file-invoice-dollar",
@@ -57,15 +57,15 @@ export default function initialize() {
}
if (
roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) ||
roles.hasRole(roles.AuthorizationRoles.BizAdminFull)
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminFull)
) {
addNavItem(locale.get("Administration"), "user-tie", "/admin");
}
if (
roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) ||
roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited)
roles.hasRole(roles.AUTHORIZATION_ROLES.OpsAdminFull) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.OpsAdminLimited)
) {
addNavItem(locale.get("Operations"), "cogs", "ops");
}

View File

@@ -1,6 +1,6 @@
import store from "../store";
export default {
AuthorizationRoles: {
AUTHORIZATION_ROLES: {
///<summary>No role set</summary>
NoRole: 0,
///<summary>BizAdminLimited</summary>