diff --git a/frontend/src/app.js b/frontend/src/app.js
index 93c7223..d165a01 100644
--- a/frontend/src/app.js
+++ b/frontend/src/app.js
@@ -55,11 +55,26 @@ class NoEntry extends React.Component {
render() {
const logbookId = parseInt(this.props.match.params.logbookId);
+ const {hideLogbook, hideLogbookTree, eventbus} = this.props;
console.log(this.props.match.location);
return (
-
Select an entry to read it
- {logbookId ? (
+
+ {!hideLogbook &&
Select an entry to read it }
+ {logbookId && !hideLogbook ? (
{" "}
or{" "}
@@ -72,19 +87,53 @@ class NoEntry extends React.Component {
click here to make a new entry.
+
) : null}
);
}
}
+class Elogy extends React.Component {
+
+ constructor() {
+ super();
+ this.state = {
+ hideLogbookTree: false,
+ hideLogbook: false
+ };
+ this._hideLogbookTree = this._hideLogbookTree.bind(this);
+ this._hideLogbook = this._hideLogbook.bind(this);
+ }
-const Elogy = () => (
+ componentDidMount() {
+ eventbus.subscribe("logbooktree.hide", this._hideLogbookTree);
+ eventbus.subscribe("logbook.hide", this._hideLogbook);
+ }
+
+ componentWillUnmount() {
+ eventbus.unsubscribe("logbooktree.hide", this._hideLogbookTree);
+ eventbus.unsubscribe("logbook.hide", this._hideLogbook);
+ }
+
+ _hideLogbookTree(hide) {
+ this.setState({hideLogbookTree: hide});
+ }
+
+ _hideLogbook(hide) {
+ this.setState({hideLogbook: hide});
+ }
+
+ render() {
+ const EntryWithEventbus = withProps(Entry, { "eventbus": eventbus, "hideLogbookTree": this.state.hideLogbookTree, "hideLogbook": this.state.hideLogbook });
+ const NoEntryWithEventbus = withProps(NoEntry, { "eventbus": eventbus, "hideLogbookTree": this.state.hideLogbookTree, "hideLogbook": this.state.hideLogbook });
+
+ return (
/* Set up a browser router that will render the correct component
in the right places, all depending on the current URL. */
-
+ {!this.state.hideLogbookTree ?
(
/>
-
+
: null}
-
+ {!this.state.hideLogbook ?
(
/>
-
+
: null}
@@ -128,7 +177,7 @@ const Elogy = () => (
(
component={LogbookEditorWithEventbus}
/>
-
+
);
-
+}
+}
export default Elogy;
diff --git a/frontend/src/entry.js b/frontend/src/entry.js
index 4b99858..7d7bdea 100644
--- a/frontend/src/entry.js
+++ b/frontend/src/entry.js
@@ -253,6 +253,18 @@ class Entry extends React.Component {
{this.state.logbook ? (
+ {this.props.hideLogbookTree &&
+
+ this.props.eventbus.publish("logbooktree.hide", false)}>Show logbooks
+ |
+
+ }
+ {this.props.hideLogbook &&
+
+ this.props.eventbus.publish("logbook.hide", false)}>Show logbook
+ |
+
+ }
{this.state.follows ? (
{logbook.id === 0 ? "[All logbooks]" : logbook.name}
-
+
{logbook.id ? (
diff --git a/frontend/src/logbooktree.js b/frontend/src/logbooktree.js
index ab2d696..6d5eb62 100644
--- a/frontend/src/logbooktree.js
+++ b/frontend/src/logbooktree.js
@@ -106,6 +106,10 @@ class LogbookTree extends React.Component {
this.props.eventbus.unsubscribe("logbook.reload", this._reload);
}
+ hide(){
+ this.props.eventbus.publish("logbooktree.hide", true);
+ }
+
reload() {
console.log("reload logbook tree");
this.fetch(this.props.location.search);
@@ -148,6 +152,10 @@ class LogbookTree extends React.Component {