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 5c621a90..b871a639 100644 --- a/js/components/ascribe_forms/input_checkbox.js +++ b/js/components/ascribe_forms/input_checkbox.js @@ -4,7 +4,8 @@ import React from 'react'; let InputCheckbox = React.createClass({ propTypes: { - 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 @@ -18,17 +19,26 @@ let InputCheckbox = React.createClass({ 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() { @@ -39,7 +49,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/input_hidden.js b/js/components/ascribe_forms/input_hidden.js deleted file mode 100644 index b6a8ac46..00000000 --- a/js/components/ascribe_forms/input_hidden.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -import React from 'react'; - -import AlertMixin from '../../mixins/alert_mixin'; - -let InputHidden = React.createClass({ - propTypes: { - submitted: React.PropTypes.bool, - value: React.PropTypes.string - }, - - mixins: [AlertMixin], - - getInitialState() { - return {value: this.props.value, - alerts: null // needed in AlertMixin - }; - }, - handleChange(event) { - this.setState({value: event.target.value}); - }, - render() { - let alerts = (this.props.submitted) ? null : this.state.alerts; - return ( -
- {alerts} - -
- ); - - } -}); - -export default InputHidden; \ No newline at end of file diff --git a/js/components/ascribe_forms/input_text.js b/js/components/ascribe_forms/input_text.js deleted file mode 100644 index 7f0ee5d0..00000000 --- a/js/components/ascribe_forms/input_text.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -import React from 'react'; - -import AlertMixin from '../../mixins/alert_mixin'; - -let InputText = React.createClass({ - propTypes: { - submitted: React.PropTypes.bool, - onBlur: React.PropTypes.func, - type: React.PropTypes.string, - required: React.PropTypes.string, - placeHolder: React.PropTypes.string - }, - - mixins: [AlertMixin], - - getInitialState() { - return {value: null, - alerts: null // needed in AlertMixin - }; - }, - - handleChange(event) { - this.setState({value: event.target.value}); - }, - - render() { - let className = 'form-control input-text-ascribe'; - let alerts = (this.props.submitted) ? null : this.state.alerts; - return ( -
- {alerts} - -
- ); - - } -}); - -export default InputText; \ No newline at end of file diff --git a/js/components/ascribe_forms/input_textarea.js b/js/components/ascribe_forms/input_textarea.js deleted file mode 100644 index 2c5ab40a..00000000 --- a/js/components/ascribe_forms/input_textarea.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -import React from 'react'; - -import AlertMixin from '../../mixins/alert_mixin'; - -let InputTextArea = React.createClass({ - propTypes: { - submitted: React.PropTypes.bool, - required: React.PropTypes.string, - defaultValue: React.PropTypes.string - }, - - mixins: [AlertMixin], - - getInitialState() { - return { - value: this.props.defaultValue, - alerts: null // needed in AlertMixin - }; - }, - handleChange(event) { - this.setState({value: event.target.value}); - }, - render() { - let className = 'form-control input-text-ascribe textarea-ascribe-message'; - - let alerts = (this.props.submitted) ? null : this.state.alerts; - return ( -
- {alerts} - -
- ); - } -}); - -export default InputTextArea; \ No newline at end of file diff --git a/js/components/ascribe_forms/property.js b/js/components/ascribe_forms/property.js index 2547c65b..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, @@ -158,7 +161,6 @@ let Property = React.createClass({ renderChildren() { return ReactAddons.Children.map(this.props.children, (child) => { return ReactAddons.addons.cloneWithProps(child, { - //value: this.state.value, onChange: this.handleChange, onFocus: this.handleFocus, onBlur: this.handleBlur, 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.')}