1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

separate pre-sending form submission functionality

This commit is contained in:
Tim Daubenschütz 2015-08-18 13:15:22 +02:00
parent eb54e6fff6
commit ad8be7e34a
6 changed files with 37 additions and 24 deletions

View File

@ -15,6 +15,8 @@ import GlobalNotificationActions from '../../actions/global_notification_actions
import FurtherDetailsFileuploader from './further_details_fileuploader';
import { isReadyForFormSubmission } from '../ascribe_uploader/react_s3_fine_uploader_utils';
let FurtherDetails = React.createClass({
propTypes: {
editable: React.PropTypes.bool,
@ -48,15 +50,6 @@ let FurtherDetails = React.createClass({
});
},
isReadyForFormSubmission(files) {
files = files.filter((file) => file.status !== 'deleted' && file.status !== 'canceled');
if(files.length > 0 && files[0].status === 'upload successful') {
return true;
} else {
return false;
}
},
render() {
//return (<span />);
return (
@ -88,7 +81,7 @@ let FurtherDetails = React.createClass({
<FurtherDetailsFileuploader
submitKey={this.submitKey}
setIsUploadReady={this.setIsUploadReady}
isReadyForFormSubmission={this.isReadyForFormSubmission}
isReadyForFormSubmission={isReadyForFormSubmission}
editable={this.props.editable}
pieceId={this.props.pieceId}
otherData={this.props.otherData}

View File

@ -16,6 +16,7 @@ import ApiUrls from '../../constants/api_urls';
import { getCookie } from '../../utils/fetch_api_utils';
import { getLangText } from '../../utils/lang_utils';
import { mergeOptions } from '../../utils/general_utils';
import { isReadyForFormSubmission } from '../ascribe_uploader/react_s3_fine_uploader_utils';
let RegisterPieceForm = React.createClass({
@ -24,6 +25,7 @@ let RegisterPieceForm = React.createClass({
submitMessage: React.PropTypes.string,
handleSuccess: React.PropTypes.func,
isFineUploaderActive: React.PropTypes.bool,
isFineUploaderEditable: React.PropTypes.bool,
enableLocalHashing: React.PropTypes.bool,
children: React.PropTypes.element,
onLoggedOut: React.PropTypes.func
@ -78,15 +80,6 @@ let RegisterPieceForm = React.createClass({
});
},
isReadyForFormSubmission(files) {
files = files.filter((file) => file.status !== 'deleted' && file.status !== 'canceled');
if (files.length > 0 && files[0].status === 'upload successful') {
return true;
} else {
return false;
}
},
render() {
let currentUser = this.state.currentUser;
let enableLocalHashing = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
@ -117,7 +110,7 @@ let RegisterPieceForm = React.createClass({
<FileUploader
submitKey={this.submitKey}
setIsUploadReady={this.setIsUploadReady}
isReadyForFormSubmission={this.isReadyForFormSubmission}
isReadyForFormSubmission={isReadyForFormSubmission}
isFineUploaderActive={this.props.isFineUploaderActive}
onLoggedOut={this.props.onLoggedOut}
editable={this.props.isFineUploaderEditable}

View File

@ -145,7 +145,10 @@ let SlidesContainer = React.createClass({
<div className="no-margin row ascribe-breadcrumb-container">
{this.props.breadcrumbs.map((breadcrumb, i) => {
return (
<Col className="no-padding" sm={columnWidth}>
<Col
className="no-padding"
sm={columnWidth}
key={i}>
<div className="ascribe-breadcrumb">
<a className={this.state.slideNum === i ? 'active' : ''}>
{this.props.breadcrumbs[i]}

View File

@ -160,7 +160,7 @@ var ReactS3FineUploader = React.createClass({
}
return name;
},
multiple: true,
multiple: false,
defaultErrorMessage: getLangText('Unexpected error. Please contact us if this happens repeatedly.')
};
},

View File

@ -0,0 +1,16 @@
'use strict';
/**
* Returns a boolean if there has been at least one file uploaded
* successfully without it being deleted or canceled.
* @param {array of files} files provided by react fine uploader
* @return {Boolean}
*/
export function isReadyForFormSubmission(files) {
files = files.filter((file) => file.status !== 'deleted' && file.status !== 'canceled');
if (files.length > 0 && files[0].status === 'upload successful') {
return true;
} else {
return false;
}
}

View File

@ -43,6 +43,7 @@ let CylandAdditionalDataForm = React.createClass({
extradata: extradata,
piece_id: this.props.piece.id
};
},
setIsUploadReady(isReady) {
@ -51,8 +52,15 @@ let CylandAdditionalDataForm = React.createClass({
});
},
isReadyForFormSubmission() {
isReadyForFormSubmission(files) {
let uploadedFiles = files.filter((file) => file.status === 'upload successful');
let uploadingFiles = files.filter((file) => file.status === 'submitting');
if (uploadedFiles.length > 0 && uploadingFiles.length === 0) {
return true;
} else {
return false;
}
},
render() {