2015-09-16 14:07:13 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
|
|
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
|
|
|
|
|
|
|
import Form from './form';
|
|
|
|
import Property from './property';
|
|
|
|
|
2015-09-17 11:39:55 +02:00
|
|
|
import ApiUrls from '../../constants/api_urls';
|
|
|
|
import AppConstants from '../../constants/application_constants';
|
2015-09-16 14:07:13 +02:00
|
|
|
|
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
|
|
|
|
|
|
|
let CopyrightAssociationForm = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
currentUser: React.PropTypes.object
|
|
|
|
},
|
|
|
|
|
|
|
|
handleSubmitSuccess(){
|
|
|
|
let notification = getLangText('Copyright association updated');
|
|
|
|
notification = new GlobalNotificationModel(notification, 'success', 10000);
|
|
|
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
|
|
},
|
|
|
|
|
|
|
|
getProfileFormData(){
|
2015-09-17 11:39:55 +02:00
|
|
|
return {email: this.props.currentUser.email};
|
2015-09-16 14:07:13 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
2015-09-22 14:13:04 +02:00
|
|
|
let selectedState;
|
|
|
|
let selectDefaultValue = ' -- ' + getLangText('select an association') + ' -- ';
|
|
|
|
|
|
|
|
if (this.props.currentUser && this.props.currentUser.profile
|
2015-09-16 14:07:13 +02:00
|
|
|
&& this.props.currentUser.profile.copyright_association) {
|
2015-09-17 11:39:55 +02:00
|
|
|
selectedState = AppConstants.copyrightAssociations.indexOf(this.props.currentUser.profile.copyright_association);
|
2015-09-22 14:13:04 +02:00
|
|
|
selectedState = selectedState !== -1 ? AppConstants.copyrightAssociations[selectedState] : selectDefaultValue;
|
2015-09-16 14:07:13 +02:00
|
|
|
}
|
2015-09-22 14:13:04 +02:00
|
|
|
|
2015-09-17 11:39:55 +02:00
|
|
|
if (this.props.currentUser && this.props.currentUser.email){
|
|
|
|
return (
|
|
|
|
<Form
|
|
|
|
ref='form'
|
|
|
|
url={ApiUrls.users_profile}
|
|
|
|
getFormData={this.getProfileFormData}
|
|
|
|
handleSuccess={this.handleSubmitSuccess}>
|
|
|
|
<Property
|
|
|
|
name="copyright_association"
|
|
|
|
className="ascribe-settings-property-collapsible-toggle"
|
|
|
|
label={getLangText('Copyright Association')}
|
|
|
|
style={{paddingBottom: 0}}>
|
2015-09-22 14:13:04 +02:00
|
|
|
<select defaultValue={selectedState} name="contract">
|
|
|
|
<option
|
|
|
|
name={0}
|
|
|
|
key={0}
|
|
|
|
value={selectDefaultValue}>
|
|
|
|
{selectDefaultValue}
|
2015-09-17 11:39:55 +02:00
|
|
|
</option>
|
|
|
|
{AppConstants.copyrightAssociations.map((association, i) => {
|
|
|
|
return (
|
|
|
|
<option
|
2015-09-22 14:13:04 +02:00
|
|
|
name={i + 1}
|
|
|
|
key={i + 1}
|
|
|
|
value={association}>
|
2015-09-17 11:39:55 +02:00
|
|
|
{ association }
|
|
|
|
</option>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</select>
|
|
|
|
</Property>
|
|
|
|
<hr />
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
2015-09-16 14:07:13 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default CopyrightAssociationForm;
|