mirror of
https://github.com/apache/superset.git
synced 2026-04-10 11:55:24 +00:00
* Adding support for client side validators on controls * Applying validators to more fields * Addressing comments
33 lines
674 B
JavaScript
33 lines
674 B
JavaScript
import React, { PropTypes } from 'react';
|
|
import { Checkbox } from 'react-bootstrap';
|
|
|
|
const propTypes = {
|
|
name: PropTypes.string.isRequired,
|
|
value: PropTypes.bool,
|
|
label: PropTypes.string,
|
|
description: PropTypes.string,
|
|
onChange: PropTypes.func,
|
|
};
|
|
|
|
const defaultProps = {
|
|
value: false,
|
|
onChange: () => {},
|
|
};
|
|
|
|
export default class CheckboxField extends React.Component {
|
|
onToggle() {
|
|
this.props.onChange(!this.props.value);
|
|
}
|
|
render() {
|
|
return (
|
|
<Checkbox
|
|
checked={this.props.value}
|
|
onChange={this.onToggle.bind(this)}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
CheckboxField.propTypes = propTypes;
|
|
CheckboxField.defaultProps = defaultProps;
|