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:
parent
4b8987dc7c
commit
5be771f6ac
@ -236,7 +236,8 @@ let EditionSummary = React.createClass({
|
|||||||
url={ApiUrls.ownership_transfers_withdraw}
|
url={ApiUrls.ownership_transfers_withdraw}
|
||||||
getFormData={this.getTransferWithdrawData}
|
getFormData={this.getTransferWithdrawData}
|
||||||
handleSuccess={this.showNotification}
|
handleSuccess={this.showNotification}
|
||||||
className='inline'>
|
className='inline'
|
||||||
|
isInline={true}>
|
||||||
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
|
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
|
||||||
WITHDRAW TRANSFER
|
WITHDRAW TRANSFER
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -6,6 +6,9 @@ import ReactAddons from 'react/addons';
|
|||||||
import Button from 'react-bootstrap/lib/Button';
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
import AlertDismissable from './alert';
|
import AlertDismissable from './alert';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
import requests from '../../utils/requests';
|
import requests from '../../utils/requests';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
@ -28,7 +31,12 @@ let Form = React.createClass({
|
|||||||
buttons: React.PropTypes.oneOfType([
|
buttons: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.element,
|
React.PropTypes.element,
|
||||||
React.PropTypes.arrayOf(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() {
|
getDefaultProps() {
|
||||||
@ -136,7 +144,14 @@ let Form = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.logGlobal(err, false, formData);
|
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});
|
this.setState({submitted: false});
|
||||||
},
|
},
|
||||||
|
@ -54,7 +54,7 @@ let RequestActionForm = React.createClass({
|
|||||||
|
|
||||||
showNotification(option, action, owner) {
|
showNotification(option, action, owner) {
|
||||||
return () => {
|
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');
|
let notification = new GlobalNotificationModel(message, 'success');
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
@ -94,6 +94,7 @@ let RequestActionForm = React.createClass({
|
|||||||
url={urls.accept}
|
url={urls.accept}
|
||||||
getFormData={this.getFormData}
|
getFormData={this.getFormData}
|
||||||
handleSuccess={this.showNotification(getLangText('denied'), edition.request_action, edition.owner)}
|
handleSuccess={this.showNotification(getLangText('denied'), edition.request_action, edition.owner)}
|
||||||
|
isInline={true}
|
||||||
className='inline pull-right'>
|
className='inline pull-right'>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
@ -115,6 +116,7 @@ let RequestActionForm = React.createClass({
|
|||||||
<div>
|
<div>
|
||||||
<Form
|
<Form
|
||||||
url={urls.deny}
|
url={urls.deny}
|
||||||
|
isInline={true}
|
||||||
getFormData={this.getFormData}
|
getFormData={this.getFormData}
|
||||||
handleSuccess={this.showNotification(getLangText('accepted'), edition.request_action, edition.owner)}
|
handleSuccess={this.showNotification(getLangText('accepted'), edition.request_action, edition.owner)}
|
||||||
className='inline pull-right'>
|
className='inline pull-right'>
|
||||||
|
Loading…
Reference in New Issue
Block a user