mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
refactor form_remove_piece_from_collection
This commit is contained in:
parent
0eb10c6c4b
commit
3624ae874f
@ -2,38 +2,56 @@
|
|||||||
|
|
||||||
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 PieceRemoveFromCollectionForm = React.createClass({
|
let PieceRemoveFromCollectionForm = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
pieceId: React.PropTypes.number
|
pieceId: React.PropTypes.number,
|
||||||
|
|
||||||
|
// Propagated by ModalWrapper in most cases
|
||||||
|
handleSuccess: React.PropTypes.func
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [FormMixin],
|
getFormData() {
|
||||||
|
return {
|
||||||
url() {
|
piece_id: this.props.pieceId
|
||||||
return requests.prepareUrl(apiUrls.piece_remove_from_collection, {piece_id: this.props.pieceId});
|
};
|
||||||
},
|
|
||||||
|
|
||||||
httpVerb(){
|
|
||||||
return 'delete';
|
|
||||||
},
|
},
|
||||||
|
|
||||||
renderForm () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<div className="modal-body">
|
<Form
|
||||||
|
ref='form'
|
||||||
|
url={ApiUrls.piece_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 this piece from your collection')}?</p>
|
<p>{getLangText('Are you sure you would like to remove this piece 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>
|
|
||||||
<button className="btn btn-default btn-sm ascribe-margin-1px" style={{marginLeft: '0'}}
|
|
||||||
onClick={this.props.onRequestHide}>{getLangText('CLOSE')}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user