1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

inputcheckbox and terms checking

This commit is contained in:
diminator 2015-07-27 14:39:19 +02:00
parent 494ab209ca
commit 1504a5b20d
5 changed files with 67 additions and 21 deletions

View File

@ -63,6 +63,7 @@ let Form = React.createClass({
if ('getFormData' in this.props){
data = mergeOptionsWithDuplicates(data, this.props.getFormData());
}
console.log(data)
return data;
},

View File

@ -173,7 +173,8 @@ let FileUploader = React.createClass({
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}
localHashing={true} />
multiple={false}
localHashing={false} />
);
}
});

View File

@ -5,42 +5,42 @@ import React from 'react';
let InputCheckbox = React.createClass({
propTypes: {
required: React.PropTypes.string.isRequired,
defaultValue: React.PropTypes.bool,
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element
]).isRequired
},
getInitialState() {
getDefaultProps() {
return {
show: false
required: 'required'
};
},
handleFocus(event) {
this.refs.checkbox.getDOMNode().checked = !this.refs.checkbox.getDOMNode().checked;
// This is calling property.js's method handleChange which
// expects an event object
// Since we don't have a valid one, we'll just manipulate the one we get and send
// it to handleChange
event.target.value = this.refs.checkbox.getDOMNode().checked;
getInitialState() {
return {
//show: false
value: this.props.defaultValue
};
},
onChange: function(event) {
let newValue = !this.state.value;
event.target.value = newValue;
this.props.onChange(event);
event.stopPropagation();
this.setState({
show: this.refs.checkbox.getDOMNode().checked,
value: this.refs.checkbox.getDOMNode().checked
});
this.setState({value: newValue});
},
render() {
return (
<span
onClick={this.handleFocus}
onFocus={this.handleFocus}>
<input type="checkbox" ref="checkbox" required="required"/>
onClick={this.onChange}>
<input
type="checkbox"
ref="checkbox"
onChange={this.onChange}
checked={this.state.value}/>
<span className="checkbox">
{this.props.children}
</span>

View File

@ -20,6 +20,7 @@ import ReactS3FineUploader from './ascribe_uploader/react_s3_fine_uploader';
import CollapsibleParagraph from './ascribe_collapsible/collapsible_paragraph';
import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property';
import InputCheckbox from './ascribe_forms/input_checkbox';
import apiUrls from '../constants/api_urls';
import AppConstants from '../constants/application_constants';
@ -68,8 +69,14 @@ let AccountSettings = React.createClass({
let notification = new GlobalNotificationModel(getLangText('username succesfully updated'), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification);
},
getFormDataProfile(){
return {'email': this.state.currentUser.email};
},
render() {
let content = <img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />;
let profile = null;
if (this.state.currentUser.username) {
content = (
<Form
@ -97,6 +104,41 @@ let AccountSettings = React.createClass({
<hr />
</Form>
);
profile = (
<Form
url={apiUrls.users_profile}
handleSuccess={this.handleSuccess}
getFormData={this.getFormDataProfile}>
<Property
name="hash_locally"
className="ascribe-settings-property-collapsible-toggle"
style={{paddingBottom: 0}}>
<InputCheckbox
defaultValue={true}
required={false}>
<span>
{' ' + getLangText('Enable hash option for slow connections. ' +
'Computes and uploads a hash of the work instead.')}
</span>
</InputCheckbox>
</Property>
{/*<Property
name='language'
label={getLangText('Choose your Language')}
editable={true}>
<select id="select-lang" name="language">
<option value="fr">
Fran&ccedil;ais
</option>
<option value="en"
selected="selected">
English
</option>
</select>
</Property>*/}
<hr />
</Form>
);
}
return (
<CollapsibleParagraph
@ -104,6 +146,7 @@ let AccountSettings = React.createClass({
show={true}
defaultExpanded={true}>
{content}
{profile}
{/*<Form
url={AppConstants.serverUrl + 'api/users/set_language/'}>
<Property

View File

@ -49,6 +49,7 @@ let apiUrls = {
'users_password_reset_request': AppConstants.apiEndpoint + 'users/request_reset_password/',
'users_signup': AppConstants.apiEndpoint + 'users/',
'users_username': AppConstants.apiEndpoint + 'users/username/',
'users_profile': AppConstants.apiEndpoint + 'users/profile/',
'wallet_settings': AppConstants.apiEndpoint + 'users/wallet_settings/',
'whitelabel_settings': AppConstants.apiEndpoint + 'whitelabel/settings/${subdomain}/',
'delete_s3_file': AppConstants.serverUrl + 's3/delete/'