From 209d141939e323312806fe0f381c03cf11998fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 14 Sep 2015 17:02:47 +0200 Subject: [PATCH] extend fileClassToUpload functionality and implement it in contract settings --- .../ascribe_forms/form_create_contract.js | 25 ++++++++++++---- .../ascribe_forms/input_fineuploader.js | 2 +- .../ascribe_settings/contract_settings.js | 29 ++++++++++++++----- .../file_drag_and_drop_dialog.js | 2 +- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/js/components/ascribe_forms/form_create_contract.js b/js/components/ascribe_forms/form_create_contract.js index 23916c67..c91e97f0 100644 --- a/js/components/ascribe_forms/form_create_contract.js +++ b/js/components/ascribe_forms/form_create_contract.js @@ -4,7 +4,6 @@ import React from 'react'; import Form from '../ascribe_forms/form'; import Property from '../ascribe_forms/property'; -import InputCheckbox from '../ascribe_forms/input_checkbox'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; @@ -21,6 +20,16 @@ import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uplo let CreateContractForm = React.createClass({ + propTypes: { + isPublic: React.PropTypes.bool, + + // A class of a file the user has to upload + // Needs to be defined both in singular as well as in plural + fileClassToUpload: React.PropTypes.shape({ + singular: React.PropTypes.string, + plural: React.PropTypes.string + }) + }, getInitialState() { return { @@ -58,7 +67,7 @@ let CreateContractForm = React.createClass({ handleSuccess={this.handleCreateSuccess}> + label="Contract file (*.pdf only)"> + fileClassToUpload={this.props.fileClassToUpload}/> + ); } diff --git a/js/components/ascribe_forms/input_fineuploader.js b/js/components/ascribe_forms/input_fineuploader.js index 4fa89ef8..82d6bf92 100644 --- a/js/components/ascribe_forms/input_fineuploader.js +++ b/js/components/ascribe_forms/input_fineuploader.js @@ -103,7 +103,7 @@ let InputFileUploader = React.createClass({ } }} onInactive={this.props.onLoggedOut} - enableLocalHashing={this.props.enableLocalHashing} + enableLocalHashing={this.props.enableLocalHashing} fileClassToUpload={this.props.fileClassToUpload}/> ); } diff --git a/js/components/ascribe_settings/contract_settings.js b/js/components/ascribe_settings/contract_settings.js index 06584a8d..ed07e33f 100644 --- a/js/components/ascribe_settings/contract_settings.js +++ b/js/components/ascribe_settings/contract_settings.js @@ -80,6 +80,18 @@ let ContractSettings = React.createClass({ render() { let publicContracts = this.getPublicContracts(); let privateContracts = this.getPrivateContracts(); + let createPublicContractForm = null; + + if(publicContracts.length === 0) { + createPublicContractForm = ( + + ); + } return ( + {createPublicContractForm} {publicContracts.map((contract, i) => { return ( - DOWNLOAD + PREVIEW