1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-28 08:37:59 +02:00

Small cleanups and fixes for spacing, unused props, etc

This commit is contained in:
Brett Sun 2015-12-21 11:44:13 +01:00
parent 418022dff5
commit 5a497bae59
4 changed files with 61 additions and 73 deletions

View File

@ -28,12 +28,10 @@ class ContractListActions {
} }
changeContract(contract){ changeContract(contract) {
return Q.Promise((resolve, reject) => { return Q.Promise((resolve, reject) => {
OwnershipFetcher.changeContract(contract) OwnershipFetcher.changeContract(contract)
.then((res) => { .then(resolve)
resolve(res);
})
.catch((err)=> { .catch((err)=> {
console.logGlobal(err); console.logGlobal(err);
reject(err); reject(err);
@ -41,13 +39,11 @@ class ContractListActions {
}); });
} }
removeContract(contractId){ removeContract(contractId) {
return Q.Promise( (resolve, reject) => { return Q.Promise((resolve, reject) => {
OwnershipFetcher.deleteContract(contractId) OwnershipFetcher.deleteContract(contractId)
.then((res) => { .then(resolve)
resolve(res); .catch((err) => {
})
.catch( (err) => {
console.logGlobal(err); console.logGlobal(err);
reject(err); reject(err);
}); });

View File

@ -28,11 +28,7 @@ import { mergeOptions, truncateTextAtCharIndex } from '../../utils/general_utils
let ContractSettings = React.createClass({ let ContractSettings = React.createClass({
propTypes: { getInitialState() {
location: React.PropTypes.object
},
getInitialState(){
return mergeOptions( return mergeOptions(
ContractListStore.getState(), ContractListStore.getState(),
UserStore.getState() UserStore.getState()
@ -64,40 +60,39 @@ let ContractSettings = React.createClass({
ContractListActions.removeContract(contract.id) ContractListActions.removeContract(contract.id)
.then((response) => { .then((response) => {
ContractListActions.fetchContractList(true); ContractListActions.fetchContractList(true);
let notification = new GlobalNotificationModel(response.notification, 'success', 4000); const notification = new GlobalNotificationModel(response.notification, 'success', 4000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
}) })
.catch((err) => { .catch((err) => {
let notification = new GlobalNotificationModel(err, 'danger', 10000); const notification = new GlobalNotificationModel(err, 'danger', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
}); });
}; };
}, },
getPublicContracts(){ getPublicContracts() {
return this.state.contractList.filter((contract) => contract.is_public); return this.state.contractList.filter((contract) => contract.is_public);
}, },
getPrivateContracts(){ getPrivateContracts() {
return this.state.contractList.filter((contract) => !contract.is_public); return this.state.contractList.filter((contract) => !contract.is_public);
}, },
render() { render() {
let publicContracts = this.getPublicContracts(); const publicContracts = this.getPublicContracts();
let privateContracts = this.getPrivateContracts(); const privateContracts = this.getPrivateContracts();
let createPublicContractForm = null; let createPublicContractForm = null;
setDocumentTitle(getLangText('Contracts settings')); setDocumentTitle(getLangText('Contracts settings'));
if(publicContracts.length === 0) { if (publicContracts.length === 0) {
createPublicContractForm = ( createPublicContractForm = (
<CreateContractForm <CreateContractForm
isPublic={true} isPublic={true}
fileClassToUpload={{ fileClassToUpload={{
singular: 'new contract', singular: 'new contract',
plural: 'new contracts' plural: 'new contracts'
}} }} />
location={this.props.location}/>
); );
} }
@ -114,7 +109,7 @@ let ContractSettings = React.createClass({
{publicContracts.map((contract, i) => { {publicContracts.map((contract, i) => {
return ( return (
<ActionPanel <ActionPanel
key={i} key={contract.id}
title={contract.name} title={contract.name}
content={truncateTextAtCharIndex(contract.name, 120, '(...).pdf')} content={truncateTextAtCharIndex(contract.name, 120, '(...).pdf')}
buttons={ buttons={
@ -123,8 +118,7 @@ let ContractSettings = React.createClass({
aclObject={this.state.whitelabel} aclObject={this.state.whitelabel}
aclName="acl_update_public_contract"> aclName="acl_update_public_contract">
<ContractSettingsUpdateButton <ContractSettingsUpdateButton
contract={contract} contract={contract} />
location={this.props.location}/>
</AclProxy> </AclProxy>
<a <a
className="btn btn-default btn-sm margin-left-2px" className="btn btn-default btn-sm margin-left-2px"
@ -154,12 +148,11 @@ let ContractSettings = React.createClass({
fileClassToUpload={{ fileClassToUpload={{
singular: getLangText('new contract'), singular: getLangText('new contract'),
plural: getLangText('new contracts') plural: getLangText('new contracts')
}} }} />
location={this.props.location}/>
{privateContracts.map((contract, i) => { {privateContracts.map((contract, i) => {
return ( return (
<ActionPanel <ActionPanel
key={i} key={contract.id}
title={contract.name} title={contract.name}
content={truncateTextAtCharIndex(contract.name, 120, '(...).pdf')} content={truncateTextAtCharIndex(contract.name, 120, '(...).pdf')}
buttons={ buttons={
@ -168,8 +161,7 @@ let ContractSettings = React.createClass({
aclObject={this.state.whitelabel} aclObject={this.state.whitelabel}
aclName="acl_update_private_contract"> aclName="acl_update_private_contract">
<ContractSettingsUpdateButton <ContractSettingsUpdateButton
contract={contract} contract={contract} />
location={this.props.location}/>
</AclProxy> </AclProxy>
<a <a
className="btn btn-default btn-sm margin-left-2px" className="btn btn-default btn-sm margin-left-2px"

View File

@ -55,40 +55,40 @@ let ContractSettingsUpdateButton = React.createClass({
render() { render() {
return ( return (
<ReactS3FineUploader <ReactS3FineUploader
fileInputElement={UploadButton()} fileInputElement={UploadButton({ showLabel: false })}
keyRoutine={{ keyRoutine={{
url: AppConstants.serverUrl + 's3/key/', url: AppConstants.serverUrl + 's3/key/',
fileClass: 'contract' fileClass: 'contract'
}} }}
createBlobRoutine={{ createBlobRoutine={{
url: ApiUrls.blob_contracts url: ApiUrls.blob_contracts
}} }}
validation={{ validation={{
itemLimit: AppConstants.fineUploader.validation.registerWork.itemLimit, itemLimit: AppConstants.fineUploader.validation.registerWork.itemLimit,
sizeLimit: AppConstants.fineUploader.validation.additionalData.sizeLimit, sizeLimit: AppConstants.fineUploader.validation.additionalData.sizeLimit,
allowedExtensions: ['pdf'] allowedExtensions: ['pdf']
}} }}
setIsUploadReady={() =>{/* So that ReactS3FineUploader is not complaining */}} setIsUploadReady={() =>{/* So that ReactS3FineUploader is not complaining */}}
signature={{ signature={{
endpoint: AppConstants.serverUrl + 's3/signature/', endpoint: AppConstants.serverUrl + 's3/signature/',
customHeaders: { customHeaders: {
'X-CSRFToken': getCookie(AppConstants.csrftoken) 'X-CSRFToken': getCookie(AppConstants.csrftoken)
} }
}} }}
deleteFile={{ deleteFile={{
enabled: true, enabled: true,
method: 'DELETE', method: 'DELETE',
endpoint: AppConstants.serverUrl + 's3/delete', endpoint: AppConstants.serverUrl + 's3/delete',
customHeaders: { customHeaders: {
'X-CSRFToken': getCookie(AppConstants.csrftoken) 'X-CSRFToken': getCookie(AppConstants.csrftoken)
} }
}} }}
fileClassToUpload={{ fileClassToUpload={{
singular: getLangText('UPDATE'), singular: getLangText('UPDATE'),
plural: getLangText('UPDATE') plural: getLangText('UPDATE')
}} }}
isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile} isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile}
submitFile={this.submitFile} /> submitFile={this.submitFile} />
); );
} }
}); });

View File

@ -15,7 +15,7 @@ let OwnershipFetcher = {
/** /**
* Fetch the contracts of the logged-in user from the API. * Fetch the contracts of the logged-in user from the API.
*/ */
fetchContractList(isActive, isPublic, issuer){ fetchContractList(isActive, isPublic, issuer) {
let queryParams = { let queryParams = {
isActive, isActive,
isPublic, isPublic,
@ -28,7 +28,7 @@ let OwnershipFetcher = {
/** /**
* Create a contractagreement between the logged-in user and the email from the API with contract. * Create a contractagreement between the logged-in user and the email from the API with contract.
*/ */
createContractAgreement(signee, contractObj){ createContractAgreement(signee, contractObj) {
return requests.post(ApiUrls.ownership_contract_agreements, { body: {signee: signee, contract: contractObj.id }}); return requests.post(ApiUrls.ownership_contract_agreements, { body: {signee: signee, contract: contractObj.id }});
}, },
@ -44,23 +44,23 @@ let OwnershipFetcher = {
return requests.get(ApiUrls.ownership_contract_agreements, queryParams); return requests.get(ApiUrls.ownership_contract_agreements, queryParams);
}, },
confirmContractAgreement(contractAgreement){ confirmContractAgreement(contractAgreement) {
return requests.put(ApiUrls.ownership_contract_agreements_confirm, {contract_agreement_id: contractAgreement.id}); return requests.put(ApiUrls.ownership_contract_agreements_confirm, {contract_agreement_id: contractAgreement.id});
}, },
denyContractAgreement(contractAgreement){ denyContractAgreement(contractAgreement) {
return requests.put(ApiUrls.ownership_contract_agreements_deny, {contract_agreement_id: contractAgreement.id}); return requests.put(ApiUrls.ownership_contract_agreements_deny, {contract_agreement_id: contractAgreement.id});
}, },
fetchLoanPieceRequestList(){ fetchLoanPieceRequestList() {
return requests.get(ApiUrls.ownership_loans_pieces_request); return requests.get(ApiUrls.ownership_loans_pieces_request);
}, },
changeContract(contractObj){ changeContract(contractObj) {
return requests.put(ApiUrls.ownership_contract, { body: contractObj, contract_id: contractObj.id }); return requests.put(ApiUrls.ownership_contract, { body: contractObj, contract_id: contractObj.id });
}, },
deleteContract(contractObjId){ deleteContract(contractObjId) {
return requests.delete(ApiUrls.ownership_contract, {contract_id: contractObjId}); return requests.delete(ApiUrls.ownership_contract, {contract_id: contractObjId});
} }
}; };