From 01cea9ad3d2f082ff155fd381a3a57157e020e18 Mon Sep 17 00:00:00 2001 From: vrde Date: Wed, 14 Oct 2015 15:30:10 +0200 Subject: [PATCH 1/2] Property component now propagate its name to its input child --- js/components/ascribe_forms/input_checkbox.js | 8 ++++++-- js/components/ascribe_forms/property.js | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/js/components/ascribe_forms/input_checkbox.js b/js/components/ascribe_forms/input_checkbox.js index 38885441..620c310f 100644 --- a/js/components/ascribe_forms/input_checkbox.js +++ b/js/components/ascribe_forms/input_checkbox.js @@ -17,11 +17,13 @@ let InputCheckbox = React.createClass({ // // Since this component even has checkbox in its name, it felt wrong to expose defaultValue // as the default-setting prop to other developers, which is why we choose defaultChecked. + defaultValue: React.PropTypes.string, defaultChecked: React.PropTypes.bool, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element ]), + name: React.PropTypes.string, // provided by Property disabled: React.PropTypes.bool, @@ -102,8 +104,10 @@ let InputCheckbox = React.createClass({ return ( + onClick={this.onChange} + name={this.props.name}> Date: Wed, 14 Oct 2015 15:49:04 +0200 Subject: [PATCH 2/2] Disable eslint check on specific proptype --- js/components/ascribe_forms/input_checkbox.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/components/ascribe_forms/input_checkbox.js b/js/components/ascribe_forms/input_checkbox.js index 620c310f..a0ee1a70 100644 --- a/js/components/ascribe_forms/input_checkbox.js +++ b/js/components/ascribe_forms/input_checkbox.js @@ -17,7 +17,6 @@ let InputCheckbox = React.createClass({ // // Since this component even has checkbox in its name, it felt wrong to expose defaultValue // as the default-setting prop to other developers, which is why we choose defaultChecked. - defaultValue: React.PropTypes.string, defaultChecked: React.PropTypes.bool, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), @@ -52,7 +51,7 @@ let InputCheckbox = React.createClass({ // Developer's are used to define defaultValues for inputs via defaultValue, but since this is a // input of type checkbox we warn the dev to not do that. - if(this.props.defaultValue) { + if(this.props.defaultValue) { //eslint-disable-line react/prop-types console.warn('InputCheckbox is of type checkbox. Therefore its value is represented by checked and defaultChecked. defaultValue will do nothing!'); }