2015-07-13 17:09:44 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import Form from '../ascribe_forms/form';
|
|
|
|
import Property from '../ascribe_forms/property';
|
|
|
|
|
2015-07-13 18:13:16 +02:00
|
|
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
|
|
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
|
|
|
|
2015-10-12 17:55:02 +02:00
|
|
|
import AscribeSpinner from '../ascribe_spinner';
|
2015-08-07 15:08:02 +02:00
|
|
|
import ApiUrls from '../../constants/api_urls';
|
2015-07-13 17:09:44 +02:00
|
|
|
|
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
|
|
|
|
|
|
|
let CreateEditionsForm = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
handleSuccess: React.PropTypes.func,
|
|
|
|
pieceId: React.PropTypes.number
|
|
|
|
},
|
|
|
|
|
2015-12-16 14:48:43 +01:00
|
|
|
getFormData() {
|
2015-07-13 17:09:44 +02:00
|
|
|
return {
|
|
|
|
piece_id: parseInt(this.props.pieceId, 10)
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2015-07-13 18:13:16 +02:00
|
|
|
handleSuccess(response) {
|
2016-03-10 12:45:21 +01:00
|
|
|
const { handleSuccess } = this.props;
|
|
|
|
|
|
|
|
const notification = new GlobalNotificationModel(response.notification, 'success', 10000);
|
2015-07-13 18:13:16 +02:00
|
|
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
|
|
|
2016-03-10 12:45:21 +01:00
|
|
|
if (typeof handleSuccess === 'function') {
|
|
|
|
handleSuccess(response);
|
2015-07-13 18:13:16 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-07-13 17:09:44 +02:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Form
|
|
|
|
ref='form'
|
2015-08-07 15:08:02 +02:00
|
|
|
url={ApiUrls.editions}
|
2015-07-13 17:09:44 +02:00
|
|
|
getFormData={this.getFormData}
|
2015-07-13 18:13:16 +02:00
|
|
|
handleSuccess={this.handleSuccess}
|
2015-09-28 10:19:12 +02:00
|
|
|
buttons={
|
|
|
|
<button
|
|
|
|
type="submit"
|
2015-10-12 17:55:02 +02:00
|
|
|
className="btn btn-default btn-wide">
|
2015-09-28 10:19:12 +02:00
|
|
|
{getLangText('Create editions')}
|
|
|
|
</button>}
|
2015-07-13 17:09:44 +02:00
|
|
|
spinner={
|
2015-10-12 17:55:02 +02:00
|
|
|
<button className="btn btn-default btn-wide btn-spinner">
|
|
|
|
<AscribeSpinner color="dark-blue" size="md" />
|
2015-07-13 17:09:44 +02:00
|
|
|
</button>
|
|
|
|
}>
|
|
|
|
<Property
|
|
|
|
name='num_editions'
|
|
|
|
label={getLangText('Number of editions')}>
|
|
|
|
<input
|
|
|
|
type="number"
|
|
|
|
placeholder="(e.g. 32)"
|
2015-12-16 14:48:43 +01:00
|
|
|
min={1}
|
|
|
|
max={100} />
|
2015-07-13 17:09:44 +02:00
|
|
|
</Property>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-16 14:48:43 +01:00
|
|
|
export default CreateEditionsForm;
|