diff --git a/js/components/ascribe_forms/form_register_piece.js b/js/components/ascribe_forms/form_register_piece.js index b09d29ac..da19ea96 100644 --- a/js/components/ascribe_forms/form_register_piece.js +++ b/js/components/ascribe_forms/form_register_piece.js @@ -8,6 +8,7 @@ import UserActions from '../../actions/user_actions'; import Form from './form'; import Property from './property'; import InputFineUploader from './input_fineuploader'; +import UploadButton from '../ascribe_uploader/ascribe_upload_button/upload_button'; import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; @@ -48,7 +49,8 @@ let RegisterPieceForm = React.createClass({ getInitialState(){ return mergeOptions( { - isUploadReady: false + digitalWorkKeyReady: false, + thumbnailKeyReady: true }, UserStore.getState() ); @@ -67,30 +69,49 @@ let RegisterPieceForm = React.createClass({ this.setState(state); }, - setIsUploadReady(isReady) { - this.setState({ - isUploadReady: isReady - }); + /** + * This method is overloaded so that we can track the ready-state + * of each uploader in the component + * @param {string} uploaderKey Name of the uploader's key to track + */ + setIsUploadReady(uploaderKey) { + return (isUploadReady) => { + this.setState({ + [uploaderKey]: isUploadReady + }); + }; }, render() { - let currentUser = this.state.currentUser; - let enableLocalHashing = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false; - enableLocalHashing = enableLocalHashing && this.props.enableLocalHashing; + const { disabled, + handleSuccess, + submitMessage, + headerMessage, + isFineUploaderActive, + onLoggedOut, + isFineUploaderEditable, + location, + children, + enableLocalHashing } = this.props; + const { currentUser, + isUploadReady } = this.state; + + const profileHashLocally = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false; + const hashLocally = profileHashLocally && enableLocalHashing; return (
- {this.props.submitMessage} + disabled={!isUploadReady || disabled}> + {submitMessage} } spinner={ @@ -99,7 +120,7 @@ let RegisterPieceForm = React.createClass({ }>
-

{this.props.headerMessage}

+

{headerMessage}

+ isFineUploaderActive={isFineUploaderActive} + onLoggedOut={onLoggedOut} + disabled={!isFineUploaderEditable} + enableLocalHashing={hashLocally} + uploadMethod={location.query.method} /> + + + - {this.props.children} + {children}
); } diff --git a/js/components/ascribe_forms/property.js b/js/components/ascribe_forms/property.js index ac272988..d0c22dc2 100644 --- a/js/components/ascribe_forms/property.js +++ b/js/components/ascribe_forms/property.js @@ -220,6 +220,19 @@ let Property = React.createClass({ }); }, + getLabelAndErrors() { + if(this.props.label || this.state.errors) { + return ( +

+ {this.props.label} + {this.state.errors} +

+ ); + } else { + return null; + } + }, + render() { let footer = null; let tooltip = ; @@ -253,10 +266,7 @@ let Property = React.createClass({ placement="top" overlay={tooltip}>
-

- {this.props.label} - {this.state.errors} -

+ {this.getLabelAndErrors()} {this.renderChildren(style)} {footer}