1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 09:50:31 +01:00
onion/js/components/ascribe_forms/form_delete_edition.js

73 lines
2.3 KiB
JavaScript
Raw Normal View History

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';
import AscribeSpinner from '../ascribe_spinner';
2015-08-05 18:14:49 +02:00
2015-07-03 19:08:56 +02:00
import { getLangText } from '../../utils/lang_utils';
2015-11-03 10:39:01 +01:00
import AclInformation from '../ascribe_buttons/acl_information';
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}
buttons={
<div className="modal-footer">
<p className="pull-right">
<button
type="submit"
className="btn btn-danger btn-delete btn-sm ascribe-margin-1px"
onClick={this.submit}>
{getLangText('YES, DELETE')}
</button>
</p>
</div>
}
spinner={
<div className="modal-footer">
<p className="pull-right">
<AscribeSpinner color='dark-blue' size='md'/>
</p>
2015-08-05 18:14:49 +02:00
</div>
}>
2015-11-03 10:39:01 +01:00
<AclInformation aim={'form'} verbs={['acl_delete']}/>
2015-07-03 19:08:56 +02:00
<p>{getLangText('Are you sure you would like to permanently delete this edition')}&#63;</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
);
}
});
export default EditionDeleteForm;