From 495f5600af8fab9ce6c01ae91deda1e75a6e48e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 19 Aug 2015 17:39:25 +0200 Subject: [PATCH] implement form locking for cyland --- .../ascribe_forms/form_register_piece.js | 10 +++++++--- .../cyland_additional_data_form.js | 7 +++++-- .../cyland/cyland_register_piece.js | 19 ++++++++++++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/js/components/ascribe_forms/form_register_piece.js b/js/components/ascribe_forms/form_register_piece.js index a47ab00e..3519c976 100644 --- a/js/components/ascribe_forms/form_register_piece.js +++ b/js/components/ascribe_forms/form_register_piece.js @@ -28,7 +28,10 @@ let RegisterPieceForm = React.createClass({ isFineUploaderEditable: React.PropTypes.bool, enableLocalHashing: React.PropTypes.bool, children: React.PropTypes.element, - onLoggedOut: React.PropTypes.func + onLoggedOut: React.PropTypes.func, + + // For this form to work with SlideContainer, we sometimes have to disable it + disabled: React.PropTypes.bool }, getDefaultProps() { @@ -84,9 +87,10 @@ let RegisterPieceForm = React.createClass({ let currentUser = this.state.currentUser; let enableLocalHashing = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false; enableLocalHashing = enableLocalHashing && this.props.enableLocalHashing; + return (
+ disabled={!this.state.isUploadReady || this.props.disabled}> {this.props.submitMessage} } spinner={ 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 38eeee7f..397e5d6d 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 @@ -19,7 +19,9 @@ import { getLangText } from '../../../../../../utils/lang_utils'; let CylandAdditionalDataForm = React.createClass({ propTypes: { handleSuccess: React.PropTypes.func.isRequired, - piece: React.PropTypes.object.isRequired + piece: React.PropTypes.object.isRequired, + + disabled: React.PropTypes.bool }, getInitialState() { @@ -67,6 +69,7 @@ let CylandAdditionalDataForm = React.createClass({ if(this.props.piece && this.props.piece.id) { return ( + disabled={!this.state.isUploadReady || this.props.disabled}> {getLangText('Proceed to loan')} } 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 1c07bbd1..6e4abead 100644 --- a/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js +++ b/js/components/whitelabel/wallet/components/cyland/cyland_register_piece.js @@ -53,7 +53,8 @@ let CylandRegisterPiece = React.createClass({ WhitelabelStore.getState(), { selectedLicense: 0, - isFineUploaderActive: false + isFineUploaderActive: false, + step: 0 }); }, @@ -99,11 +100,16 @@ let CylandRegisterPiece = React.createClass({ PieceActions.updatePiece(response.piece); } + this.incrementStep(); + this.refs.slidesContainer.nextSlide(); }, handleAdditionalDataSuccess() { this.refreshPieceList(); + + this.incrementStep(); + this.refs.slidesContainer.nextSlide(); }, @@ -117,6 +123,15 @@ let CylandRegisterPiece = React.createClass({ this.transitionTo('piece', {pieceId: this.state.piece.id}); }, + // We need to increase the step to lock the forms that are already filed out + incrementStep() { + // also increase step + let newStep = this.state.step + 1; + this.setState({ + step: newStep + }); + }, + refreshPieceList() { PieceListActions.fetchPieceList( this.state.page, @@ -155,6 +170,7 @@ let CylandRegisterPiece = React.createClass({ 0} enableLocalHashing={false} headerMessage={getLangText('Submit to Cyland Archive')} submitMessage={getLangText('Submit')} @@ -182,6 +198,7 @@ let CylandRegisterPiece = React.createClass({ 1} handleSuccess={this.handleAdditionalDataSuccess} piece={this.state.piece}/>