2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-01 18:59:47 +02:00
|
|
|
import React from 'react';
|
|
|
|
import ReactAddons from 'react/addons';
|
|
|
|
|
|
|
|
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';
|
|
|
|
|
2015-06-05 11:06:36 +02:00
|
|
|
import ModalMixin from '../../mixins/modal_mixin';
|
2015-06-01 18:59:47 +02:00
|
|
|
|
|
|
|
let ModalWrapper = React.createClass({
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<OverlayTrigger delay={500} placement="left"
|
|
|
|
overlay={<Tooltip>{this.props.tooltip}</Tooltip>}>
|
|
|
|
<ModalTrigger modal={
|
|
|
|
<ModalBody
|
|
|
|
title={this.props.title}
|
2015-06-02 11:38:18 +02:00
|
|
|
editions={this.props.editions}
|
|
|
|
currentUser={this.props.currentUser}
|
|
|
|
handleSuccess={this.props.handleSuccess}
|
|
|
|
>
|
2015-06-01 18:59:47 +02:00
|
|
|
{this.props.children}
|
|
|
|
</ModalBody>
|
|
|
|
}>
|
|
|
|
{this.props.button}
|
|
|
|
</ModalTrigger>
|
|
|
|
</OverlayTrigger>
|
2015-06-05 11:06:36 +02:00
|
|
|
);
|
2015-06-01 18:59:47 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//
|
|
|
|
let ModalBody = React.createClass({
|
2015-06-05 11:06:36 +02:00
|
|
|
|
|
|
|
mixins: [ModalMixin],
|
2015-06-01 18:59:47 +02:00
|
|
|
|
2015-06-02 11:38:18 +02:00
|
|
|
handleSuccess(){
|
|
|
|
this.props.handleSuccess();
|
|
|
|
this.props.onRequestHide();
|
|
|
|
},
|
2015-06-05 11:06:36 +02:00
|
|
|
|
2015-06-01 18:59:47 +02:00
|
|
|
renderChildren() {
|
2015-06-05 11:06:36 +02:00
|
|
|
return ReactAddons.Children.map(this.props.children, (child) => {
|
2015-06-01 18:59:47 +02:00
|
|
|
return ReactAddons.addons.cloneWithProps(child, {
|
2015-06-02 11:38:18 +02:00
|
|
|
editions: this.props.editions,
|
2015-06-01 18:59:47 +02:00
|
|
|
currentUser: this.props.currentUser,
|
2015-06-02 11:38:18 +02:00
|
|
|
onRequestHide: this.onRequestHide,
|
|
|
|
handleSuccess: this.handleSuccess
|
2015-06-01 18:59:47 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2015-06-05 11:06:36 +02:00
|
|
|
|
2015-06-01 18:59:47 +02:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Modal {...this.props} title={this.props.title}>
|
|
|
|
<div className="modal-body">
|
|
|
|
{this.renderChildren()}
|
|
|
|
</div>
|
|
|
|
</Modal>
|
2015-06-05 11:06:36 +02:00
|
|
|
);
|
2015-06-01 18:59:47 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
export default ModalWrapper;
|