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

@@ -255,7 +255,7 @@ Make all fields work according to specs below
- Use browser Numeric format - Use browser Numeric format
- Override browser with these numeric format settings instead (see below) - Override browser with these numeric format settings instead (see below)
- Digit grouping symbol i.e. the , in 1,000,000 - Digit grouping symbol i.e. the , in 1,000,000
- Decimal symbol i.e. the . in 1.00 - decimalValid symbol i.e. the . in 1.00
- Currency symbol string (may be more than one character in some locales i.e. "Eur") - Currency symbol string (may be more than one character in some locales i.e. "Eur")
- negative display format one of these: -1.1, (1.1), 1.1- - negative display format one of these: -1.1, (1.1), 1.1-
- Use browser Datetime format - Use browser Datetime format

View File

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

View File

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

View File

@@ -95,7 +95,7 @@ function getErrorsForField(v, ref) {
// ERROR BOX ERRORS // ERROR BOX ERRORS
// 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(v, errs) { function getErrorBoxErrors(v, errs) {
var hasErrors = false; var hasErrors = false;
var ret = ""; var ret = "";
if (errs.length > 0) { if (errs.length > 0) {
@@ -123,7 +123,7 @@ export default {
/////////////////////////////// ///////////////////////////////
// REQUIRED // REQUIRED
// //
Required(v, ref) { required(v, ref) {
var ctrl = getControl(v, ref); var ctrl = getControl(v, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return false; return false;
@@ -145,7 +145,7 @@ export default {
/////////////////////////////// ///////////////////////////////
// MAXLENGTH // MAXLENGTH
// //
MaxLength(v, ref, max) { maxLength(v, ref, max) {
var ctrl = getControl(v, ref); var ctrl = getControl(v, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return false; return false;
@@ -171,12 +171,14 @@ export default {
/////////////////////////////// ///////////////////////////////
// MAX 255 // MAX 255
// //
Max255(v, ref) { max255(v, ref) {
return this.MaxLength(v, ref, 255); return this.maxLength(v, ref, 255);
}, },
/////////////////////////////// ///////////////////////////////
// AFTER // DatePrecedence
After(v, refStart, refEnd) { // (start date must precede end date)
//
datePrecedence(v, refStart, refEnd) {
var ctrlStart = getControl(v, refStart); var ctrlStart = getControl(v, refStart);
if (typeof ctrlStart == "undefined") { if (typeof ctrlStart == "undefined") {
return false; return false;
@@ -214,16 +216,16 @@ export default {
} }
}, },
/////////////////////////////// ///////////////////////////////
// INTEGER // INTEGER IS VALID
// //
Integer(v, ref) { integerValid(v, ref) {
var ctrl = getControl(v, ref); var ctrl = getControl(v, ref);
if (typeof ctrl == "undefined") { if (typeof ctrl == "undefined") {
return false; return false;
} }
//DEBUG //DEBUG
//logControl("Integer", ctrl, ref); //logControl("integerValid", ctrl, ref);
var value = getControlValue(ctrl); var value = getControlValue(ctrl);
if (isEmpty(value)) { if (isEmpty(value)) {
@@ -242,7 +244,8 @@ export default {
/////////////////////////////// ///////////////////////////////
// DECIMAL // DECIMAL
// Basically anything that can be a number is valid // Basically anything that can be a number is valid
Decimal(v, ref) { //
decimalValid(v, ref) {
//TODO: Handle commas and spaces in numbers //TODO: Handle commas and spaces in numbers
//as per v.$gzlocale rules for numbers //as per v.$gzlocale rules for numbers
@@ -252,7 +255,7 @@ export default {
} }
//DEBUG //DEBUG
//logControl("Decimal", ctrl, ref); //logControl("decimalValid", ctrl, ref);
var value = getControlValue(ctrl); var value = getControlValue(ctrl);
if (isEmpty(value)) { if (isEmpty(value)) {
@@ -272,29 +275,29 @@ export default {
// SERVER ERRORS // SERVER ERRORS
// Process and return server errors if any for form and field specified // 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 //CHECK PREREQUISITES IN DEV MODE TO ENSURE FORM ISN"T MISSING NEEDED DATA ATTRIBUTES ETC
if (v.$gzdevmode()) { if (v.$gzdevmode()) {
//make sure serverErrors is defined on data //make sure serverErrors is defined on data
if (!v.$_.has(v, "serverError")) { 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 //make sure appError is defined on data
if (!v.$_.has(v, "appError")) { 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 //make sure errorBoxMessage is defined on data
if (!v.$_.has(v, "errorBoxMessage")) { 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 //ensure the error returned is in an expected format to catch coding errors at the server end
if (!v.$_.isEmpty(v.serverError)) { if (!v.$_.isEmpty(v.serverError)) {
//Make sure there is an error code if there is an error collection //Make sure there is an error code if there is an error collection
if (!v.serverError.code) { 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); ret.push(err);
} }
//DETAIL ERRORS //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 //Specific field validation errors are in an array in "details" key
if (!v.$_.isEmpty(v.serverError.details)) { if (!v.$_.isEmpty(v.serverError.details)) {
//See if this key is in the details array //See if this key is in the details array
@@ -352,28 +355,28 @@ export default {
// ClearServerErrors // ClearServerErrors
// Clear all server errors and app errors and ensure error box doesn't show // Clear all server errors and app errors and ensure error box doesn't show
// //
DeleteAllErrorBoxErrors(v) { deleteAllErrorBoxErrors(v) {
//clear all keys from server error //clear all keys from server error
v.$gzutil.RemoveAllPropertiesFromObject(v.serverError); v.$gzutil.removeAllPropertiesFromObject(v.serverError);
//clear app errors //clear app errors
v.appError = null; v.appError = null;
//clear out actual message box display //clear out actual message box display
v.errorBoxMessage = null; v.errorBoxMessage = null;
}, },
/////////////////////////////// ///////////////////////////////
// SetErrorBoxErrors // setErrorBoxErrors
// Gather server errors and set the appropriate keys // Gather server errors and set the appropriate keys
// //
SetErrorBoxErrors(v) { setErrorBoxErrors(v) {
var errs = this.ServerErrors(v, "errorbox"); var errs = this.serverErrors(v, "errorbox");
var ret = GetErrorBoxErrors(v, errs); var ret = getErrorBoxErrors(v, errs);
v.errorBoxMessage = ret; v.errorBoxMessage = ret;
}, },
/////////////////////////////// ///////////////////////////////
// On Change handler // On onChange handler
// This is required so that server errors can be cleared when input is changed // This is required so that server errors can be cleared when input is changed
// //
Change(v, ref) { onChange(v, ref) {
if (triggeringChange) { if (triggeringChange) {
return; return;
} }
@@ -389,7 +392,7 @@ export default {
if (v.serverError.details && v.serverError.details.length < 1) { if (v.serverError.details && v.serverError.details.length < 1) {
if (v.serverError.code == "2200") { if (v.serverError.code == "2200") {
//clear all keys from server error //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", "/"); addNavItem(locale.get("Home"), "home", "/");
if ( if (
roles.hasRole(roles.AuthorizationRoles.TechLimited) || roles.hasRole(roles.AUTHORIZATION_ROLES.TechLimited) ||
roles.hasRole(roles.AuthorizationRoles.TechFull) || roles.hasRole(roles.AUTHORIZATION_ROLES.TechFull) ||
roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) || roles.hasRole(roles.AUTHORIZATION_ROLES.SubContractorLimited) ||
roles.hasRole(roles.AuthorizationRoles.SubContractorFull) roles.hasRole(roles.AUTHORIZATION_ROLES.SubContractorFull)
) { ) {
addNavItem(locale.get("Service"), "toolbox", "/service"); addNavItem(locale.get("Service"), "toolbox", "/service");
} }
if ( if (
roles.hasRole(roles.AuthorizationRoles.DispatchLimited) || roles.hasRole(roles.AUTHORIZATION_ROLES.DispatchLimited) ||
roles.hasRole(roles.AuthorizationRoles.DispatchFull) roles.hasRole(roles.AUTHORIZATION_ROLES.DispatchFull)
) { ) {
addNavItem(locale.get("Dispatch"), "shipping-fast", "/dispatch"); addNavItem(locale.get("Dispatch"), "shipping-fast", "/dispatch");
} }
if ( if (
roles.hasRole(roles.AuthorizationRoles.InventoryLimited) || roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryLimited) ||
roles.hasRole(roles.AuthorizationRoles.InventoryFull) roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryFull)
) { ) {
addNavItem(locale.get("Inventory"), "dolly", "/inventory"); addNavItem(locale.get("Inventory"), "dolly", "/inventory");
} }
if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) { if (roles.hasRole(roles.AUTHORIZATION_ROLES.AccountingFull)) {
addNavItem( addNavItem(
locale.get("Accounting"), locale.get("Accounting"),
"file-invoice-dollar", "file-invoice-dollar",
@@ -57,15 +57,15 @@ export default function initialize() {
} }
if ( if (
roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) || roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminLimited) ||
roles.hasRole(roles.AuthorizationRoles.BizAdminFull) roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminFull)
) { ) {
addNavItem(locale.get("Administration"), "user-tie", "/admin"); addNavItem(locale.get("Administration"), "user-tie", "/admin");
} }
if ( if (
roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) || roles.hasRole(roles.AUTHORIZATION_ROLES.OpsAdminFull) ||
roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited) roles.hasRole(roles.AUTHORIZATION_ROLES.OpsAdminLimited)
) { ) {
addNavItem(locale.get("Operations"), "cogs", "ops"); addNavItem(locale.get("Operations"), "cogs", "ops");
} }

View File

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

View File

@@ -21,10 +21,10 @@
clearable clearable
:counter="255" :counter="255"
:label="this.$gzlocale.get('WidgetName')" :label="this.$gzlocale.get('WidgetName')"
:rules="[this.$gzv.Max255(this,'name'),this.$gzv.Required(this,'name')]" :rules="[this.$gzv.max255(this,'name'),this.$gzv.required(this,'name')]"
:error-messages="this.$gzv.ServerErrors(this,'name')" :error-messages="this.$gzv.serverErrors(this,'name')"
ref="name" ref="name"
@change="Change('name')" @change="onChange('name')"
></v-text-field> ></v-text-field>
</v-flex> </v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>
@@ -33,10 +33,10 @@
clearable clearable
:counter="10" :counter="10"
:label="this.$gzlocale.get('WidgetSerial')" :label="this.$gzlocale.get('WidgetSerial')"
:rules="[this.$gzv.MaxLength(this,'serial',10)]" :rules="[this.$gzv.maxLength(this,'serial',10)]"
:error-messages="this.$gzv.ServerErrors(this,'serial')" :error-messages="this.$gzv.serverErrors(this,'serial')"
ref="serial" ref="serial"
@change="Change('serial')" @change="onChange('serial')"
></v-text-field> ></v-text-field>
</v-flex> </v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>
@@ -46,10 +46,10 @@
:counter="10" :counter="10"
:label="this.$gzlocale.get('WidgetCount')" :label="this.$gzlocale.get('WidgetCount')"
ref="count" ref="count"
:rules="[this.$gzv.Integer(this,'count'),this.$gzv.Required(this,'count')]" :rules="[this.$gzv.integerValid(this,'count'),this.$gzv.required(this,'count')]"
:error-messages="this.$gzv.ServerErrors(this,'count')" :error-messages="this.$gzv.serverErrors(this,'count')"
required required
@change="Change('count')" @change="onChange('count')"
type="number" type="number"
></v-text-field> ></v-text-field>
</v-flex> </v-flex>
@@ -61,9 +61,9 @@
:label="this.$gzlocale.get('WidgetDollarAmount')" :label="this.$gzlocale.get('WidgetDollarAmount')"
ref="dollarAmount" ref="dollarAmount"
required required
:rules="[this.$gzv.Decimal(this,'dollarAmount'),this.$gzv.Required(this,'dollarAmount')]" :rules="[this.$gzv.decimalValid(this,'dollarAmount'),this.$gzv.required(this,'dollarAmount')]"
:error-messages="this.$gzv.ServerErrors(this,'dollarAmount')" :error-messages="this.$gzv.serverErrors(this,'dollarAmount')"
@change="Change('dollarAmount')" @change="onChange('dollarAmount')"
type="number" type="number"
></v-text-field> ></v-text-field>
</v-flex> </v-flex>
@@ -73,19 +73,19 @@
:label="this.$gzlocale.get('WidgetStartDate')" :label="this.$gzlocale.get('WidgetStartDate')"
v-model="obj.startDate" v-model="obj.startDate"
ref="startDate" ref="startDate"
:error-messages="this.$gzv.ServerErrors(this,'startDate')" :error-messages="this.$gzv.serverErrors(this,'startDate')"
@change="Change('startDate')" @change="onChange('startDate')"
></gz-date-time-picker> ></gz-date-time-picker>
</v-flex> </v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>
<gz-date-time-picker <gz-date-time-picker
:label="this.$gzlocale.get('WidgetEndDate')" :label="this.$gzlocale.get('WidgetEndDate')"
:rules="[this.$gzv.After(this,'startDate','endDate')]" :rules="[this.$gzv.datePrecedence(this,'startDate','endDate')]"
:error-messages="this.$gzv.ServerErrors(this,'endDate')" :error-messages="this.$gzv.serverErrors(this,'endDate')"
v-model="obj.endDate" v-model="obj.endDate"
ref="endDate" ref="endDate"
@change="Change('endDate')" @change="onChange('endDate')"
></gz-date-time-picker> ></gz-date-time-picker>
</v-flex> </v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>
@@ -93,9 +93,9 @@
v-model="obj.active" v-model="obj.active"
:label="this.$gzlocale.get('Active')" :label="this.$gzlocale.get('Active')"
ref="active" ref="active"
:error-messages="this.$gzv.ServerErrors(this,'active')" :error-messages="this.$gzv.serverErrors(this,'active')"
required required
@change="Change('active')" @change="onChange('active')"
></v-checkbox> ></v-checkbox>
</v-flex> </v-flex>
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>
@@ -103,10 +103,10 @@
v-model="obj.roles" v-model="obj.roles"
:label="this.$gzlocale.get('WidgetRoles')" :label="this.$gzlocale.get('WidgetRoles')"
ref="roles" ref="roles"
:rules="[this.$gzv.Integer(this,'roles'),this.$gzv.Required(this,'roles')]" :rules="[this.$gzv.integerValid(this,'roles'),this.$gzv.required(this,'roles')]"
:error-messages="this.$gzv.ServerErrors(this,'roles')" :error-messages="this.$gzv.serverErrors(this,'roles')"
required required
@change="Change('roles')" @change="onChange('roles')"
type="number" type="number"
></v-text-field> ></v-text-field>
</v-flex> </v-flex>
@@ -218,19 +218,19 @@ export default {
}; };
}, },
methods: { methods: {
Change(ref) { onChange(ref) {
this.$gzv.Change(this, ref); this.$gzv.onChange(this, ref);
}, },
getDataFromApi() { getDataFromApi() {
var url = "Widget/" + this.$route.params.id; var url = "Widget/" + this.$route.params.id;
var that = this; var that = this;
this.$gzv.DeleteAllErrorBoxErrors(this); this.$gzv.deleteAllErrorBoxErrors(this);
this.$gzapi this.$gzapi
.get(url) .get(url)
.then(res => { .then(res => {
if (res.error) { if (res.error) {
that.serverError = res.error; that.serverError = res.error;
that.$gzv.SetErrorBoxErrors(that); that.$gzv.setErrorBoxErrors(that);
} else { } else {
that.obj = res.data; that.obj = res.data;
} }
@@ -246,14 +246,14 @@ export default {
var url = "Widget/" + this.$route.params.id; var url = "Widget/" + this.$route.params.id;
//clear any errors that might be around from previous submit //clear any errors that might be around from previous submit
this.$gzv.DeleteAllErrorBoxErrors(this); this.$gzv.deleteAllErrorBoxErrors(this);
this.$gzapi this.$gzapi
.upsert(url, this.obj) .upsert(url, this.obj)
.then(res => { .then(res => {
if (res.error) { if (res.error) {
that.serverError = res.error; that.serverError = res.error;
that.$gzv.SetErrorBoxErrors(that); that.$gzv.setErrorBoxErrors(that);
} else { } else {
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put //Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
if (res.id) { if (res.id) {