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

add inline property to form

This commit is contained in:
Tim Daubenschütz 2015-08-10 14:15:32 +02:00
parent 4b8987dc7c
commit 5be771f6ac
3 changed files with 22 additions and 4 deletions

View File

@ -236,7 +236,8 @@ let EditionSummary = React.createClass({
url={ApiUrls.ownership_transfers_withdraw}
getFormData={this.getTransferWithdrawData}
handleSuccess={this.showNotification}
className='inline'>
className='inline'
isInline={true}>
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
WITHDRAW TRANSFER
</Button>

View File

@ -6,6 +6,9 @@ import ReactAddons from 'react/addons';
import Button from 'react-bootstrap/lib/Button';
import AlertDismissable from './alert';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
import requests from '../../utils/requests';
import { getLangText } from '../../utils/lang_utils';
@ -28,7 +31,12 @@ let Form = React.createClass({
buttons: React.PropTypes.oneOfType([
React.PropTypes.element,
React.PropTypes.arrayOf(React.PropTypes.element)
])
]),
// You can use the form for inline requests, like the submit click on a button.
// For the form to then not display the error on top, you need to enable this option.
// It will make use of the GlobalNotification
isInline: React.PropTypes.bool
},
getDefaultProps() {
@ -136,7 +144,14 @@ let Form = React.createClass({
}
console.logGlobal(err, false, formData);
this.setState({errors: [getLangText('Something went wrong, please try again later')]});
if(this.props.isInline) {
let notification = new GlobalNotificationModel(getLangText('Something went wrong, please try again later'), 'danger');
GlobalNotificationActions.appendGlobalNotification(notification);
} else {
this.setState({errors: [getLangText('Something went wrong, please try again later')]});
}
}
this.setState({submitted: false});
},

View File

@ -54,7 +54,7 @@ let RequestActionForm = React.createClass({
showNotification(option, action, owner) {
return () => {
let message = getLangText('You have successfully') + ' ' + option + ' ' + action + ' ' + getLangText('to') + ' ' + owner;
let message = getLangText('You have successfully') + ' ' + option + ' the ' + action + ' request ' + getLangText('from') + ' ' + owner;
let notification = new GlobalNotificationModel(message, 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
@ -94,6 +94,7 @@ let RequestActionForm = React.createClass({
url={urls.accept}
getFormData={this.getFormData}
handleSuccess={this.showNotification(getLangText('denied'), edition.request_action, edition.owner)}
isInline={true}
className='inline pull-right'>
<button
type="submit"
@ -115,6 +116,7 @@ let RequestActionForm = React.createClass({
<div>
<Form
url={urls.deny}
isInline={true}
getFormData={this.getFormData}
handleSuccess={this.showNotification(getLangText('accepted'), edition.request_action, edition.owner)}
className='inline pull-right'>