From ef5027fae18116c6979ada2cbf54c3a0e8318a8d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 8 Oct 2020 15:11:08 +0000 Subject: [PATCH] --- ayanova/src/api/gzutil.js | 9 ++++++++- ayanova/src/components/custom-fields-control.vue | 2 +- ayanova/src/components/tag-picker.vue | 8 ++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ayanova/src/api/gzutil.js b/ayanova/src/api/gzutil.js index b296adfa..f5b58d26 100644 --- a/ayanova/src/api/gzutil.js +++ b/ayanova/src/api/gzutil.js @@ -270,7 +270,7 @@ export default { } //A number already then parse and return - if (window.$gz._.isNumber(string)) { + if (this.isNumeric(string)) { if (string === NaN) { return 0; } @@ -459,6 +459,13 @@ export default { while (start < end && str[start] === ch) ++start; while (end > start && str[end - 1] === ch) --end; return start > 0 || end < str.length ? str.substring(start, end) : str; + }, + /////////////////////////////////////////////// + // is numeric replacement for lodash + // https://stackoverflow.com/a/52986361/8939 + // + isNumeric: function(n) { + return !isNaN(parseFloat(n)) && isFinite(n); } /** diff --git a/ayanova/src/components/custom-fields-control.vue b/ayanova/src/components/custom-fields-control.vue index a2325237..050e734f 100644 --- a/ayanova/src/components/custom-fields-control.vue +++ b/ayanova/src/components/custom-fields-control.vue @@ -319,7 +319,7 @@ export default { break; case 8: case 7: - if (!window.$gz._.isNumber(ret)) { + if (!window.$gz.util.isNumeric(ret)) { ret = window.$gz.util.stringToFloat(ret); break; diff --git a/ayanova/src/components/tag-picker.vue b/ayanova/src/components/tag-picker.vue index 33379487..7c25daf6 100644 --- a/ayanova/src/components/tag-picker.vue +++ b/ayanova/src/components/tag-picker.vue @@ -107,7 +107,7 @@ export default { methods: { addTag() { let theTag = this.tagSearchEntry; - theTag = this.normalizeTag(theTag); + theTag = window.$gz.util.normalizeTag(theTag); //Maybe need to make sure there are no existing of the same tag? Although that shouldn't be possible technically this.sourcetags.push(theTag); this.value.push(theTag); @@ -115,11 +115,7 @@ export default { this.$emit("input", this.value); }, normalizeTag(tagName) { - //kebab case takes care of all the things we need for tags in one go - tagName = window.$gz._.kebabCase(tagName); - //No longer than 255 characters - tagName = tagName.length > 255 ? tagName.substr(0, 255 - 1) : tagName; - return tagName; + return window.$gz.util.normalizeTag(tagName); } } };