Use new onClose prop to close sources when no result was selected

This commit is contained in:
Thibaud Colas 2018-01-17 11:09:18 +02:00
parent 127cea6d9c
commit d841616d0a
2 changed files with 3 additions and 12 deletions

View file

@ -16,21 +16,11 @@ class DocumentSource extends ModalSource {
}
componentDidMount() {
const { entity } = this.props;
const documentChooser = global.chooserUrls.documentChooser;
const url = documentChooser;
$(document.body).on('hidden.bs.modal', this.onClose);
// TODO: wagtail should support passing params to this endpoint.
if (entity) {
// const entityData = entity.getData();
// console.log(entityData);
// if (entityData.title) {
// url = url + `?q=${entityData.title}`
// }
}
// eslint-disable-next-line new-cap
window.ModalWorkflow({
url,

View file

@ -46,10 +46,10 @@ class ModalSource extends React.Component {
}
onClose(e) {
const { onComplete } = this.props;
const { onClose } = this.props;
e.preventDefault();
onComplete();
onClose();
}
render() {
@ -63,6 +63,7 @@ ModalSource.propTypes = {
// eslint-disable-next-line
entity: PropTypes.object,
onComplete: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
};
ModalSource.defaultProps = {