mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
modal error resolves
This commit is contained in:
parent
a8807e8d3c
commit
d4a98ce7c4
@ -8,6 +8,7 @@ import Modal from 'react-bootstrap/lib/Modal';
|
||||
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
|
||||
import ModalTrigger from 'react-bootstrap/lib/ModalTrigger';
|
||||
import Tooltip from 'react-bootstrap/lib/Tooltip';
|
||||
import Alert from 'react-bootstrap/lib/Alert';
|
||||
|
||||
|
||||
let ShareModalButton = React.createClass({
|
||||
@ -26,12 +27,17 @@ let ShareModalButton = React.createClass({
|
||||
});
|
||||
|
||||
let ShareModal = React.createClass({
|
||||
onRequestHide(e){
|
||||
e.preventDefault();
|
||||
this.props.onRequestHide();
|
||||
},
|
||||
render() {
|
||||
return (
|
||||
<Modal {...this.props} title="Share artwork">
|
||||
<div className="modal-body">
|
||||
<ShareForm edition={this.props.edition}
|
||||
currentUser={this.props.currentUser}/>
|
||||
currentUser={this.props.currentUser}
|
||||
onRequestHide={this.onRequestHide}/>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
@ -40,7 +46,7 @@ let ShareModal = React.createClass({
|
||||
|
||||
let ShareForm = React.createClass({
|
||||
getInitialState() {
|
||||
return {errors: []}
|
||||
return {errors: null}
|
||||
},
|
||||
submit(e) {
|
||||
e.preventDefault();
|
||||
@ -70,17 +76,33 @@ let ShareForm = React.createClass({
|
||||
share_message: this.refs.share_message.getDOMNode().value
|
||||
}
|
||||
},
|
||||
renderAlert(id){
|
||||
if (this.state.errors && id in this.state.errors) {
|
||||
return this.state.errors[id].map(function(error) {
|
||||
return <AlertDismissable error={error} key={error}/>
|
||||
}
|
||||
)
|
||||
}
|
||||
return <span />
|
||||
},
|
||||
renderTextInput(id, placeHolder, required) {
|
||||
|
||||
return (
|
||||
<div className="form-group">
|
||||
{this.renderAlert(id)}
|
||||
<input className="form-control input-text-ascribe" name={id} ref={id}
|
||||
placeholder={placeHolder} required={required} type="text" />
|
||||
</div>
|
||||
)
|
||||
},
|
||||
renderTextArea(id, placeHolder, required) {
|
||||
let alert = "";
|
||||
if (this.state.errors && id in this.state.errors) {
|
||||
alert = <AlertDismissable error={this.state.errors.id} />
|
||||
}
|
||||
return (
|
||||
<div className="form-group">
|
||||
{alert}
|
||||
<textarea className="form-control input-text-ascribe textarea-ascribe-message" name={id} ref={id}
|
||||
defaultValue={placeHolder} required={required}></textarea>
|
||||
</div>
|
||||
@ -102,4 +124,27 @@ let ShareForm = React.createClass({
|
||||
}
|
||||
});
|
||||
|
||||
const AlertDismissable = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
alertVisible: true
|
||||
};
|
||||
},
|
||||
render() {
|
||||
if (this.state.alertVisible) {
|
||||
return (
|
||||
<Alert bsStyle='danger' onDismiss={this.handleAlertDismiss}>
|
||||
{this.props.error}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span />
|
||||
);
|
||||
},
|
||||
handleAlertDismiss() {
|
||||
this.setState({alertVisible: false});
|
||||
}
|
||||
});
|
||||
|
||||
export default ShareModalButton;
|
||||
|
Loading…
Reference in New Issue
Block a user