1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-23 17:56:28 +02:00

now committing the remove contract

This commit is contained in:
Cevo 2015-09-07 11:38:23 +02:00
parent ae21686f26
commit 501d7ac7c0
4 changed files with 38 additions and 8 deletions

View File

@ -38,6 +38,21 @@ class ContractListActions {
});
});
}
removeContract(contract){
return Q.Promise((resolve, reject) => {
OwnershipFetcher.deleteContract(contract)
.then((res) => {
console.log('Contract deleted');
resolve(res);
})
.catch( (err) => {
console.log('Error while deleting');
console.logGlobal(err);
reject(err);
});
});
}
}
export default alt.createActions(ContractListActions);

View File

@ -36,9 +36,18 @@ let ContractSettings = React.createClass({
ContractListActions.makeContractPublic(contract)
.then(( ) => ContractListActions.fetchContractList())
.catch((error)=>{console.log('Error ', error);
let notification = new GlobalNotificationModel('Service is unavailable', 'danger', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
});
let notification = new GlobalNotificationModel('Service is unavailable', 'danger', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
});
},
removeContract(contract){
console.log(contract);
ContractListActions.removeContract(contract)
.then(( ) => ContractListActions.fetchContractList())
.catch((error) => {console.log('Error', error);
let notification = new GlobalNotificationModel('Service is unavailable', 'danger', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);
});
},
getPublicContracts(){
return this.state.contractList.filter((contract) => contract.public);
@ -70,10 +79,11 @@ let ContractSettings = React.createClass({
(contract) => {
return (
<ActionPanel title = {contract.name}
content = {this.getblobEndName(contract)}
content = {contract.name}
buttons = {<span>
<button className="btn btn-default btn-sm margin-left-2px">UPDATE</button>
<button className="btn btn-default btn-sm margin-left-2px">REMOVE</button>
<button className="btn btn-default btn-sm margin-left-2px"
onClick={this.removeContract.bind(this, contract)}>REMOVE</button>
</span>}
/>);
}
@ -87,9 +97,10 @@ let ContractSettings = React.createClass({
(contract) => {
return (
<ActionPanel title = {contract.name}
content = {this.getblobEndName(contract)}
content = {contract.name}
buttons = {<span> <button className="btn btn-default btn-sm margin-left-2px">UPDATE</button>
<button className="btn btn-default btn-sm margin-left-2px" >REMOVE</button>
<button className="btn btn-default btn-sm margin-left-2px"
onClick={this.removeContract.bind(this, contract)}> REMOVE </button>
<button className="btn btn-default btn-sm margin-left-2px"
onClick={this.makeContractPublic.bind(this, contract)}>MAKE PUBLIC</button> </span>}
/>);

View File

@ -48,7 +48,7 @@ let ApiUrls = {
'ownership_unconsigns_deny': AppConstants.apiEndpoint + 'ownership/unconsigns/deny/',
'ownership_unconsigns_request': AppConstants.apiEndpoint + 'ownership/unconsigns/request/',
'ownership_contract': AppConstants.apiEndpoint + 'ownership/contracts/${contract_id}/',
"ownership_contract_list": AppConstants.apiEndpoint + 'ownership/contracts/',
'ownership_contract_list': AppConstants.apiEndpoint + 'ownership/contracts/',
'piece': AppConstants.apiEndpoint + 'pieces/${piece_id}/',
'piece_extradata': AppConstants.apiEndpoint + 'pieces/${piece_id}/extradata/',
'piece_first_edition_id': AppConstants.apiEndpoint + 'pieces/${piece_id}/edition_index/',

View File

@ -25,6 +25,10 @@ let OwnershipFetcher = {
makeContractPublic(contractObj){
return requests.put('ownership_contract', { body: contractObj, contract_id: contractObj.id });
},
deleteContract(contractObj){
return requests.delete('ownership_contract', {body: contractObj, contract_id: contractObj.id});
}
};