1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 21:52:08 +02:00
onion/js/components/ascribe_forms/create_editions_form.js

61 lines
1.8 KiB
JavaScript
Raw Normal View History

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-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
},
getFormData(){
return {
piece_id: parseInt(this.props.pieceId, 10)
};
},
2015-07-13 18:13:16 +02:00
handleSuccess(response) {
let notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
if(this.props.handleSuccess) {
this.props.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-07-13 17:09:44 +02:00
spinner={
<button className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
</button>
}>
<Property
name='num_editions'
label={getLangText('Number of editions')}>
<input
type="number"
placeholder="(e.g. 32)"
2015-07-15 14:02:33 +02:00
min={1}/>
2015-07-13 17:09:44 +02:00
</Property>
</Form>
);
}
});
export default CreateEditionsForm;