This commit is contained in:
@@ -10,20 +10,57 @@ import dayjs from "dayjs";
|
|||||||
import locale from "./locale";
|
import locale from "./locale";
|
||||||
import _ from "../libs/lodash.min.js";
|
import _ from "../libs/lodash.min.js";
|
||||||
|
|
||||||
|
function isEmpty(o) {
|
||||||
|
if (typeof o == "number" && o == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !o;
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
//get the localized rule text
|
//get the localized rule text
|
||||||
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
||||||
var err = locale.get("ErrorRequiredFieldEmpty");
|
var err = locale.get("ErrorRequiredFieldEmpty");
|
||||||
var fieldName = locale.get(ltkey);
|
var fieldName = ctrl.label;
|
||||||
err = _.replace(err, "{0}", fieldName);
|
err = _.replace(err, "{0}", fieldName);
|
||||||
//lodash replace only replaces first instance so need to do it twice
|
//lodash replace only replaces first instance so need to do it twice
|
||||||
err = _.replace(err, "{0}", fieldName);
|
err = _.replace(err, "{0}", fieldName);
|
||||||
return err;
|
return err;
|
||||||
},
|
},
|
||||||
|
///////////////////////////////
|
||||||
|
// MAXLENGTH
|
||||||
MaxLength(ltkey, value, max) {
|
MaxLength(ltkey, value, max) {
|
||||||
if (_.isEmpty(value)) {
|
if (_.isEmpty(value)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -41,9 +78,13 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
///////////////////////////////
|
||||||
|
// MAX 255
|
||||||
Max255(ltkey, value) {
|
Max255(ltkey, value) {
|
||||||
return this.MaxLength(ltkey, value, 255);
|
return this.MaxLength(ltkey, value, 255);
|
||||||
},
|
},
|
||||||
|
///////////////////////////////
|
||||||
|
// AFTER
|
||||||
After(startDate, endDate) {
|
After(startDate, endDate) {
|
||||||
if (_.isEmpty(startDate)) {
|
if (_.isEmpty(startDate)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -67,5 +108,12 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
///////////////////////////////
|
||||||
|
// TEST
|
||||||
|
Test(ctrl, ref) {
|
||||||
|
var v = ctrl;
|
||||||
|
return false;
|
||||||
|
// return this.MaxLength(ltkey, value, 255);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-layout v-if="this.formReady">
|
<v-layout v-if="this.formReady">
|
||||||
<v-flex>
|
<v-flex>
|
||||||
<form>
|
<form ref="form">
|
||||||
<v-layout align-center justify-left row wrap>
|
<v-layout align-center justify-left row wrap>
|
||||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="obj.name"
|
v-model="obj.name"
|
||||||
:counter="255"
|
:counter="255"
|
||||||
:label="this.$gzlocale.get('WidgetName')"
|
:label="this.$gzlocale.get('WidgetName')"
|
||||||
:rules="[this.$gzv.Max255('WidgetName',obj.name),this.$gzv.Required('WidgetName',obj.name)]"
|
:rules="[this.$gzv.Max255('WidgetName',obj.name)]"
|
||||||
name="name"
|
ref="name"
|
||||||
required
|
|
||||||
></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>
|
||||||
@@ -19,8 +18,7 @@
|
|||||||
:counter="10"
|
:counter="10"
|
||||||
:label="this.$gzlocale.get('WidgetSerial')"
|
:label="this.$gzlocale.get('WidgetSerial')"
|
||||||
:rules="[this.$gzv.MaxLength('WidgetSerial',obj.serial,10)]"
|
:rules="[this.$gzv.MaxLength('WidgetSerial',obj.serial,10)]"
|
||||||
name="serial"
|
ref="serial"
|
||||||
required
|
|
||||||
></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>
|
||||||
@@ -28,7 +26,9 @@
|
|||||||
v-model="obj.count"
|
v-model="obj.count"
|
||||||
:counter="10"
|
:counter="10"
|
||||||
:label="this.$gzlocale.get('WidgetCount')"
|
:label="this.$gzlocale.get('WidgetCount')"
|
||||||
|
ref="count"
|
||||||
name="count"
|
name="count"
|
||||||
|
:rules="[this.$gzv.Required(this,'count')]"
|
||||||
required
|
required
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
@@ -38,36 +38,11 @@
|
|||||||
v-model="obj.dollarAmount"
|
v-model="obj.dollarAmount"
|
||||||
:prefix="this.$gzlocale.formats.currencySymbol"
|
:prefix="this.$gzlocale.formats.currencySymbol"
|
||||||
:label="this.$gzlocale.get('WidgetDollarAmount')"
|
:label="this.$gzlocale.get('WidgetDollarAmount')"
|
||||||
name="dollarAmount"
|
ref="dollarAmount"
|
||||||
required
|
required
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
|
|
||||||
<!--
|
|
||||||
This block was for testing date validation outside of my custom control with v-validate, keeping it just for now until done my own validator code
|
|
||||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
|
||||||
<v-text-field
|
|
||||||
:label="this.$gzlocale.get('WidgetStartDate')"
|
|
||||||
v-model="obj.startDate"
|
|
||||||
name="startDate"
|
|
||||||
v-validate="'required'"
|
|
||||||
ref="qwerty"
|
|
||||||
:error-messages="errors.collect('startDate')"
|
|
||||||
required
|
|
||||||
></v-text-field>
|
|
||||||
</v-flex>
|
|
||||||
|
|
||||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
|
||||||
<v-text-field
|
|
||||||
:label="this.$gzlocale.get('WidgetEndDate')"
|
|
||||||
v-model="obj.endDate"
|
|
||||||
name="endDate"
|
|
||||||
v-validate="'required|gzafter:qwerty'"
|
|
||||||
:error-messages="errors.collect('endDate')"
|
|
||||||
required
|
|
||||||
></v-text-field>
|
|
||||||
</v-flex>-->
|
|
||||||
<!-- YYYY-MM-DDTHH:mm:ss.sssZ -->
|
|
||||||
<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('WidgetStartDate')"
|
:label="this.$gzlocale.get('WidgetStartDate')"
|
||||||
@@ -87,7 +62,6 @@
|
|||||||
<v-flex xs12 sm6 lg4 xl3 px-2>
|
<v-flex xs12 sm6 lg4 xl3 px-2>
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
v-model="obj.active"
|
v-model="obj.active"
|
||||||
value="1"
|
|
||||||
:label="this.$gzlocale.get('Active')"
|
:label="this.$gzlocale.get('Active')"
|
||||||
name="checkbox"
|
name="checkbox"
|
||||||
required
|
required
|
||||||
@@ -159,14 +133,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
obj: {},
|
obj: {},
|
||||||
formReady: false,
|
formReady: false
|
||||||
theDate: new Date(),
|
|
||||||
date: new Date().toISOString().substr(0, 10),
|
|
||||||
menu: false,
|
|
||||||
modal: false,
|
|
||||||
menu2: false,
|
|
||||||
pw: "",
|
|
||||||
pw2: ""
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -178,7 +145,8 @@ export default {
|
|||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
// debugger;
|
// debugger;
|
||||||
this.$validator.validateAll();
|
//this.$validator.validateAll();
|
||||||
|
this.$refs.form.validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user