1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

refactor form_delete_piece

This commit is contained in:
Tim Daubenschütz 2015-08-06 10:15:02 +02:00
parent dbd0e14a64
commit a3bfda186a
2 changed files with 39 additions and 22 deletions

View File

@ -14,6 +14,8 @@ let EditionDeleteForm = React.createClass({
propTypes: { propTypes: {
editions: React.PropTypes.arrayOf(React.PropTypes.object), editions: React.PropTypes.arrayOf(React.PropTypes.object),
// Propagated by ModalWrapper in most cases
handleSuccess: React.PropTypes.func handleSuccess: React.PropTypes.func
}, },

View File

@ -2,40 +2,55 @@
import React from 'react'; import React from 'react';
import requests from '../../utils/requests'; import Form from '../ascribe_forms/form';
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'; import { getLangText } from '../../utils/lang_utils';
let PieceDeleteForm = React.createClass({ let PieceDeleteForm = 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, {piece_id: this.props.pieceId}); };
}, },
httpVerb() { render() {
return 'delete';
},
renderForm () {
return ( return (
<div className="modal-body"> <Form
ref='form'
url={ApiUrls.piece}
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, DELETE')}
</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 permanently delete this piece')}&#63;</p> <p>{getLangText('Are you sure you would like to permanently delete this piece')}&#63;</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, DELETE')}
</button>
</div>
</div>
); );
} }
}); });