From 713eea03ccd1c03bb57c6bd42f26ad4a60cb7683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 14 Oct 2015 16:20:51 +0200 Subject: [PATCH] Better robustness for slides container and register form for cyland --- .../slides_container.js | 17 +++++++---------- .../ascribe_buttons/cyland_submit_button.js | 18 ++++-------------- .../cyland_additional_data_form.js | 10 +++++----- .../components/cyland/cyland_register_piece.js | 3 ++- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/js/components/ascribe_slides_container/slides_container.js b/js/components/ascribe_slides_container/slides_container.js index cbb2c167..8ed66c1d 100644 --- a/js/components/ascribe_slides_container/slides_container.js +++ b/js/components/ascribe_slides_container/slides_container.js @@ -29,8 +29,6 @@ const SlidesContainer = React.createClass({ }, componentDidMount() { - this.handleContainerResize(); - // we're using an event listener on window here, // as it was not possible to listen to the resize events of a dom node window.addEventListener('resize', this.handleContainerResize); @@ -51,16 +49,15 @@ const SlidesContainer = React.createClass({ }, // When the start_from parameter is used, this.setSlideNum can not simply be used anymore. - nextSlide() { - const slideNum = parseInt(this.props.location.query.slide_num, 10); + nextSlide(additionalQueryParams) { + const slideNum = parseInt(this.props.location.query.slide_num, 10) || 0; let nextSlide = slideNum + 1; - this.setSlideNum(nextSlide); + this.setSlideNum(nextSlide, additionalQueryParams); }, - setSlideNum(nextSlideNum) { - let queryParams = this.props.location.query; + setSlideNum(nextSlideNum, additionalQueryParams = {}) { + let queryParams = Object.assign(this.props.location.query, additionalQueryParams); queryParams.slide_num = nextSlideNum; - this.history.pushState(null, this.props.location.pathname, queryParams); }, @@ -107,7 +104,7 @@ const SlidesContainer = React.createClass({ return ( @@ -142,7 +139,7 @@ const SlidesContainer = React.createClass({ }, render() { - let spacing = this.state.containerWidth * parseInt(this.props.location.query.slide_num, 10); + let spacing = this.state.containerWidth * parseInt(this.props.location.query.slide_num, 10) || 0; let translateXValue = 'translateX(' + (-1) * spacing + 'px)'; /* diff --git a/js/components/whitelabel/wallet/components/cyland/ascribe_buttons/cyland_submit_button.js b/js/components/whitelabel/wallet/components/cyland/ascribe_buttons/cyland_submit_button.js index 03c976e9..1cf1ee45 100644 --- a/js/components/whitelabel/wallet/components/cyland/ascribe_buttons/cyland_submit_button.js +++ b/js/components/whitelabel/wallet/components/cyland/ascribe_buttons/cyland_submit_button.js @@ -38,28 +38,18 @@ let CylandSubmitButton = React.createClass({ }, render() { - let piece = this.props.piece; - let startFrom = 1; - - // In the Cyland register page a user has to complete three steps. - // Since every one of those steps is atomic a user should always be able to continue - // where he left of. - // This is why we start the process form slide 1/2 if the user has already finished - // it in another session. - if(piece && piece.extra_data && Object.keys(piece.extra_data).length > 0) { - startFrom = 2; - } + const { piece, className } = this.props; return ( diff --git a/js/components/whitelabel/wallet/components/cyland/ascribe_forms/cyland_additional_data_form.js b/js/components/whitelabel/wallet/components/cyland/ascribe_forms/cyland_additional_data_form.js index 7e18bd10..8db721ac 100644 --- a/js/components/whitelabel/wallet/components/cyland/ascribe_forms/cyland_additional_data_form.js +++ b/js/components/whitelabel/wallet/components/cyland/ascribe_forms/cyland_additional_data_form.js @@ -36,17 +36,17 @@ let CylandAdditionalDataForm = React.createClass({ }; }, - handleSuccess() { - let notification = new GlobalNotificationModel('Further details successfully updated', 'success', 10000); - GlobalNotificationActions.appendGlobalNotification(notification); - }, - getInitialState() { return { isUploadReady: true }; }, + handleSuccess() { + let notification = new GlobalNotificationModel('Further details successfully updated', 'success', 10000); + GlobalNotificationActions.appendGlobalNotification(notification); + }, + getFormData() { let extradata = {}; let formRefs = this.refs.form.refs; diff --git a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js index 73cefaa1..5b2289b3 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -104,12 +104,13 @@ let CylandRegisterPiece = React.createClass({ // also start loading the piece for the next step if(response && response.piece) { + PieceActions.updatePiece({}); PieceActions.updatePiece(response.piece); } this.incrementStep(); - this.refs.slidesContainer.nextSlide(); + this.refs.slidesContainer.nextSlide({ piece_id: response.piece.id }); }, handleAdditionalDataSuccess() {