mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
reset method for react s3 fineuploader
This commit is contained in:
parent
c3b71b5398
commit
1d184973f4
@ -30,7 +30,6 @@ let InputFileUploader = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
value: null
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
@ -40,8 +39,11 @@ let InputFileUploader = React.createClass({
|
||||
});
|
||||
},
|
||||
|
||||
render() {
|
||||
reset() {
|
||||
this.refs.fineuploader.reset();
|
||||
},
|
||||
|
||||
render() {
|
||||
let editable = this.props.isFineUploaderActive;
|
||||
|
||||
// if disabled is actually set by property, we want to override
|
||||
@ -50,9 +52,9 @@ let InputFileUploader = React.createClass({
|
||||
editable = !this.props.disabled;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<ReactS3FineUploader
|
||||
ref="fineuploader"
|
||||
onClick={this.props.onClick}
|
||||
keyRoutine={{
|
||||
url: AppConstants.serverUrl + 's3/key/',
|
||||
|
@ -96,6 +96,14 @@ let Property = React.createClass({
|
||||
// resets the value of a plain HTML5 input
|
||||
this.refs.input.getDOMNode().value = this.state.initialValue;
|
||||
|
||||
// For some inputs, reseting state.value is not enough to visually reset the
|
||||
// component.
|
||||
//
|
||||
// So if the input actually needs a visual reset, it needs to implement
|
||||
// a dedicated reset method.
|
||||
if(this.refs.input.reset && typeof this.refs.input.reset === 'function') {
|
||||
this.refs.input.reset();
|
||||
}
|
||||
},
|
||||
|
||||
handleChange(event) {
|
||||
|
@ -235,6 +235,21 @@ var ReactS3FineUploader = React.createClass({
|
||||
};
|
||||
},
|
||||
|
||||
// Resets the whole react fineuploader component to its initial state
|
||||
reset() {
|
||||
// Cancel all currently ongoing uploads
|
||||
this.state.uploader.cancelAll();
|
||||
|
||||
// and reset component in general
|
||||
this.state.uploader.reset();
|
||||
|
||||
// proclaim that upload is not ready
|
||||
this.props.setIsUploadReady(false);
|
||||
|
||||
// reset internal data structures of component
|
||||
this.setState(this.getInitialState());
|
||||
},
|
||||
|
||||
requestKey(fileId) {
|
||||
let filename = this.state.uploader.getName(fileId);
|
||||
let uuid = this.state.uploader.getUuid(fileId);
|
||||
@ -439,7 +454,6 @@ var ReactS3FineUploader = React.createClass({
|
||||
},
|
||||
|
||||
onCancel(id) {
|
||||
|
||||
// when a upload is canceled, we need to update this components file array
|
||||
this.setStatusOfFile(id, 'canceled');
|
||||
|
||||
@ -461,7 +475,6 @@ var ReactS3FineUploader = React.createClass({
|
||||
},
|
||||
|
||||
onProgress(id, name, uploadedBytes, totalBytes) {
|
||||
|
||||
let newState = React.addons.update(this.state, {
|
||||
filesToUpload: { [id]: {
|
||||
progress: { $set: (uploadedBytes / totalBytes) * 100} }
|
||||
|
Loading…
Reference in New Issue
Block a user