diff --git a/ayanova/src/api/gzvalidate.js b/ayanova/src/api/gzvalidate.js index a912ed65..b1df0e39 100644 --- a/ayanova/src/api/gzvalidate.js +++ b/ayanova/src/api/gzvalidate.js @@ -10,20 +10,57 @@ import dayjs from "dayjs"; import locale from "./locale"; import _ from "../libs/lodash.min.js"; +function isEmpty(o) { + if (typeof o == "number" && o == 0) { + return false; + } + return !o; +} + export default { - Required(ltkey, value) { - if (!_.isEmpty(value)) { + /* + ctrl.$refs[ref].value +0 +ctrl.$refs[ref].label +"Count" +ctrl.$refs[ref].initialValue + */ + /////////////////////////////// + // REQUIRED + // Required(ltkey, value) { + // if (!_.isEmpty(value)) { + // return false; + // } + // //get the localized rule text + // // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", + // var err = locale.get("ErrorRequiredFieldEmpty"); + // var fieldName = locale.get(ltkey); + // err = _.replace(err, "{0}", fieldName); + // //lodash replace only replaces first instance so need to do it twice + // err = _.replace(err, "{0}", fieldName); + // return err; + // }, + Required(v, ref) {HERE DID THIS METHOD OVER TO NEW WAY USING REF, NOW TO DO THE REST + var ctrl = v.$refs[ref]; + if (isEmpty(ctrl)) { + return false; + } + + var value = ctrl.value; + if (!isEmpty(value)) { return false; } //get the localized rule text // "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}", var err = locale.get("ErrorRequiredFieldEmpty"); - var fieldName = locale.get(ltkey); + var fieldName = ctrl.label; err = _.replace(err, "{0}", fieldName); //lodash replace only replaces first instance so need to do it twice err = _.replace(err, "{0}", fieldName); return err; }, + /////////////////////////////// + // MAXLENGTH MaxLength(ltkey, value, max) { if (_.isEmpty(value)) { return false; @@ -41,9 +78,13 @@ export default { return false; } }, + /////////////////////////////// + // MAX 255 Max255(ltkey, value) { return this.MaxLength(ltkey, value, 255); }, + /////////////////////////////// + // AFTER After(startDate, endDate) { if (_.isEmpty(startDate)) { return false; @@ -67,5 +108,12 @@ export default { } else { return false; } + }, + /////////////////////////////// + // TEST + Test(ctrl, ref) { + var v = ctrl; + return false; + // return this.MaxLength(ltkey, value, 255); } }; diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index bfdaf594..84edb8ec 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -1,16 +1,15 @@