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

make contract creation implicit

This commit is contained in:
Tim Daubenschütz 2015-09-14 16:15:01 +02:00
parent 73c2a7c544
commit 6c713714ec
3 changed files with 28 additions and 33 deletions

View File

@ -24,7 +24,8 @@ let CreateContractForm = React.createClass({
getInitialState() {
return {
isUploadReady: false
isUploadReady: false,
contractName: ''
};
},
@ -41,30 +42,25 @@ let CreateContractForm = React.createClass({
this.refs.form.reset();
},
submitFileName(fileName) {
this.setState({
contractName: fileName
});
this.refs.form.submit();
},
render() {
return (
<Form
ref='form'
url={ApiUrls.ownership_contract_list}
handleSuccess={this.handleCreateSuccess}
buttons={
<button
type="submit"
className="btn ascribe-btn ascribe-btn-login"
disabled={!this.state.isUploadReady}>
{getLangText('Create new contract')}
</button>
}
spinner={
<span className="btn ascribe-btn ascribe-btn-login ascribe-btn-login-spinner">
<img src="https://s3-us-west-2.amazonaws.com/ascribe0/media/thumbnails/ascribe_animated_medium.gif" />
</span>
}>
handleSuccess={this.handleCreateSuccess}>
<Property
name="blob"
label="Contract file">
label="Contract file (*.pdf)">
<InputFineUploader
submitFileName={this.submitFileName}
keyRoutine={{
url: AppConstants.serverUrl + 's3/key/',
fileClass: 'contract'
@ -74,7 +70,8 @@ let CreateContractForm = React.createClass({
}}
validation={{
itemLimit: 100000,
sizeLimit: '50000000'
sizeLimit: '50000000',
allowedExtensions: ['pdf']
}}
areAssetsDownloadable={true}
areAssetsEditable={true}
@ -84,21 +81,11 @@ let CreateContractForm = React.createClass({
</Property>
<Property
name='name'
label={getLangText('Contract name')}>
label={getLangText('Contract name')}
hidden={true}>
<input
type="text"
placeholder={getLangText('(e.g. Contract - Loan agreement #1)')}
required/>
</Property>
<Property
name="is_public"
className="ascribe-settings-property-collapsible-toggle"
style={{paddingBottom: 0}}>
<InputCheckbox>
<span>
{getLangText('Make contract public (this will replace the current public contract')}
</span>
</InputCheckbox>
value={this.state.contractName}/>
</Property>
</Form>
);

View File

@ -12,6 +12,8 @@ let InputFileUploader = React.createClass({
propTypes: {
setIsUploadReady: React.PropTypes.func,
isReadyForFormSubmission: React.PropTypes.func,
submitFileName: React.PropTypes.func,
onClick: React.PropTypes.func,
keyRoutine: React.PropTypes.shape({
url: React.PropTypes.string,
@ -22,7 +24,8 @@ let InputFileUploader = React.createClass({
}),
validation: React.PropTypes.shape({
itemLimit: React.PropTypes.number,
sizeLimit: React.PropTypes.string
sizeLimit: React.PropTypes.string,
allowedExtensions: React.PropTypes.arrayOf(React.PropTypes.string)
}),
// isFineUploaderActive is used to lock react fine uploader in case
@ -47,6 +50,10 @@ let InputFileUploader = React.createClass({
this.setState({
value: file.key
});
if(typeof this.props.submitFileName === 'function') {
this.props.submitFileName(file.originalName);
}
},
reset() {

View File

@ -83,7 +83,8 @@ var ReactS3FineUploader = React.createClass({
}),
validation: React.PropTypes.shape({
itemLimit: React.PropTypes.number,
sizeLimit: React.PropTypes.string
sizeLimit: React.PropTypes.string,
allowedExtensions: React.PropTypes.arrayOf(React.PropTypes.string)
}),
messages: React.PropTypes.shape({
unsupportedBrowser: React.PropTypes.string
@ -433,7 +434,7 @@ var ReactS3FineUploader = React.createClass({
});
this.state.uploader.cancelAll();
let notification = new GlobalNotificationModel(this.props.defaultErrorMessage, 'danger', 5000);
let notification = new GlobalNotificationModel(errorReason || this.props.defaultErrorMessage, 'danger', 5000);
GlobalNotificationActions.appendGlobalNotification(notification);
},