mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
make form submittable after the files blob was successfully created
This commit is contained in:
parent
5da577caca
commit
8f6b858f0a
@ -281,6 +281,7 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(getLangText('Could not find a url to download.'));
|
throw new Error(getLangText('Could not find a url to download.'));
|
||||||
}
|
}
|
||||||
|
console.log(res);
|
||||||
resolve(res.key);
|
resolve(res.key);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -294,36 +295,50 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
|
|
||||||
onComplete(id) {
|
onComplete(id) {
|
||||||
let files = this.state.filesToUpload;
|
let files = this.state.filesToUpload;
|
||||||
|
|
||||||
|
// Set the state of the completed file to 'upload successful' in order to
|
||||||
|
// remove it from the GUI
|
||||||
files[id].status = 'upload successful';
|
files[id].status = 'upload successful';
|
||||||
files[id].key = this.state.uploader.getKey(id);
|
files[id].key = this.state.uploader.getKey(id);
|
||||||
|
|
||||||
let newState = React.addons.update(this.state, {
|
let newState = React.addons.update(this.state, {
|
||||||
filesToUpload: { $set: files }
|
filesToUpload: { $set: files }
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
this.createBlob(files[id]);
|
|
||||||
|
|
||||||
// since the form validation props isReadyForFormSubmission, setIsUploadReady and submitKey
|
// Only after the blob has been created server-side, we can make the form submittable.
|
||||||
// are optional, we'll only trigger them when they're actually defined
|
this.createBlob(files[id])
|
||||||
if(this.props.submitKey) {
|
.then(() => {
|
||||||
this.props.submitKey(files[id].key);
|
// since the form validation props isReadyForFormSubmission, setIsUploadReady and submitKey
|
||||||
} else {
|
// are optional, we'll only trigger them when they're actually defined
|
||||||
console.warn('You didn\'t define submitKey in as a prop in react-s3-fine-uploader');
|
if(this.props.submitKey) {
|
||||||
}
|
this.props.submitKey(files[id].key);
|
||||||
|
} else {
|
||||||
|
console.warn('You didn\'t define submitKey in as a prop in react-s3-fine-uploader');
|
||||||
|
}
|
||||||
|
|
||||||
|
// for explanation, check comment of if statement above
|
||||||
|
if(this.props.isReadyForFormSubmission && this.props.setIsUploadReady) {
|
||||||
|
// also, lets check if after the completion of this upload,
|
||||||
|
// the form is ready for submission or not
|
||||||
|
if(this.props.isReadyForFormSubmission(this.state.filesToUpload)) {
|
||||||
|
// if so, set uploadstatus to true
|
||||||
|
this.props.setIsUploadReady(true);
|
||||||
|
} else {
|
||||||
|
this.props.setIsUploadReady(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.warn('You didn\'t define the functions isReadyForFormSubmission and/or setIsUploadReady in as a prop in react-s3-fine-uploader');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.logGlobal(err);
|
||||||
|
let notification = new GlobalNotificationModel(err.message, 'danger', 5000);
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// for explanation, check comment of if statement above
|
|
||||||
if(this.props.isReadyForFormSubmission && this.props.setIsUploadReady) {
|
|
||||||
// also, lets check if after the completion of this upload,
|
|
||||||
// the form is ready for submission or not
|
|
||||||
if(this.props.isReadyForFormSubmission(this.state.filesToUpload)) {
|
|
||||||
// if so, set uploadstatus to true
|
|
||||||
this.props.setIsUploadReady(true);
|
|
||||||
} else {
|
|
||||||
this.props.setIsUploadReady(false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.warn('You didn\'t define the functions isReadyForFormSubmission and/or setIsUploadReady in as a prop in react-s3-fine-uploader');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onError() {
|
onError() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user