mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
refactor form_remove_editions_from_collection
This commit is contained in:
parent
68f4decaad
commit
0eb10c6c4b
@ -21,7 +21,7 @@ let PieceExtraDataForm = React.createClass({
|
|||||||
editable: React.PropTypes.bool
|
editable: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getFormData(){
|
getFormData() {
|
||||||
let extradata = {};
|
let extradata = {};
|
||||||
extradata[this.props.name] = this.refs.form.refs[this.props.name].state.value;
|
extradata[this.props.name] = this.refs.form.refs[this.props.name].state.value;
|
||||||
return {
|
return {
|
||||||
|
@ -2,34 +2,63 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils.js';
|
import Form from './form';
|
||||||
import requests from '../../utils/requests';
|
|
||||||
import apiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
import FormMixin from '../../mixins/form_mixin';
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
|
||||||
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
let EditionRemoveFromCollectionForm = React.createClass({
|
let EditionRemoveFromCollectionForm = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
editions: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||||
|
|
||||||
mixins: [FormMixin],
|
// Propagated by ModalWrapper in most cases
|
||||||
|
handleSuccess: React.PropTypes.func
|
||||||
url() {
|
|
||||||
return requests.prepareUrl(apiUrls.edition_remove_from_collection, {edition_id: this.getBitcoinIds().join()});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
httpVerb(){
|
getBitcoinIds() {
|
||||||
return 'delete';
|
return this.props.editions.map(function(edition){
|
||||||
|
return edition.bitcoin_id;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderForm () {
|
// 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(',')
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="modal-body">
|
<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">
|
||||||
|
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_small.gif'} />
|
||||||
|
</div>
|
||||||
|
}>
|
||||||
<p>{getLangText('Are you sure you would like to remove these editions from your collection')}?</p>
|
<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>
|
<p>{getLangText('This is an irrevocable action%s', '.')}</p>
|
||||||
<div className="modal-footer">
|
</Form>
|
||||||
<button type="submit" className="btn btn-danger btn-delete btn-sm ascribe-margin-1px" onClick={this.submit}>
|
|
||||||
{getLangText('YES, REMOVE')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user