Simplify JsonSchemaform getComponent logic

This commit is contained in:
Kyle Shockey
2017-11-29 19:04:50 -06:00
parent e17a5f40f5
commit 8d1d15ca4a

View File

@@ -36,7 +36,7 @@ export class JsonSchemaForm extends Component {
let { type, format="" } = schema
let Comp = getComponent(`JsonSchema_${type}_${format}`) || getComponent(`JsonSchema_${type}`) || getComponent("JsonSchema_string")
let Comp = format ? getComponent(`JsonSchema_${type}_${format}`) : getComponent(`JsonSchema_${type}`) || getComponent("JsonSchema_string")
return <Comp { ...this.props } fn={fn} getComponent={getComponent} value={value} onChange={onChange} schema={schema}/>
}
@@ -68,19 +68,19 @@ export class JsonSchema_string extends Component {
const isDisabled = schema["in"] === "formData" && !("FormData" in window)
const Input = getComponent("Input")
if (schema["type"] === "file") {
return (<Input type="file"
className={ errors.length ? "invalid" : ""}
return (<Input type="file"
className={ errors.length ? "invalid" : ""}
title={ errors.length ? errors : ""}
onChange={ this.onChange }
onChange={ this.onChange }
disabled={isDisabled}/>)
}
else {
return (<Input type={ schema.format === "password" ? "password" : "text" }
className={ errors.length ? "invalid" : ""}
return (<Input type={ schema.format === "password" ? "password" : "text" }
className={ errors.length ? "invalid" : ""}
title={ errors.length ? errors : ""}
value={value}
placeholder={description}
onChange={ this.onChange }
value={value}
placeholder={description}
onChange={ this.onChange }
disabled={isDisabled}/>)
}
}