2015-06-10 15:49:46 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
2015-08-05 18:14:49 +02:00
|
|
|
import Form from './form';
|
2015-06-10 15:49:46 +02:00
|
|
|
import ApiUrls from '../../constants/api_urls';
|
2015-09-17 12:01:20 +02:00
|
|
|
import { SubmitDangerButton } from '../../lib/buttons';
|
2015-07-03 19:08:56 +02:00
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
2015-06-10 15:49:46 +02:00
|
|
|
|
2015-08-05 18:14:49 +02:00
|
|
|
|
2015-06-10 15:49:46 +02:00
|
|
|
let EditionDeleteForm = React.createClass({
|
|
|
|
|
2015-08-05 18:14:49 +02:00
|
|
|
propTypes: {
|
|
|
|
editions: React.PropTypes.arrayOf(React.PropTypes.object),
|
2015-08-06 10:15:02 +02:00
|
|
|
|
|
|
|
// Propagated by ModalWrapper in most cases
|
2015-08-05 18:14:49 +02:00
|
|
|
handleSuccess: React.PropTypes.func
|
|
|
|
},
|
2015-06-10 15:49:46 +02:00
|
|
|
|
2015-08-06 10:09:25 +02:00
|
|
|
getBitcoinIds() {
|
2015-08-05 18:14:49 +02:00
|
|
|
return this.props.editions.map(function(edition){
|
|
|
|
return edition.bitcoin_id;
|
|
|
|
});
|
2015-06-10 15:49:46 +02:00
|
|
|
},
|
2015-08-05 18:14:49 +02:00
|
|
|
|
2015-08-06 10:09:25 +02:00
|
|
|
// Since this form can be used for either deleting a single edition or multiple
|
|
|
|
// we need to call getBitcoinIds to get the value of edition_id
|
2015-08-05 18:14:49 +02:00
|
|
|
getFormData() {
|
|
|
|
return {
|
2015-08-06 10:09:25 +02:00
|
|
|
edition_id: this.getBitcoinIds().join(',')
|
2015-08-05 18:14:49 +02:00
|
|
|
};
|
2015-06-10 15:49:46 +02:00
|
|
|
},
|
|
|
|
|
2015-08-05 18:14:49 +02:00
|
|
|
render () {
|
2015-06-10 15:49:46 +02:00
|
|
|
return (
|
2015-08-05 18:14:49 +02:00
|
|
|
<Form
|
|
|
|
ref='form'
|
|
|
|
url={ApiUrls.edition_delete}
|
|
|
|
getFormData={this.getFormData}
|
2015-08-06 10:09:25 +02:00
|
|
|
method="delete"
|
2015-08-05 18:14:49 +02:00
|
|
|
handleSuccess={this.props.handleSuccess}
|
2015-09-17 12:01:20 +02:00
|
|
|
buttonSubmit={<SubmitDangerButton>{getLangText('YES, DELETE')}</SubmitDangerButton>}>
|
2015-07-03 19:08:56 +02:00
|
|
|
<p>{getLangText('Are you sure you would like to permanently delete this edition')}?</p>
|
|
|
|
<p>{getLangText('This is an irrevocable action%s', '.')}</p>
|
2015-08-05 18:14:49 +02:00
|
|
|
</Form>
|
2015-06-10 15:49:46 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-06-16 13:48:48 +02:00
|
|
|
export default EditionDeleteForm;
|