From fe292e0768a06ef37ff350023d2f5d31e26852db Mon Sep 17 00:00:00 2001 From: chrislearn Date: Thu, 31 Aug 2017 07:46:01 +0800 Subject: [PATCH] u --- src/widgets/input/NumberInput.js | 4 +++- src/widgets/input/TextInput.js | 3 +-- src/widgets/utils.js | 8 ++++---- src/widgets/validate.js | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/widgets/input/NumberInput.js b/src/widgets/input/NumberInput.js index 4f437d0..83ae49c 100644 --- a/src/widgets/input/NumberInput.js +++ b/src/widgets/input/NumberInput.js @@ -35,7 +35,7 @@ class NumberInput extends Component { } render() { - const { label, fetchValue, step, style, disabled } = this.props; + const { label, fetchValue, step, style, disabled, min, max } = this.props; return ( ); diff --git a/src/widgets/input/TextInput.js b/src/widgets/input/TextInput.js index 6dc205c..dccc299 100644 --- a/src/widgets/input/TextInput.js +++ b/src/widgets/input/TextInput.js @@ -34,7 +34,6 @@ class TextInput extends Component { } @observable _errorText; - @observable _value = '' render() { const { fetchValue, label, style, type, disabled } = this.props return {label}} diff --git a/src/widgets/utils.js b/src/widgets/utils.js index b3ce084..f5b7699 100644 --- a/src/widgets/utils.js +++ b/src/widgets/utils.js @@ -17,13 +17,13 @@ export function fetchValue(element, defaultValue = "") { if (element.props.convert) { if (element.props.convert.fetch) { value = element.props.convert.fetch.apply(element, values) - } else { + } else if (typeof element.props.convert === 'function'){ value = element.props.convert.apply(element, values) + }else{ + value = values.length == 1 ? values[0] : values.join(', ') } - }else if (values.length == 1){ - value = values[0] }else{ - value = values.join(', ') + value = values.length == 1 ? values[0] : values.join(', ') } return value } diff --git a/src/widgets/validate.js b/src/widgets/validate.js index e5f253d..02bd694 100644 --- a/src/widgets/validate.js +++ b/src/widgets/validate.js @@ -5,7 +5,7 @@ export function validateInput(target, key, descriptor) { const method = descriptor.initializer; descriptor.initializer = function () { return function (event) { - if(this.props.validators){ + if(this.props && this.props.validators){ this.props.validators.map((validator, index) => { check.apply(this, [validator, this.props.errorMessages[index], event.target.value]); }); @@ -24,7 +24,7 @@ export function validateForm(Form) { if (this.wci) { let all_clear = true; this.wci.map((child) => { - if (child.props.validators) { + if (child && child.props && child.props.validators) { for (var i = 0, l = child.props.validators.length; i < l; i++) { if (!check.apply(child, [child.props.validators[i], child.props.errorMessages[i], getValues(child.props.record, child.props.source)[0]])) { all_clear = false; @@ -35,7 +35,7 @@ export function validateForm(Form) { }); if (all_clear) { console.log('all clear'); - this.props.onSubmit(data); + this.props && this.props.onSubmit && this.props.onSubmit(data); } } }