From ee684f0a20f76232f1e9084ec06763c47d995415 Mon Sep 17 00:00:00 2001 From: David Higgins Date: Tue, 5 Dec 2017 11:59:00 -0500 Subject: [PATCH 1/3] fixes #345 - declare debouncedValidateFunc and set it when debouncedValidate() is called... vue 2.2.0 prevents you from attaching methods/properties to components that have not been declared --- src/fields/abstractField.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/fields/abstractField.js b/src/fields/abstractField.js index 6d253241..7ed55d7e 100644 --- a/src/fields/abstractField.js +++ b/src/fields/abstractField.js @@ -1,4 +1,4 @@ -import { get as objGet, each, isFunction, isString, isArray, debounce } from "lodash"; +import { uniqueId, get as objGet, each, isFunction, isString, isArray, debounce } from "lodash"; import validators from "../utils/validators"; import { slugifyFormID } from "../utils/schema"; @@ -24,7 +24,8 @@ export default { data() { return { - errors: [] + errors: [], + debouncedValidateFunc: null }; }, @@ -66,9 +67,6 @@ export default { if (this.$parent.options && this.$parent.options.validateAfterChanged === true) { if (this.$parent.options.validateDebounceTime > 0) { - if (!this.debouncedValidate) - this.debouncedValidate = debounce(this.validate.bind(this), this.$parent.options.validateDebounceTime); - this.debouncedValidate(); } else { this.validate(); @@ -81,6 +79,7 @@ export default { methods: { validate(calledParent) { + console.log('validating', performance.now()); this.clearValidationErrors(); if (this.schema.validator && this.schema.readonly !== true && this.disabled !== true) { @@ -130,7 +129,14 @@ export default { return this.errors; }, - + debouncedValidate() { + if(!isFunction(this.debouncedValidateFunc)) { + console.log('debouncedValidate', 'config', objGet(this, '$parent.optionsvalidateDebounceTime', 500)); + this.debouncedValidateFunc = debounce(this.validate.bind(this), objGet(this, '$parent.options.validateDebounceTime', 500)); + } + console.log('debouncedValidate', performance.now()); + this.debouncedValidateFunc(); + }, clearValidationErrors() { this.errors.splice(0); }, From c86d7dced81ee8ec3751fec8bca221fb594282e4 Mon Sep 17 00:00:00 2001 From: David Higgins Date: Tue, 5 Dec 2017 12:00:23 -0500 Subject: [PATCH 2/3] remove uniqueId import --- src/fields/abstractField.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fields/abstractField.js b/src/fields/abstractField.js index 7ed55d7e..2d68af0e 100644 --- a/src/fields/abstractField.js +++ b/src/fields/abstractField.js @@ -1,4 +1,4 @@ -import { uniqueId, get as objGet, each, isFunction, isString, isArray, debounce } from "lodash"; +import { get as objGet, each, isFunction, isString, isArray, debounce } from "lodash"; import validators from "../utils/validators"; import { slugifyFormID } from "../utils/schema"; From 025b5418f5f6dbb4145e70e19030a4526827941c Mon Sep 17 00:00:00 2001 From: David Higgins Date: Tue, 5 Dec 2017 12:05:35 -0500 Subject: [PATCH 3/3] removed console.log and fixed quotes --- src/fields/abstractField.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/fields/abstractField.js b/src/fields/abstractField.js index 2d68af0e..100de8e3 100644 --- a/src/fields/abstractField.js +++ b/src/fields/abstractField.js @@ -79,7 +79,6 @@ export default { methods: { validate(calledParent) { - console.log('validating', performance.now()); this.clearValidationErrors(); if (this.schema.validator && this.schema.readonly !== true && this.disabled !== true) { @@ -131,10 +130,8 @@ export default { }, debouncedValidate() { if(!isFunction(this.debouncedValidateFunc)) { - console.log('debouncedValidate', 'config', objGet(this, '$parent.optionsvalidateDebounceTime', 500)); - this.debouncedValidateFunc = debounce(this.validate.bind(this), objGet(this, '$parent.options.validateDebounceTime', 500)); + this.debouncedValidateFunc = debounce(this.validate.bind(this), objGet(this, "$parent.options.validateDebounceTime", 500)); } - console.log('debouncedValidate', performance.now()); this.debouncedValidateFunc(); }, clearValidationErrors() {