2015-06-11 15:03:55 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
2015-08-06 10:31:51 +02:00
|
|
|
import Form from './form';
|
|
|
|
|
|
|
|
import ApiUrls from '../../constants/api_urls';
|
2015-10-12 15:25:21 +02:00
|
|
|
import AscribeSpinner from '../ascribe_spinner';
|
2015-08-06 10:31:51 +02:00
|
|
|
|
|
|
|
import { getLangText } from '../../utils/lang_utils';
|
2015-06-11 15:03:55 +02:00
|
|
|
|
|
|
|
let EditionRemoveFromCollectionForm = React.createClass({
|
2015-08-06 10:31:51 +02:00
|
|
|
propTypes: {
|
|
|
|
editions: React.PropTypes.arrayOf(React.PropTypes.object),
|
2015-06-11 15:03:55 +02:00
|
|
|
|
2015-08-06 10:31:51 +02:00
|
|
|
// Propagated by ModalWrapper in most cases
|
|
|
|
handleSuccess: React.PropTypes.func
|
|
|
|
},
|
2015-06-11 15:03:55 +02:00
|
|
|
|
2015-08-06 10:31:51 +02:00
|
|
|
getBitcoinIds() {
|
|
|
|
return this.props.editions.map(function(edition){
|
|
|
|
return edition.bitcoin_id;
|
|
|
|
});
|
2015-06-11 15:03:55 +02:00
|
|
|
},
|
2015-08-06 10:31:51 +02:00
|
|
|
|
|
|
|
// Since this form can be used for either removing a single edition or multiple
|
|
|
|
// we need to call getBitcoinIds to get the value of edition_id
|
|
|
|
getFormData() {
|
|
|
|
return {
|
|
|
|
edition_id: this.getBitcoinIds().join(',')
|
|
|
|
};
|
2015-06-11 15:03:55 +02:00
|
|
|
},
|
|
|
|
|
2015-08-06 10:31:51 +02:00
|
|
|
render() {
|
2015-06-11 15:03:55 +02:00
|
|
|
return (
|
2015-08-06 10:31:51 +02:00
|
|
|
<Form
|
|
|
|
ref='form'
|
|
|
|
url={ApiUrls.edition_remove_from_collection}
|
|
|
|
getFormData={this.getFormData}
|
|
|
|
method="delete"
|
|
|
|
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, REMOVE')}
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
spinner={
|
|
|
|
<div className="modal-footer">
|
2015-10-12 15:25:21 +02:00
|
|
|
<p className="pull-right">
|
|
|
|
<AscribeSpinner color='dark-blue' size='md'/>
|
|
|
|
</p>
|
2015-08-06 10:31:51 +02:00
|
|
|
</div>
|
|
|
|
}>
|
2015-07-03 19:08:56 +02:00
|
|
|
<p>{getLangText('Are you sure you would like to remove these editions from your collection')}?</p>
|
|
|
|
<p>{getLangText('This is an irrevocable action%s', '.')}</p>
|
2015-08-06 10:31:51 +02:00
|
|
|
</Form>
|
2015-06-11 15:03:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-06-16 13:48:48 +02:00
|
|
|
export default EditionRemoveFromCollectionForm;
|