refactoring, renaming capitalized functions to proper case, etc
This commit is contained in:
@@ -255,7 +255,7 @@ Make all fields work according to specs below
|
||||
- Use browser Numeric format
|
||||
- Override browser with these numeric format settings instead (see below)
|
||||
- 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")
|
||||
- negative display format one of these: -1.1, (1.1), 1.1-
|
||||
- Use browser Datetime format
|
||||
|
||||
@@ -30,7 +30,7 @@ function dealWithError(msg, form) {
|
||||
}
|
||||
}
|
||||
form.appError = msg;
|
||||
form.$gzv.SetErrorBoxErrors(form);
|
||||
form.$gzv.setErrorBoxErrors(form);
|
||||
}
|
||||
}
|
||||
export default {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import store from "../store";
|
||||
export default {
|
||||
AuthorizationRoles: {
|
||||
AUTHORIZATION_ROLES: {
|
||||
///<summary>No role set</summary>
|
||||
NoRole: 0,
|
||||
///<summary>BizAdminLimited</summary>
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
clearable
|
||||
:counter="255"
|
||||
:label="this.$gzlocale.get('WidgetName')"
|
||||
:rules="[this.$gzv.Max255(this,'name'),this.$gzv.Required(this,'name')]"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'name')"
|
||||
:rules="[this.$gzv.max255(this,'name'),this.$gzv.required(this,'name')]"
|
||||
:error-messages="this.$gzv.serverErrors(this,'name')"
|
||||
ref="name"
|
||||
@change="Change('name')"
|
||||
@change="onChange('name')"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||
@@ -33,10 +33,10 @@
|
||||
clearable
|
||||
:counter="10"
|
||||
:label="this.$gzlocale.get('WidgetSerial')"
|
||||
:rules="[this.$gzv.MaxLength(this,'serial',10)]"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'serial')"
|
||||
:rules="[this.$gzv.maxLength(this,'serial',10)]"
|
||||
:error-messages="this.$gzv.serverErrors(this,'serial')"
|
||||
ref="serial"
|
||||
@change="Change('serial')"
|
||||
@change="onChange('serial')"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||
@@ -46,10 +46,10 @@
|
||||
:counter="10"
|
||||
:label="this.$gzlocale.get('WidgetCount')"
|
||||
ref="count"
|
||||
:rules="[this.$gzv.Integer(this,'count'),this.$gzv.Required(this,'count')]"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'count')"
|
||||
:rules="[this.$gzv.integerValid(this,'count'),this.$gzv.required(this,'count')]"
|
||||
:error-messages="this.$gzv.serverErrors(this,'count')"
|
||||
required
|
||||
@change="Change('count')"
|
||||
@change="onChange('count')"
|
||||
type="number"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
@@ -61,9 +61,9 @@
|
||||
:label="this.$gzlocale.get('WidgetDollarAmount')"
|
||||
ref="dollarAmount"
|
||||
required
|
||||
:rules="[this.$gzv.Decimal(this,'dollarAmount'),this.$gzv.Required(this,'dollarAmount')]"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'dollarAmount')"
|
||||
@change="Change('dollarAmount')"
|
||||
:rules="[this.$gzv.decimalValid(this,'dollarAmount'),this.$gzv.required(this,'dollarAmount')]"
|
||||
:error-messages="this.$gzv.serverErrors(this,'dollarAmount')"
|
||||
@change="onChange('dollarAmount')"
|
||||
type="number"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
@@ -73,19 +73,19 @@
|
||||
:label="this.$gzlocale.get('WidgetStartDate')"
|
||||
v-model="obj.startDate"
|
||||
ref="startDate"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'startDate')"
|
||||
@change="Change('startDate')"
|
||||
:error-messages="this.$gzv.serverErrors(this,'startDate')"
|
||||
@change="onChange('startDate')"
|
||||
></gz-date-time-picker>
|
||||
</v-flex>
|
||||
|
||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||
<gz-date-time-picker
|
||||
:label="this.$gzlocale.get('WidgetEndDate')"
|
||||
:rules="[this.$gzv.After(this,'startDate','endDate')]"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'endDate')"
|
||||
:rules="[this.$gzv.datePrecedence(this,'startDate','endDate')]"
|
||||
:error-messages="this.$gzv.serverErrors(this,'endDate')"
|
||||
v-model="obj.endDate"
|
||||
ref="endDate"
|
||||
@change="Change('endDate')"
|
||||
@change="onChange('endDate')"
|
||||
></gz-date-time-picker>
|
||||
</v-flex>
|
||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||
@@ -93,9 +93,9 @@
|
||||
v-model="obj.active"
|
||||
:label="this.$gzlocale.get('Active')"
|
||||
ref="active"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'active')"
|
||||
:error-messages="this.$gzv.serverErrors(this,'active')"
|
||||
required
|
||||
@change="Change('active')"
|
||||
@change="onChange('active')"
|
||||
></v-checkbox>
|
||||
</v-flex>
|
||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||
@@ -103,10 +103,10 @@
|
||||
v-model="obj.roles"
|
||||
:label="this.$gzlocale.get('WidgetRoles')"
|
||||
ref="roles"
|
||||
:rules="[this.$gzv.Integer(this,'roles'),this.$gzv.Required(this,'roles')]"
|
||||
:error-messages="this.$gzv.ServerErrors(this,'roles')"
|
||||
:rules="[this.$gzv.integerValid(this,'roles'),this.$gzv.required(this,'roles')]"
|
||||
:error-messages="this.$gzv.serverErrors(this,'roles')"
|
||||
required
|
||||
@change="Change('roles')"
|
||||
@change="onChange('roles')"
|
||||
type="number"
|
||||
></v-text-field>
|
||||
</v-flex>
|
||||
@@ -218,19 +218,19 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
Change(ref) {
|
||||
this.$gzv.Change(this, ref);
|
||||
onChange(ref) {
|
||||
this.$gzv.onChange(this, ref);
|
||||
},
|
||||
getDataFromApi() {
|
||||
var url = "Widget/" + this.$route.params.id;
|
||||
var that = this;
|
||||
this.$gzv.DeleteAllErrorBoxErrors(this);
|
||||
this.$gzv.deleteAllErrorBoxErrors(this);
|
||||
this.$gzapi
|
||||
.get(url)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
that.serverError = res.error;
|
||||
that.$gzv.SetErrorBoxErrors(that);
|
||||
that.$gzv.setErrorBoxErrors(that);
|
||||
} else {
|
||||
that.obj = res.data;
|
||||
}
|
||||
@@ -246,14 +246,14 @@ export default {
|
||||
var url = "Widget/" + this.$route.params.id;
|
||||
|
||||
//clear any errors that might be around from previous submit
|
||||
this.$gzv.DeleteAllErrorBoxErrors(this);
|
||||
this.$gzv.deleteAllErrorBoxErrors(this);
|
||||
|
||||
this.$gzapi
|
||||
.upsert(url, this.obj)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
that.serverError = res.error;
|
||||
that.$gzv.SetErrorBoxErrors(that);
|
||||
that.$gzv.setErrorBoxErrors(that);
|
||||
} else {
|
||||
//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) {
|
||||
|
||||
Reference in New Issue
Block a user