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