+
-
+
{this.props.buttons}
diff --git a/js/components/ascribe_settings/contract_settings.js b/js/components/ascribe_settings/contract_settings.js
index f38464f3..c48ca0d7 100644
--- a/js/components/ascribe_settings/contract_settings.js
+++ b/js/components/ascribe_settings/contract_settings.js
@@ -10,97 +10,141 @@ import ContractListActions from '../../actions/contract_list_actions';
import ActionPanel from '../ascribe_panel/action_panel';
-import { getLangText } from '../../utils/lang_utils';
import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions';
+import { getLangText } from '../../utils/lang_utils';
+
let ContractSettings = React.createClass({
propTypes: {
defaultExpanded: React.PropTypes.bool
},
+
getInitialState(){
return ContractListStore.getState();
},
+
componentDidMount() {
ContractListStore.listen(this.onChange);
ContractListActions.fetchContractList();
},
+
componentWillUnmount() {
ContractListStore.unlisten(this.onChange);
},
+
onChange(state) {
this.setState(state);
},
- makeContractPublic(contract){
- console.log(contract);
- ContractListActions.makeContractPublic(contract)
- .then(( ) => ContractListActions.fetchContractList())
- .catch((error)=>{console.log('Error ', error);
- let notification = new GlobalNotificationModel('Service is unavailable', 'danger', 10000);
- GlobalNotificationActions.appendGlobalNotification(notification);
-});
+
+ makeContractPublic(contract) {
+ return () => {
+ contract.public = true;
+ ContractListActions.changeContract(contract)
+ .then(() => ContractListActions.fetchContractList())
+ .catch((err) => {
+ let notification = new GlobalNotificationModel(err, 'danger', 10000);
+ GlobalNotificationActions.appendGlobalNotification(notification);
+ });
+ };
},
+
+ removeContract(contract) {
+ return () => {
+ ContractListActions.removeContract(contract.id)
+ .then(( ) => ContractListActions.fetchContractList())
+ .catch((err) => {
+ let notification = new GlobalNotificationModel(err, 'danger', 10000);
+ GlobalNotificationActions.appendGlobalNotification(notification);
+ });
+ };
+ },
+
getPublicContracts(){
return this.state.contractList.filter((contract) => contract.public);
},
+
getPrivateContracts(){
return this.state.contractList.filter((contract) => !contract.public);
},
- getblobEndName(contract){
- return contract.blob.match(/.*\/(.*)/)[1];
- },
+
render() {
let publicContracts = this.getPublicContracts();
let privateContracts = this.getPrivateContracts();
- console.log(this.state.contractList);
+
return (
- {/* this should be this.props.defaultExpanded */}
+ defaultExpanded={true}>
- {
-
Public Contracts
- {(publicContracts.length > 0) ?
- publicContracts.map(
- (contract) => {
+ defaultExpanded={true}>
+
+ {publicContracts.map((contract, i) => {
return (
-
-
-
- }
- />);
- }
- ) : null }
- }
-
- {
-
Private Contracts
- {(privateContracts.length > 0) ?
- privateContracts.map(
- (contract) => {
+
+
+
+
+ }
+ leftColumnWidth="40%"
+ rightColumnWidth="60%"/>
+ );
+ })}
+
+
+ {privateContracts.map((contract, i) => {
return (
-
-
- }
- />);
- }
- ) : null}
- }
+
+
+
+
+
+ }
+ leftColumnWidth="40%"
+ rightColumnWidth="60%"/>
+ );
+ })}
+
+ defaultExpanded={true}>
diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js
index fcf9be6f..b8d6713d 100644
--- a/js/constants/api_urls.js
+++ b/js/constants/api_urls.js
@@ -54,7 +54,7 @@ let ApiUrls = {
'ownership_unconsigns': AppConstants.apiEndpoint + 'ownership/unconsigns/',
'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': AppConstants.apiEndpoint + 'ownership/contracts/${contract_id}/',
'ownership_contract_list': AppConstants.apiEndpoint + 'ownership/contracts/',
'piece': AppConstants.apiEndpoint + 'pieces/${piece_id}/',
'piece_extradata': AppConstants.apiEndpoint + 'pieces/${piece_id}/extradata/',
diff --git a/js/fetchers/ownership_fetcher.js b/js/fetchers/ownership_fetcher.js
index ee71d1f0..e9ca4e50 100644
--- a/js/fetchers/ownership_fetcher.js
+++ b/js/fetchers/ownership_fetcher.js
@@ -25,6 +25,10 @@ let OwnershipFetcher = {
makeContractPublic(contractObj){
return requests.put('ownership_contract', { body: contractObj, contract_id: contractObj.id });
+ },
+
+ deleteContract(contractObjId){
+ return requests.delete(ApiUrls.ownership_contract, {contract_id: contractObjId});
}
};
diff --git a/js/utils/general_utils.js b/js/utils/general_utils.js
index 673a5509..7717a96a 100644
--- a/js/utils/general_utils.js
+++ b/js/utils/general_utils.js
@@ -52,19 +52,6 @@ export function sumNumList(l) {
return sum;
}
-export function excludePropFromObject(obj, propList){
- let clonedObj = mergeOptions({},obj);
- for (let item in propList){
- console.log(item);
- if (clonedObj[propList[item]]){
- console.log('deleting... ');
- delete clonedObj[propList[item]];
- }
- }
- console.log(clonedObj);
- return clonedObj;
-}
-
/*
Taken from http://stackoverflow.com/a/4795914/1263876
Behaves like C's format string function
@@ -207,4 +194,14 @@ function _mergeOptions(obj1, obj2) {
*/
export function escapeHTML(s) {
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
+}
+
+export function excludePropFromObject(obj, propList){
+ let clonedObj = mergeOptions({}, obj);
+ for (let item in propList){
+ if (clonedObj[propList[item]]){
+ delete clonedObj[propList[item]];
+ }
+ }
+ return clonedObj;
}
\ No newline at end of file
diff --git a/js/utils/requests.js b/js/utils/requests.js
index f9e1af04..720f184f 100644
--- a/js/utils/requests.js
+++ b/js/utils/requests.js
@@ -33,7 +33,7 @@ class Requests {
// If this is the case, we can not try to parse it as JSON.
if(responseText !== 'None') {
let body = JSON.parse(responseText);
-
+
if(body && body.errors) {
let error = new Error('Form Error');
error.json = body;
@@ -119,7 +119,9 @@ class Requests {
return fetch(url, merged)
.then(this.unpackResponse)
- .catch(this.handleError);
+ .catch( () => {
+ this.handleError();
+ });
}
get(url, params) {
@@ -134,28 +136,28 @@ class Requests {
delete(url, params) {
let paramsCopy = this._merge(params);
let newUrl = this.prepareUrl(url, paramsCopy, true);
+
return this.request('delete', newUrl);
}
_putOrPost(url, paramsAndBody, method){
let paramsCopy = this._merge(paramsAndBody);
- let params = excludePropFromObject(paramsAndBody,['body']);
+ let params = excludePropFromObject(paramsAndBody, ['body']);
let newUrl = this.prepareUrl(url, params);
let body = null;
if (paramsCopy && paramsCopy.body) {
- console.log(paramsCopy.body);
body = JSON.stringify(paramsCopy.body);
}
return this.request(method, newUrl, { body });
}
post(url, params) {
- return this._putOrPost(url,params,'post')
+ return this._putOrPost(url, params, 'post');
}
put(url, params){
- return this._putOrPost(url,params,'put')
+ return this._putOrPost(url, params, 'put');
}
defaults(options) {
diff --git a/sass/ascribe_collapsible.scss b/sass/ascribe_collapsible.scss
index f6c9a623..2b65567c 100644
--- a/sass/ascribe_collapsible.scss
+++ b/sass/ascribe_collapsible.scss
@@ -26,8 +26,8 @@
width: 100%;
/* Shrink the size of the headline for a nested element */
- .ascribe-collapsible-wrapper > div:first-child {
+ .ascribe-collapsible-wrapper > .ascribe-collapsible-content {
padding-left: 1em;
- font-size: 90%;
+ font-size: 95%;
}
}
\ No newline at end of file