Simplify JsonSchemaform getComponent logic
This commit is contained in:
@@ -36,7 +36,7 @@ export class JsonSchemaForm extends Component {
|
|||||||
|
|
||||||
let { type, format="" } = schema
|
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}/>
|
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 isDisabled = schema["in"] === "formData" && !("FormData" in window)
|
||||||
const Input = getComponent("Input")
|
const Input = getComponent("Input")
|
||||||
if (schema["type"] === "file") {
|
if (schema["type"] === "file") {
|
||||||
return (<Input type="file"
|
return (<Input type="file"
|
||||||
className={ errors.length ? "invalid" : ""}
|
className={ errors.length ? "invalid" : ""}
|
||||||
title={ errors.length ? errors : ""}
|
title={ errors.length ? errors : ""}
|
||||||
onChange={ this.onChange }
|
onChange={ this.onChange }
|
||||||
disabled={isDisabled}/>)
|
disabled={isDisabled}/>)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (<Input type={ schema.format === "password" ? "password" : "text" }
|
return (<Input type={ schema.format === "password" ? "password" : "text" }
|
||||||
className={ errors.length ? "invalid" : ""}
|
className={ errors.length ? "invalid" : ""}
|
||||||
title={ errors.length ? errors : ""}
|
title={ errors.length ? errors : ""}
|
||||||
value={value}
|
value={value}
|
||||||
placeholder={description}
|
placeholder={description}
|
||||||
onChange={ this.onChange }
|
onChange={ this.onChange }
|
||||||
disabled={isDisabled}/>)
|
disabled={isDisabled}/>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user