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() { getInitialState() {
return { return {
isUploadReady: false isUploadReady: false,
contractName: ''
}; };
}, },
@ -41,30 +42,25 @@ let CreateContractForm = React.createClass({
this.refs.form.reset(); this.refs.form.reset();
}, },
submitFileName(fileName) {
this.setState({
contractName: fileName
});
this.refs.form.submit();
},
render() { render() {
return ( return (
<Form <Form
ref='form' ref='form'
url={ApiUrls.ownership_contract_list} url={ApiUrls.ownership_contract_list}
handleSuccess={this.handleCreateSuccess} 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>
}>
<Property <Property
name="blob" name="blob"
label="Contract file"> label="Contract file (*.pdf)">
<InputFineUploader <InputFineUploader
submitFileName={this.submitFileName}
keyRoutine={{ keyRoutine={{
url: AppConstants.serverUrl + 's3/key/', url: AppConstants.serverUrl + 's3/key/',
fileClass: 'contract' fileClass: 'contract'
@ -74,7 +70,8 @@ let CreateContractForm = React.createClass({
}} }}
validation={{ validation={{
itemLimit: 100000, itemLimit: 100000,
sizeLimit: '50000000' sizeLimit: '50000000',
allowedExtensions: ['pdf']
}} }}
areAssetsDownloadable={true} areAssetsDownloadable={true}
areAssetsEditable={true} areAssetsEditable={true}
@ -84,21 +81,11 @@ let CreateContractForm = React.createClass({
</Property> </Property>
<Property <Property
name='name' name='name'
label={getLangText('Contract name')}> label={getLangText('Contract name')}
hidden={true}>
<input <input
type="text" type="text"
placeholder={getLangText('(e.g. Contract - Loan agreement #1)')} value={this.state.contractName}/>
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>
</Property> </Property>
</Form> </Form>
); );

View File

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

View File

@ -83,7 +83,8 @@ var ReactS3FineUploader = React.createClass({
}), }),
validation: React.PropTypes.shape({ validation: React.PropTypes.shape({
itemLimit: React.PropTypes.number, itemLimit: React.PropTypes.number,
sizeLimit: React.PropTypes.string sizeLimit: React.PropTypes.string,
allowedExtensions: React.PropTypes.arrayOf(React.PropTypes.string)
}), }),
messages: React.PropTypes.shape({ messages: React.PropTypes.shape({
unsupportedBrowser: React.PropTypes.string unsupportedBrowser: React.PropTypes.string
@ -433,7 +434,7 @@ var ReactS3FineUploader = React.createClass({
}); });
this.state.uploader.cancelAll(); 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); GlobalNotificationActions.appendGlobalNotification(notification);
}, },