1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-07 04:04:20 +01:00
onion/js/components/ascribe_forms/form_delete_edition.js

73 lines
2.3 KiB
JavaScript
Raw Permalink 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';
import AclInformation from '../ascribe_buttons/acl_information';
import AscribeSpinner from '../ascribe_spinner';
2015-08-05 18:14:49 +02:00
import { getLangText } from '../../utils/lang';
import { formatText } from '../../utils/text';
import { resolveUrl } from '../../utils/url_resolver';
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() {
return this.props.editions.map((edition) => edition.bitcoin_id);
2015-06-10 15:49:46 +02:00
},
2015-08-05 18:14:49 +02:00
getUrl() {
return formatText(resolveUrl('edition_delete'), {
// 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
editionId: this.getBitcoinIds().join(',')
});
2015-06-10 15:49:46 +02:00
},
render() {
2015-06-10 15:49:46 +02:00
return (
2015-08-05 18:14:49 +02:00
<Form
ref='form'
url={this.getUrl()}
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-10-15 11:17:16 +02: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;