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: {
|
2016-02-05 11:53:33 +01:00
|
|
|
currentUser: React.PropTypes.object.isRequired
|
2015-09-16 14:07:13 +02:00
|
|
|
},
|
|
|
|
|
2016-02-05 11:53:33 +01:00
|
|
|
handleSubmitSuccess() {
|
|
|
|
const notification = new GlobalNotificationModel(getLangText('Copyright association updated'), 'success', 10000);
|
2015-09-16 14:07:13 +02:00
|
|
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
|
|
},
|
|
|
|
|
2016-02-05 11:53:33 +01:00
|
|
|
getProfileFormData() {
|
|
|
|
return { email: this.props.currentUser.email };
|
2015-09-16 14:07:13 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
2016-02-05 11:53:33 +01:00
|
|
|
const { currentUser } = this.props;
|
|
|
|
const selectDefaultValue = ' -- ' + getLangText('select an association') + ' -- ';
|
2015-09-22 14:13:04 +02:00
|
|
|
|
2016-02-05 11:53:33 +01:00
|
|
|
let selectedState = selectDefaultValue;
|
|
|
|
if (currentUser.profile && currentUser.profile.copyright_association) {
|
|
|
|
if (AppConstants.copyrightAssociations.indexOf(currentUser.profile.copyright_association) !== -1) {
|
|
|
|
selectedState = AppConstants.copyrightAssociations[selectedState];
|
|
|
|
}
|
2015-09-16 14:07:13 +02:00
|
|
|
}
|
2015-09-22 14:13:04 +02:00
|
|
|
|
2016-02-05 11:53:33 +01:00
|
|
|
if (currentUser.email) {
|
2015-09-17 11:39:55 +02:00
|
|
|
return (
|
|
|
|
<Form
|
|
|
|
ref='form'
|
|
|
|
url={ApiUrls.users_profile}
|
|
|
|
getFormData={this.getProfileFormData}
|
|
|
|
handleSuccess={this.handleSubmitSuccess}>
|
|
|
|
<Property
|
|
|
|
name="copyright_association"
|
2015-10-12 15:25:21 +02:00
|
|
|
className="ascribe-property-collapsible-toggle"
|
2016-02-05 10:38:59 +01:00
|
|
|
label={getLangText('Copyright Association')}>
|
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>
|
|
|
|
);
|
2016-02-05 11:53:33 +01:00
|
|
|
} else {
|
|
|
|
return null;
|
2015-09-17 11:39:55 +02:00
|
|
|
}
|
2015-09-16 14:07:13 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-02-05 10:38:59 +01:00
|
|
|
export default CopyrightAssociationForm;
|