1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-14 21:10:27 +01:00

Update RequestActionForm to use form utils

This commit is contained in:
Brett Sun 2015-10-30 11:46:01 +01:00
parent 7e1f6a382a
commit 67fbfbd470

View File

@ -16,9 +16,9 @@ import GlobalNotificationActions from '../../actions/global_notification_actions
import ApiUrls from '../../constants/api_urls'; import ApiUrls from '../../constants/api_urls';
import { getAclFormDataId } from '../../utils/form_utils';
import { getLangText } from '../../utils/lang_utils.js'; import { getLangText } from '../../utils/lang_utils.js';
let RequestActionForm = React.createClass({ let RequestActionForm = React.createClass({
propTypes: { propTypes: {
pieceOrEditions: React.PropTypes.oneOfType([ pieceOrEditions: React.PropTypes.oneOfType([
@ -58,36 +58,28 @@ let RequestActionForm = React.createClass({
}, },
getFormData() { getFormData() {
if (this.isPiece()) { return getAclFormDataId(this.isPiece(), this.props.pieceOrEditions);
return {piece_id: this.props.pieceOrEditions.id};
}
else {
return {bitcoin_id: this.props.pieceOrEditions.map(function(edition){
return edition.bitcoin_id;
}).join()};
}
}, },
showNotification(option, action, owner) { showNotification(option, action, owner) {
return () => { return () => {
let message = getLangText('You have successfully') + ' ' + option + ' the ' + action + ' request ' + getLangText('from') + ' ' + owner; const message = getLangText('You have successfully') + ' ' + option + ' the ' + action + ' request ' + getLangText('from') + ' ' + owner;
let notifications = new GlobalNotificationModel(message, 'success'); const notifications = new GlobalNotificationModel(message, 'success');
GlobalNotificationActions.appendGlobalNotification(notifications); GlobalNotificationActions.appendGlobalNotification(notifications);
this.handleSuccess(); this.handleSuccess();
}; };
}, },
handleSuccess() { handleSuccess() {
if (this.isPiece()) { if (this.isPiece()) {
NotificationActions.fetchPieceListNotifications(); NotificationActions.fetchPieceListNotifications();
} } else {
else {
NotificationActions.fetchEditionListNotifications(); NotificationActions.fetchEditionListNotifications();
} }
if(this.props.handleSuccess) {
if (typeof this.props.handleSuccess === 'function') {
this.props.handleSuccess(); this.props.handleSuccess();
} }
}, },
@ -141,8 +133,8 @@ let RequestActionForm = React.createClass({
}, },
getButtonForm() { getButtonForm() {
let urls = this.getUrls(); const urls = this.getUrls();
let acceptButtonForm = this.getAcceptButtonForm(urls); const acceptButtonForm = this.getAcceptButtonForm(urls);
return ( return (
<div> <div>