diff --git a/src/components/Widgets/NumberControl.js b/src/components/Widgets/NumberControl.js index 9354fd20..9e5d622e 100644 --- a/src/components/Widgets/NumberControl.js +++ b/src/components/Widgets/NumberControl.js @@ -1,17 +1,41 @@ import React, { PropTypes } from 'react'; -export default class StringControl extends React.Component { +export default class NumberControl extends React.Component { handleChange = (e) => { - this.props.onChange(e.target.value); + const valueType = this.props.field.get('valueType'); + const { onChange } = this.props; + if(valueType === 'int') { + onChange(parseInt(e.target.value, 10)); + } else if(valueType === 'float') { + onChange(parseFloat(e.target.value)); + } else { + onChange(e.target.value); + } }; render() { - return ; + const { field, value, forID } = this.props; + const min = field.get('min', ''); + const max = field.get('max', ''); + const step = field.get('step', field.get('valueType') === 'int' ? 1 : ''); + return ; } } -StringControl.propTypes = { +NumberControl.propTypes = { onChange: PropTypes.func.isRequired, value: PropTypes.node, forID: PropTypes.string, + valueType: PropTypes.string, + step: PropTypes.number, + min: PropTypes.number, + max: PropTypes.number, };