diff --git a/js/components/ascribe_forms/form_signup.js b/js/components/ascribe_forms/form_signup.js index dc2a6cdb..5f6a3c79 100644 --- a/js/components/ascribe_forms/form_signup.js +++ b/js/components/ascribe_forms/form_signup.js @@ -123,7 +123,8 @@ let SignupForm = React.createClass({ name="terms" className="ascribe-settings-property-collapsible-toggle" style={{paddingBottom: 0}}> - + {' ' + getLangText('I agree to the Terms of Service') + ' '} ( diff --git a/js/components/ascribe_forms/input_checkbox.js b/js/components/ascribe_forms/input_checkbox.js index 46f4eb78..b1733d08 100644 --- a/js/components/ascribe_forms/input_checkbox.js +++ b/js/components/ascribe_forms/input_checkbox.js @@ -4,35 +4,40 @@ import React from 'react'; let InputCheckbox = React.createClass({ propTypes: { - required: React.PropTypes.string.isRequired, - defaultValue: React.PropTypes.bool, + required: React.PropTypes.bool, + defaultChecked: React.PropTypes.bool, children: React.PropTypes.oneOfType([ React.PropTypes.arrayOf(React.PropTypes.element), React.PropTypes.element ]).isRequired }, - getDefaultProps() { - return { - required: 'required' - }; - }, getInitialState() { return { - //show: false - value: this.props.defaultValue + value: this.props.defaultChecked }; }, - onChange: function(event) { - let newValue = !this.state.value; - event.target.value = newValue; - this.props.onChange(event); - event.stopPropagation(); - this.setState({value: newValue}); + componentDidMount() { + this.props.onChange({ + target: { + value: this.state.value + } + }); + }, + + onChange() { + let value = !this.refs.checkbox.getDOMNode().checked; + this.setState({value: value}); + this.props.onChange({ + target: { + value: value + } + }); }, render() { + console.log(this.state.value); return ( @@ -40,7 +45,8 @@ let InputCheckbox = React.createClass({ type="checkbox" ref="checkbox" onChange={this.onChange} - checked={this.state.value}/> + checked={this.state.value} + defaultChecked={this.props.defaultChecked}/> {this.props.children} diff --git a/js/components/ascribe_forms/property.js b/js/components/ascribe_forms/property.js index c37d219d..8333a8bf 100644 --- a/js/components/ascribe_forms/property.js +++ b/js/components/ascribe_forms/property.js @@ -39,6 +39,9 @@ let Property = React.createClass({ getInitialState() { return { + // Please don't confuse initialValue with react's defaultValue. + // initialValue is set by us to ensure that a user can reset a specific + // property (after editing) to its initial value initialValue: null, value: null, isFocused: false, diff --git a/js/components/settings_container.js b/js/components/settings_container.js index 90d51506..c414f10f 100644 --- a/js/components/settings_container.js +++ b/js/components/settings_container.js @@ -115,7 +115,7 @@ let AccountSettings = React.createClass({ className="ascribe-settings-property-collapsible-toggle" style={{paddingBottom: 0}}> + defaultChecked={this.state.currentUser.profile.hash_locally}> {' ' + getLangText('Enable hash option for slow connections. ' + 'Computes and uploads a hash of the work instead.')}