Interactive interface for browsing global, full-resolution satellite imagery
Reset state when tour is reset or restarted
ZachTRicec41905f67bf2
diff --git a/web/js/components/tour/modal-tour-complete.js b/web/js/components/tour/modal-tour-complete.jsindex 8e24ca6c8..992d49376 100644--- a/web/js/components/tour/modal-tour-complete.js+++ b/web/js/components/tour/modal-tour-complete.js@@ -27,7 +27,7 @@ class ModalComplete extends React.Component {{list}</ModalBody><ModalFooter>- <button type="button" className="btn btn-primary" onClick={this.props.restartTour}>More Stories</button>+ <button type="button" className="btn btn-primary" onClick={this.props.resetTour}>More Stories</button><button type="button" className="btn btn-secondary" onClick={this.props.toggleModalComplete}>Exit Tutorial</button></ModalFooter></Modal>@@ -41,7 +41,7 @@ ModalComplete.propTypes = {currentStory: PropTypes.object.isRequired,toggleModalComplete: PropTypes.func.isRequired,startTour: PropTypes.func.isRequired,- restartTour: PropTypes.func.isRequired,+ resetTour: PropTypes.func.isRequired,className: PropTypes.string};diff --git a/web/js/components/tour/modal-tour-in-progress.js b/web/js/components/tour/modal-tour-in-progress.jsindex 2e6e1c156..d8d977f35 100644--- a/web/js/components/tour/modal-tour-in-progress.js+++ b/web/js/components/tour/modal-tour-in-progress.js@@ -36,17 +36,13 @@ class ModalInProgress extends React.Component {this.selectLink = this.selectLink.bind(this);}- // componentDidMount() {- // var currentStory = this.props.currentStory;- // var currentStepIndex = this.props.currentStep;- // this.fetchMetadata(currentStory, currentStepIndex);- // }-componentDidUpdate(prevProps) {var currentStory = this.props.currentStory;var currentStepIndex = this.props.currentStep - 1;if (prevProps.currentStep !== this.props.currentStep) {var prevStepIndex = prevProps.currentStep - 1;+ // Reset the prevStepIndex when a new tour is selected+ if (currentStepIndex === 0 && prevStepIndex !== 1) prevStepIndex = null;this.fetchMetadata(currentStory, currentStepIndex);this.stepLink(currentStory, currentStepIndex, prevStepIndex);@@ -339,6 +335,14 @@ class ModalInProgress extends React.Component {var { description, metaLoaded } = this.state;var currentStory = this.props.currentStory;var modalStarted = this.props.modalInProgress;++ if (this.props.restartTour) {+ this.setState({+ metaLoaded: false+ });+ this.props.toggleRestartTour();+ }+if (modalStarted && !metaLoaded) {this.setState({ metaLoaded: true });this.fetchMetadata(currentStory, 0);@@ -377,6 +381,8 @@ ModalInProgress.propTypes = {decreaseStep: PropTypes.func.isRequired,incrementStep: PropTypes.func.isRequired,showTourAlert: PropTypes.func.isRequired,+ restartTour: PropTypes.bool.isRequired,+ toggleRestartTour: PropTypes.func.isRequired,className: PropTypes.string};diff --git a/web/js/components/tour/tour.js b/web/js/components/tour/tour.jsindex 37a4f6433..5c829d86a 100644--- a/web/js/components/tour/tour.js+++ b/web/js/components/tour/tour.js@@ -23,12 +23,14 @@ class Tour extends React.Component {currentStory: props.currentStory,currentStoryId: props.currentStoryId,showTourAlert: props.showTourAlert,- hideTour: props.hideTour+ hideTour: props.hideTour,+ restartTour: props.restartTour};this.toggleModalStart = this.toggleModalStart.bind(this);this.toggleModalInProgress = this.toggleModalInProgress.bind(this);this.toggleModalComplete = this.toggleModalComplete.bind(this);+ this.toggleRestartTour = this.toggleRestartTour.bind(this);this.incrementStep = this.incrementStep.bind(this);this.decreaseStep = this.decreaseStep.bind(this);}@@ -54,6 +56,12 @@ class Tour extends React.Component {});}+ toggleRestartTour() {+ this.setState({+ restartTour: !this.state.restartTour+ });+ }+incrementStep(e) {if (this.state.currentStep + 1 <= this.state.totalSteps) this.setState({ currentStep: this.state.currentStep + 1 });if (this.state.currentStep + 1 === this.state.totalSteps + 1) {@@ -101,6 +109,8 @@ class Tour extends React.Component {currentStoryId={this.state.currentStoryId}currentStory={this.state.currentStory}showTourAlert={this.props.showTourAlert}+ restartTour={this.state.restartTour}+ toggleRestartTour={this.toggleRestartTour}></TourInProgress><TourComplete@@ -110,7 +120,7 @@ class Tour extends React.Component {toggleModalInProgress={this.toggleModalInProgress}toggleModalComplete={this.toggleModalComplete}startTour={this.props.startTour}- restartTour={this.props.restartTour}+ resetTour={this.props.resetTour}></TourComplete></div>);@@ -136,11 +146,12 @@ Tour.propTypes = {currentStory: PropTypes.object,currentStoryId: PropTypes.string,startTour: PropTypes.func.isRequired,- restartTour: PropTypes.func.isRequired,+ resetTour: PropTypes.func.isRequired,selectTour: PropTypes.func.isRequired,showTourAlert: PropTypes.func.isRequired,hideTour: PropTypes.func.isRequired,- showTour: PropTypes.func.isRequired+ showTour: PropTypes.func.isRequired,+ restartTour: PropTypes.bool.isRequired};export default Tour;diff --git a/web/js/tour/ui.js b/web/js/tour/ui.jsindex 45f8b681e..c6e82b5fd 100644--- a/web/js/tour/ui.js+++ b/web/js/tour/ui.js@@ -45,7 +45,8 @@ export function tourUi(models, ui, config) {currentStory: {},currentStoryId: '',startTour: self.startTour,- restartTour: self.restartTour,+ resetTour: self.resetTour,+ restartTour: false,selectTour: self.selectTour,notifyUserOfTour: self.notifyUserOfTour,showTourAlert: ui.alert.showTourAlert,@@ -106,9 +107,10 @@ export function tourUi(models, ui, config) {}};- self.restartTour = function(e) {+ self.resetTour = function(e) {if (e) e.preventDefault();initTourState();+ self.startTour();};self.startTour = function(e) {@@ -116,7 +118,8 @@ export function tourUi(models, ui, config) {self.reactComponent.setState({modalStart: true,modalInProgress: false,- modalComplete: false+ modalComplete: false,+ restartTour: true});};