From 5c70134f538b9c7e710e21af0ee7ce32f90d72b7 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Mon, 24 Jul 2017 13:05:57 -0700 Subject: [PATCH 1/4] Revert "Merge pull request #3427 from owenconti/bug/3414-validate-params-reworked" Reopens #3414 This reverts commit 99d368673b4fbd640b15fe85e5c9af52179dc749, reversing changes made to 8bf9037bbcffcf12128e7b64d8fe0916fab24e77. --- src/core/components/layout-utils.jsx | 7 +- src/core/json-schema-components.js | 24 +-- src/core/utils.js | 114 ++++------ src/style/_buttons.scss | 10 +- src/style/_form.scss | 12 +- src/style/_mixins.scss | 6 - src/style/_table.scss | 4 - test/core/utils.js | 306 +++------------------------ 8 files changed, 99 insertions(+), 384 deletions(-) diff --git a/src/core/components/layout-utils.jsx b/src/core/components/layout-utils.jsx index f80e0c906de..00a4a09d22c 100644 --- a/src/core/components/layout-utils.jsx +++ b/src/core/components/layout-utils.jsx @@ -129,8 +129,7 @@ export class Select extends React.Component { value: PropTypes.any, onChange: PropTypes.func, multiple: PropTypes.bool, - allowEmptyValue: PropTypes.bool, - className: PropTypes.string + allowEmptyValue: PropTypes.bool } static defaultProps = { @@ -143,7 +142,7 @@ export class Select extends React.Component { let value - if (props.value) { + if (props.value !== undefined) { value = props.value } else { value = props.multiple ? [""] : "" @@ -179,7 +178,7 @@ export class Select extends React.Component { let value = this.state.value.toJS ? this.state.value.toJS() : this.state.value return ( - { allowEmptyValue ? : null } { allowedValues.map(function (item, key) { diff --git a/src/core/json-schema-components.js b/src/core/json-schema-components.js index 338bd6e353b..bf4ae514737 100644 --- a/src/core/json-schema-components.js +++ b/src/core/json-schema-components.js @@ -57,8 +57,7 @@ export class JsonSchema_string extends Component { if ( enumValue ) { const Select = getComponent("Select") - return () } + let errors = schema.errors || [] + return (
- { !value || value.count() < 1 ? null : + { !value || value.count() < 1 ? + (errors.length ? { errors[0] } : null) : value.map( (item,i) => { let schema = Object.assign({}, itemSchema) if ( errors.length ) { @@ -153,12 +153,12 @@ export class JsonSchema_array extends PureComponent { return (
this.onItemChange(val, i)} schema={schema} /> - +
) }).toArray() } - +
) } @@ -170,14 +170,12 @@ export class JsonSchema_boolean extends Component { onEnumChange = (val) => this.props.onChange(val) render() { - let { getComponent, value, schema } = this.props - let errors = schema.errors || [] + let { getComponent, required, value } = this.props const Select = getComponent("Select") - return (