From 39e7d619336c8beb96b38b891d8f72cfeafb6b7b Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 1 Aug 2016 16:44:46 -0300 Subject: [PATCH] Ivan - Add input disabled when loading [skip ci] --- .../main-home/main-home-page-login-widget.js | 17 +++++++++-------- client/src/core-components/input.js | 5 +++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/client/src/app/main/main-home/main-home-page-login-widget.js b/client/src/app/main/main-home/main-home-page-login-widget.js index 54c8ca38..c569ce04 100644 --- a/client/src/app/main/main-home/main-home-page-login-widget.js +++ b/client/src/app/main/main-home/main-home-page-login-widget.js @@ -27,7 +27,8 @@ let MainHomePageLoginWidget = React.createClass({ loginFormErrors: {}, recoverFormErrors: {}, recoverSent: false, - loading: false + loadingLogin: false, + loadingRecover: false }; }, @@ -95,7 +96,7 @@ let MainHomePageLoginWidget = React.createClass({ getLoginFormProps() { return { - loading: this.state.loading, + loading: this.state.loadingLogin, className: 'login-widget__form', ref: 'loginForm', onSubmit:this.handleLoginFormSubmit, @@ -106,7 +107,7 @@ let MainHomePageLoginWidget = React.createClass({ getRecoverFormProps() { return { - loading: this.state.loading, + loading: this.state.loadingRecover, className: 'login-widget__form', ref: 'recoverForm', onSubmit:this.handleForgotPasswordSubmit, @@ -119,7 +120,7 @@ let MainHomePageLoginWidget = React.createClass({ UserActions.login(formState); this.setState({ - loading: true + loadingLogin: true }); }, @@ -127,7 +128,7 @@ let MainHomePageLoginWidget = React.createClass({ UserActions.sendRecover(formState); this.setState({ - loading: true + loadingRecover: true }); }, @@ -159,7 +160,7 @@ let MainHomePageLoginWidget = React.createClass({ onUserStoreChanged(event) { if (event === 'LOGIN_FAIL') { this.setState({ - loading: false, + loadingLogin: false, loginFormErrors: { password: i18n('ERROR_PASSWORD') } @@ -170,7 +171,7 @@ let MainHomePageLoginWidget = React.createClass({ if (event === 'SEND_RECOVER_FAIL') { this.setState({ - loading: false, + loadingRecover: false, recoverFormErrors: { email: i18n('EMAIL_NOT_EXIST') } @@ -182,7 +183,7 @@ let MainHomePageLoginWidget = React.createClass({ if (event === 'SEND_RECOVER_SUCCESS') { this.setState({ - loading: false, + loadingRecover: false, recoverSent: true }); } diff --git a/client/src/core-components/input.js b/client/src/core-components/input.js index 42e6d919..34ce06bf 100644 --- a/client/src/core-components/input.js +++ b/client/src/core-components/input.js @@ -6,6 +6,10 @@ const Icon = require('core-components/icon'); const Input = React.createClass({ + contextTypes: { + loading: React.PropTypes.bool + }, + propTypes: { value: React.PropTypes.string, validation: React.PropTypes.string, @@ -60,6 +64,7 @@ const Input = React.createClass({ props['aria-required'] = this.props.required; props.type = (this.props.password) ? 'password' : 'text'; props.ref = 'nativeInput'; + props.disabled = this.context.loading; delete props.required; delete props.validation;