mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Generalize InputFineuploader's submitFileName method to submitFile
This commit is contained in:
parent
14621b5b38
commit
16840a6136
@ -51,9 +51,9 @@ let CreateContractForm = React.createClass({
|
|||||||
this.refs.form.reset();
|
this.refs.form.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
submitFileName(fileName) {
|
submitFile({ originalName }) {
|
||||||
this.setState({
|
this.setState({
|
||||||
contractName: fileName
|
contractName: originalName
|
||||||
});
|
});
|
||||||
|
|
||||||
this.refs.form.submit();
|
this.refs.form.submit();
|
||||||
@ -69,7 +69,7 @@ let CreateContractForm = React.createClass({
|
|||||||
name="blob"
|
name="blob"
|
||||||
label={getLangText('Contract file (*.pdf only, max. 50MB per contract)')}>
|
label={getLangText('Contract file (*.pdf only, max. 50MB per contract)')}>
|
||||||
<InputFineUploader
|
<InputFineUploader
|
||||||
submitFileName={this.submitFileName}
|
submitFile={this.submitFile}
|
||||||
keyRoutine={{
|
keyRoutine={{
|
||||||
url: AppConstants.serverUrl + 's3/key/',
|
url: AppConstants.serverUrl + 's3/key/',
|
||||||
fileClass: 'contract'
|
fileClass: 'contract'
|
||||||
|
@ -94,7 +94,8 @@ let RegisterPieceForm = React.createClass({
|
|||||||
children,
|
children,
|
||||||
enableLocalHashing } = this.props;
|
enableLocalHashing } = this.props;
|
||||||
const { currentUser,
|
const { currentUser,
|
||||||
isUploadReady } = this.state;
|
digitalWorkKeyReady,
|
||||||
|
thumbnailKeyReady } = this.state;
|
||||||
|
|
||||||
const profileHashLocally = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
|
const profileHashLocally = currentUser && currentUser.profile ? currentUser.profile.hash_locally : false;
|
||||||
const hashLocally = profileHashLocally && enableLocalHashing;
|
const hashLocally = profileHashLocally && enableLocalHashing;
|
||||||
@ -110,7 +111,7 @@ let RegisterPieceForm = React.createClass({
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-default btn-wide"
|
className="btn btn-default btn-wide"
|
||||||
disabled={!isUploadReady || disabled}>
|
disabled={!(digitalWorkKeyReady && thumbnailKeyReady)}>
|
||||||
{submitMessage}
|
{submitMessage}
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@ import AppConstants from '../../constants/application_constants';
|
|||||||
import { getCookie } from '../../utils/fetch_api_utils';
|
import { getCookie } from '../../utils/fetch_api_utils';
|
||||||
|
|
||||||
|
|
||||||
const { func, bool, object, shape, string, number, arrayOf } = React.PropTypes;
|
const { func, bool, shape, string, number, arrayOf } = React.PropTypes;
|
||||||
|
|
||||||
const InputFineUploader = React.createClass({
|
const InputFineUploader = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
setIsUploadReady: func,
|
setIsUploadReady: func,
|
||||||
isReadyForFormSubmission: func,
|
isReadyForFormSubmission: func,
|
||||||
submitFileName: func,
|
submitFile: func,
|
||||||
fileInputElement: func,
|
fileInputElement: func,
|
||||||
|
|
||||||
areAssetsDownloadable: bool,
|
areAssetsDownloadable: bool,
|
||||||
@ -77,8 +77,8 @@ const InputFineUploader = React.createClass({
|
|||||||
this.props.onChange({ target: { value: this.state.value } });
|
this.props.onChange({ target: { value: this.state.value } });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof this.props.submitFileName === 'function') {
|
if(typeof this.props.submitFile === 'function') {
|
||||||
this.props.submitFileName(file.originalName);
|
this.props.submitFile(file);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ const InputFineUploader = React.createClass({
|
|||||||
onLoggedOut,
|
onLoggedOut,
|
||||||
enableLocalHashing,
|
enableLocalHashing,
|
||||||
fileClassToUpload,
|
fileClassToUpload,
|
||||||
location } = this.props;
|
uploadMethod } = this.props;
|
||||||
let editable = this.props.isFineUploaderActive;
|
let editable = this.props.isFineUploaderActive;
|
||||||
|
|
||||||
// if disabled is actually set by property, we want to override
|
// if disabled is actually set by property, we want to override
|
||||||
@ -139,10 +139,10 @@ const InputFineUploader = React.createClass({
|
|||||||
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
'X-CSRFToken': getCookie(AppConstants.csrftoken)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onInactive={this.props.onLoggedOut}
|
onInactive={onLoggedOut}
|
||||||
enableLocalHashing={this.props.enableLocalHashing}
|
enableLocalHashing={enableLocalHashing}
|
||||||
uploadMethod={this.props.uploadMethod}
|
uploadMethod={uploadMethod}
|
||||||
fileClassToUpload={this.props.fileClassToUpload} />
|
fileClassToUpload={fileClassToUpload} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user