From 9fcbd48a75e666ddc9fef496dd4d7ae5222dd717 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 7 Oct 2020 21:28:51 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 2 +- ayanova/src/api/gzform.js | 57 +++++++++++++++++++++------------- ayanova/src/api/gzutil.js | 7 +++++ ayanova/src/plugins/vuetify.js | 17 ++-------- 4 files changed, 46 insertions(+), 37 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 54cef91b..e8aa21e7 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -15,7 +15,7 @@ todo: deploy and ui test login page for build 71, todo: known issues has some efficiency settings for themes and good stuff to know, check it: https://github.com/vuetifyjs/vuetify/releases/tag/v2.3.0#user-content-known-issues todo: is notifynewcount request double sending? It seems like it appears twice at the same moment in the log - +todo: widget usertype not set on new record error says "invalid value [2203]" shouldn't it say it's required instead? todo: libs outside of package.json, check if they are outdated or need updating or can be replaced / removed diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index 578b8710..b39dd109 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -86,11 +86,27 @@ function getControlLabel(ctrl) { function getErrorsForField(vm, ref) { let ret = []; if (ref == "errorbox") { - ret = window.$gz._.filter(vm.formState.serverError.details, function(o) { - return !o.target; - }); + //de-lodash + // ret = window.$gz. _.filter(vm.formState.serverError.details, function(o) { + // return !o.target; + // }); + + ret = vm.formState.serverError.details.filter(z => z.target == false); } else { - ret = window.$gz._.filter(vm.formState.serverError.details, function(o) { + //de-lodash + // ret = window.$gz. _.filter(vm.formState.serverError.details, function(o) { + // if (!o.target) { + // return false; + // } + // //server error fields are capitalized + // //client field names are generally lower case except for custom fields + // //so we need to normalize them all to lower case to match + // //they will always differ by more than case so this is fine + + // return o.target.toLowerCase() == ref.toLowerCase(); + // }); + + ret = vm.formState.serverError.details.filter(function(o) { if (!o.target) { return false; } @@ -157,10 +173,9 @@ export default { // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", let err = vm.$ay.t("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); - // console.log("gzform:required rule - failed, setting invalid", fieldName); + err = err.replace("{0}", fieldName); + //replace only replaces first instance so need to do it twice + err = err.replace("{0}", fieldName); //Update the form status this.setFormState({ vm: vm, @@ -201,8 +216,8 @@ export default { // "ErrorFieldLengthExceeded": "{0} can not exceed {1} characters.", let err = vm.$ay.t("ErrorFieldLengthExceeded"); let fieldName = getControlLabel(ctrl); - err = window.$gz._.replace(err, "{0}", fieldName); - err = window.$gz._.replace(err, "{1}", max); + err = err.replace("{0}", fieldName); + err = err.replace("{1}", max); //Update the form status this.setFormState({ vm: vm, @@ -532,9 +547,9 @@ export default { // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", let err = vm.$ay.t("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); + err = err.replace("{0}", fieldName); + //replace only replaces first instance so need to do it twice + err = err.replace("{0}", fieldName); //Update the form status this.setFormState({ vm: vm, @@ -568,13 +583,11 @@ export default { } //It's empty and it's required so return error - // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", let err = vm.$ay.t("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); + err = err.replace("{0}", fieldName); + //replace only replaces first instance so need to do it twice + err = err.replace("{0}", fieldName); //Update the form status this.setFormState({ vm: vm, @@ -613,7 +626,8 @@ export default { } //ensure the error returned is in an expected format to catch coding errors at the server end - if (!window.$gz._.isEmpty(vm.formState.serverError)) { + if (!window.$gz.util.objectIsEmpty(vm.formState.serverError)) { + //de-lodash with my own function //Make sure there is an error code if there is an error collection if (!vm.formState.serverError.code) { throw new Error( @@ -625,7 +639,8 @@ export default { let ret = []; //check for errors if we have any errors - if (!window.$gz._.isEmpty(vm.formState.serverError)) { + if (!window.$gz.util.objectIsEmpty(vm.formState.serverError)) { + //de-lodash //First let's get the top level error code let apiErrorCode = parseInt(vm.formState.serverError.code); @@ -668,7 +683,7 @@ export default { //DETAIL ERRORS //{"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 (!window.$gz._.isEmpty(vm.formState.serverError.details)) { + if (!window.$gz.util.objectIsEmpty(vm.formState.serverError.details)) { //See if this key is in the details array let errorsForField = getErrorsForField(vm, ref); if (errorsForField.length > 0) { diff --git a/ayanova/src/api/gzutil.js b/ayanova/src/api/gzutil.js index bd3da394..c94060ad 100644 --- a/ayanova/src/api/gzutil.js +++ b/ayanova/src/api/gzutil.js @@ -407,6 +407,13 @@ export default { ? has(obj[key.split(".")[0]], keyParts.slice(1).join(".")) : hasOwnProperty.call(obj, key)) ); + }, + /////////////////////////////////////////////// + // Check if object is empty + // + objectIsEmpty: function(obj) { + //https://stackoverflow.com/a/4994265/8939 + return Object.keys(obj).length === 0; } /** diff --git a/ayanova/src/plugins/vuetify.js b/ayanova/src/plugins/vuetify.js index a00bc96c..cc80d84b 100644 --- a/ayanova/src/plugins/vuetify.js +++ b/ayanova/src/plugins/vuetify.js @@ -1176,36 +1176,23 @@ const CUSTOM_ICONS = { Vue.use(Vuetify); export default new Vuetify({ - // lang: { locales: { myLang }, current: "myLang" }, theme: { themes: { light: { primary: "#00205B", //Canucks dark blue secondary: "#00843D", //canucks green - accent: "#db7022", //lighter orangey red, more friendly looking though not as much clarity it seems - //error: "#b71c1c", //dark red, easy to read but not error-y enough possibly - - //accent: "#BD491A", //dark orangey red, more clarity, less friendly looking error: "#ff5252", //lighter red, have to see if it's good for all screens and sizes as it's a bit light but it stands out as an error condition better - - // disabled: "#e0e0e0" - disabled: "#c7c7c7" + disabled: "#c7c7c7" }, dark: { //here you will define primary secondary stuff for dark theme //color adjuster tool: https://www.hexcolortool.com/#00205c primary: "#7F9FDA", //Canucks dark blue LIGHTENED 50% secondary: "#006B24", //canucks green DARKENED 10% - accent: "#db7022", //lighter orangey red, more friendly looking though not as much clarity it seems - //error: "#b71c1c", //dark red, easy to read but not error-y enough possibly - - //accent: "#BD491A", //dark orangey red, more clarity, less friendly looking error: "#ff5252", //lighter red, have to see if it's good for all screens and sizes as it's a bit light but it stands out as an error condition better - - disabled: "#e0e0e0" - // disabled: "#db7022" + disabled: "#c7c7c7" } } },