2015-05-26 10:52:20 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
2015-05-26 13:48:46 +02:00
|
|
|
import EditionActions from '../actions/edition_actions';
|
|
|
|
import EditionStore from '../stores/edition_store';
|
2015-05-27 09:34:49 +02:00
|
|
|
import UserActions from '../actions/user_actions';
|
|
|
|
import UserStore from '../stores/user_store';
|
2015-05-26 10:52:20 +02:00
|
|
|
|
2015-05-26 13:48:46 +02:00
|
|
|
import Edition from './edition';
|
2015-05-26 10:52:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the component that implements resource/data specific functionality
|
|
|
|
*/
|
2015-05-26 13:48:46 +02:00
|
|
|
let EditionContainer = React.createClass({
|
2015-05-26 10:52:20 +02:00
|
|
|
|
|
|
|
getInitialState() {
|
2015-05-27 09:34:49 +02:00
|
|
|
return {'user': UserStore.getState(),
|
|
|
|
'edition': EditionStore.getState()}
|
2015-05-26 10:52:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
onChange(state) {
|
|
|
|
this.setState(state);
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount() {
|
2015-05-26 13:48:46 +02:00
|
|
|
EditionActions.fetchOne(this.props.params.editionId);
|
|
|
|
EditionStore.listen(this.onChange);
|
2015-05-27 09:34:49 +02:00
|
|
|
UserActions.fetchCurrentUser();
|
|
|
|
UserStore.listen(this.onChange);
|
2015-05-26 10:52:20 +02:00
|
|
|
},
|
|
|
|
componentDidUnmount() {
|
2015-05-26 13:48:46 +02:00
|
|
|
EditionStore.unlisten(this.onChange);
|
2015-05-27 09:34:49 +02:00
|
|
|
UserStore.unlisten(this.onChange);
|
2015-05-26 10:52:20 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
2015-05-26 13:48:46 +02:00
|
|
|
if('title' in this.state.edition) {
|
2015-05-26 10:52:20 +02:00
|
|
|
return (
|
2015-05-27 09:34:49 +02:00
|
|
|
<Edition edition={this.state.edition } currentUser={this.state.currentUser}></Edition>
|
2015-05-26 10:52:20 +02:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<p>Loading</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-05-26 13:48:46 +02:00
|
|
|
export default EditionContainer;
|