diff --git a/src/actions/index.js b/src/actions/index.js
index 3a5e890..7f39a6d 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -213,6 +213,20 @@ export function updateNarrative(narrative) {
}
}
+export const INCREMENT_NARRATIVE_CURRENT = 'INCREMENT_NARRATIVE_CURRENT';
+export function incrementNarrativeCurrent() {
+ return {
+ type: INCREMENT_NARRATIVE_CURRENT
+ }
+}
+
+export const DECREMENT_NARRATIVE_CURRENT = 'DECREMENT_NARRATIVE_CURRENT';
+export function decrementNarrativeCurrent() {
+ return {
+ type: DECREMENT_NARRATIVE_CURRENT
+ }
+}
+
export const RESET_ALLFILTERS = 'RESET_ALLFILTERS'
export function resetAllFilters() {
return {
diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx
index ee8fac7..f73580a 100644
--- a/src/components/Dashboard.jsx
+++ b/src/components/Dashboard.jsx
@@ -71,64 +71,69 @@ class Dashboard extends React.Component {
}
render() {
+ const { actions, app, domain, ui } = this.props
return (
- {this.renderClose()}
-
{this.props.narrative.label}
-
{this.props.narrative.description}
-
- location_on
- {this.state.step + 1}/{steps.length}. {step.location}
-
-
-
this.goToPrevKeyFrame()}>←
-
= this.props.narrative.steps.length - 1) ? 'disabled ' : ''} action`} onClick={() => this.goToNextKeyFrame()}>→
-
+ function _renderActions(current, steps) {
+ return (
+
+
←
- );
- } else {
- return null
- }
+
= steps.length - 1) ? 'disabled ' : ''} action`}
+ onClick={onNext}>→
+
+
+ )
+ }
+
+ // no display if no narrative
+ if (!narrative) return null
+
+ const { steps, current } = narrative
+
+ if (steps[current]) {
+ const step = steps[current];
+
+ return (
+
+ {renderClose()}
+
{narrative.label}
+
{narrative.description}
+
+ location_on
+ {current + 1}/{steps.length}. {step.location}
+
+ {_renderActions(current, steps)}
+
+ );
+ } else {
+ return null
}
}
diff --git a/src/js/utilities.js b/src/js/utilities.js
index 2c4b3c6..751a93d 100644
--- a/src/js/utilities.js
+++ b/src/js/utilities.js
@@ -93,21 +93,3 @@ export function injectSource(id) {
}
})
}
-
-/**
- * Debugging function: put in place of a mapStateToProps function to
- * view that narrative modal by default
- */
-export function injectNarrative(idx) {
- return state => {
- console.log(state.domain.narratives)
- return {
- ...state,
- app: {
- ...state.app,
- narrative: state.domain.narratives.length ? state.domain.narratives[idx] : null
- }
- }
- }
-}
-
diff --git a/src/reducers/app.js b/src/reducers/app.js
index 1904703..d5ef6d1 100644
--- a/src/reducers/app.js
+++ b/src/reducers/app.js
@@ -37,7 +37,7 @@ function updateNarrative(appState, action) {
...appState,
narrative: action.narrative,
narrativeState: {
- current: 0
+ current: !!action.narrative ? 0 : null
}
}
}