mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
create refresh added, conflicts resolved
This commit is contained in:
commit
5b0cbc92ad
@ -23,7 +23,8 @@ class ContractListActions {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
makeContractPublic(contract){
|
|
||||||
|
changeContract(contract){
|
||||||
return Q.Promise((resolve, reject) => {
|
return Q.Promise((resolve, reject) => {
|
||||||
OwnershipFetcher.makeContractPublic(contract)
|
OwnershipFetcher.makeContractPublic(contract)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -40,11 +41,9 @@ class ContractListActions {
|
|||||||
return Q.Promise( (resolve, reject) => {
|
return Q.Promise( (resolve, reject) => {
|
||||||
OwnershipFetcher.deleteContract(contractId)
|
OwnershipFetcher.deleteContract(contractId)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log('Success...');
|
|
||||||
resolve(res);
|
resolve(res);
|
||||||
})
|
})
|
||||||
.catch( (err) => {
|
.catch( (err) => {
|
||||||
console.log('Bad news...');
|
|
||||||
console.logGlobal(err);
|
console.logGlobal(err);
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
|
@ -8,7 +8,9 @@ import InputCheckbox from '../ascribe_forms/input_checkbox';
|
|||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
import ContractListActions from '../../actions/contract_list_actions';
|
import ContractListActions from '../../actions/contract_list_actions';
|
||||||
|
|
||||||
import ReactS3FineUploader from '../ascribe_uploader/react_s3_fine_uploader';
|
import ReactS3FineUploader from '../ascribe_uploader/react_s3_fine_uploader';
|
||||||
|
|
||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
@ -51,6 +53,9 @@ let CreateContractForm = React.createClass({
|
|||||||
ContractListActions.fetchContractList();
|
ContractListActions.fetchContractList();
|
||||||
let notification = new GlobalNotificationModel(getLangText('Contract %s successfully created', response.name), 'success', 5000);
|
let notification = new GlobalNotificationModel(getLangText('Contract %s successfully created', response.name), 'success', 5000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
|
||||||
|
// also refresh contract lists for the rest of the contract settings page
|
||||||
|
ContractListActions.fetchContractList();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +117,7 @@ let CreateContractForm = React.createClass({
|
|||||||
label={getLangText('Contract name')}>
|
label={getLangText('Contract name')}>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="(e.g. Loan agreement #1)"
|
placeholder="(e.g. Contract - Loan agreement #1)"
|
||||||
required/>
|
required/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property
|
<Property
|
||||||
@ -121,10 +126,7 @@ let CreateContractForm = React.createClass({
|
|||||||
style={{paddingBottom: 0}}>
|
style={{paddingBottom: 0}}>
|
||||||
<InputCheckbox>
|
<InputCheckbox>
|
||||||
<span>
|
<span>
|
||||||
{' ' + getLangText('I agree to the Terms of Service') + ' '}
|
Make contract public (this will replace the current public contract)
|
||||||
(<a href="https://www.ascribe.io/terms" target="_blank" style={{fontSize: '0.9em', color: 'rgba(0,0,0,0.7)'}}>
|
|
||||||
{getLangText('read')}
|
|
||||||
</a>)
|
|
||||||
</span>
|
</span>
|
||||||
</InputCheckbox>
|
</InputCheckbox>
|
||||||
</Property>
|
</Property>
|
||||||
|
@ -12,8 +12,12 @@ let ActionPanel = React.createClass({
|
|||||||
]),
|
]),
|
||||||
buttons: React.PropTypes.element,
|
buttons: React.PropTypes.element,
|
||||||
onClick: React.PropTypes.func,
|
onClick: React.PropTypes.func,
|
||||||
ignoreFocus: React.PropTypes.bool
|
ignoreFocus: React.PropTypes.bool,
|
||||||
|
|
||||||
|
leftColumnWidth: React.PropTypes.string,
|
||||||
|
rightColumnWidth: React.PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
isFocused: false
|
isFocused: false
|
||||||
@ -40,14 +44,21 @@ let ActionPanel = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
|
let { leftColumnWidth, rightColumnWidth } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classnames('ascribe-panel-wrapper', {'is-focused': this.state.isFocused})}>
|
<div className={classnames('ascribe-panel-wrapper', {'is-focused': this.state.isFocused})}>
|
||||||
<div className="ascribe-panel-table">
|
<div
|
||||||
|
className="ascribe-panel-table"
|
||||||
|
style={{width: leftColumnWidth}}>
|
||||||
<div className="ascribe-panel-content">
|
<div className="ascribe-panel-content">
|
||||||
{this.props.content}
|
{this.props.content}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="ascribe-panel-table">
|
<div
|
||||||
|
className="ascribe-panel-table"
|
||||||
|
style={{width: rightColumnWidth}}>
|
||||||
<div className="ascribe-panel-content">
|
<div className="ascribe-panel-content">
|
||||||
{this.props.buttons}
|
{this.props.buttons}
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,122 +10,141 @@ import ContractListActions from '../../actions/contract_list_actions';
|
|||||||
|
|
||||||
import ActionPanel from '../ascribe_panel/action_panel';
|
import ActionPanel from '../ascribe_panel/action_panel';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
let ContractSettings = React.createClass({
|
let ContractSettings = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
defaultExpanded: React.PropTypes.bool
|
defaultExpanded: React.PropTypes.bool
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState(){
|
getInitialState(){
|
||||||
return ContractListStore.getState();
|
return ContractListStore.getState();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
ContractListStore.listen(this.onChange);
|
ContractListStore.listen(this.onChange);
|
||||||
ContractListActions.fetchContractList();
|
ContractListActions.fetchContractList();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
ContractListStore.unlisten(this.onChange);
|
ContractListStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
makeContractPublic(contract){
|
|
||||||
ContractListActions.makeContractPublic(contract)
|
makeContractPublic(contract) {
|
||||||
.then( ( ) => ContractListActions.fetchContractList())
|
return () => {
|
||||||
.catch((error)=>{
|
contract.public = true;
|
||||||
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
ContractListActions.changeContract(contract)
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
.then(() => ContractListActions.fetchContractList())
|
||||||
});
|
.catch((err) => {
|
||||||
|
let notification = new GlobalNotificationModel(err, 'danger', 10000);
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
});
|
||||||
|
};
|
||||||
},
|
},
|
||||||
removeContract(contract){
|
|
||||||
console.log(contract);
|
removeContract(contract) {
|
||||||
ContractListActions.removeContract(contract.id)
|
return () => {
|
||||||
.then(
|
ContractListActions.removeContract(contract.id)
|
||||||
() => {
|
.then(( ) => ContractListActions.fetchContractList())
|
||||||
ContractListActions.fetchContractList();
|
.catch((err) => {
|
||||||
})
|
let notification = new GlobalNotificationModel(err, 'danger', 10000);
|
||||||
.catch((error) => {
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
let notification = new GlobalNotificationModel(error, 'danger', 10000);
|
});
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
};
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getPublicContracts(){
|
getPublicContracts(){
|
||||||
return this.state.contractList.filter((contract) => contract.public);
|
return this.state.contractList.filter((contract) => contract.public);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPrivateContracts(){
|
getPrivateContracts(){
|
||||||
return this.state.contractList.filter((contract) => !contract.public);
|
return this.state.contractList.filter((contract) => !contract.public);
|
||||||
},
|
},
|
||||||
getblobEndName(contract){
|
|
||||||
return contract.blob.match(/.*\/(.*)/)[1];
|
|
||||||
},
|
|
||||||
render() {
|
render() {
|
||||||
let publicContracts = this.getPublicContracts();
|
let publicContracts = this.getPublicContracts();
|
||||||
let privateContracts = this.getPrivateContracts();
|
let privateContracts = this.getPrivateContracts();
|
||||||
console.log(this.state.contractList);
|
|
||||||
return (
|
return (
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('Contract Settings')}
|
title={getLangText('Contract Settings')}
|
||||||
show={true}
|
show={true}
|
||||||
defaultExpanded={false}>
|
defaultExpanded={true}>
|
||||||
{/* this should be this.props.defaultExpanded */}
|
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('List Contracts')}
|
title={getLangText('List Contracts')}
|
||||||
show={true}
|
show={true}
|
||||||
defaultExpanded={false}>
|
defaultExpanded={true}>
|
||||||
{<div>
|
<CollapsibleParagraph
|
||||||
<p>Public Contracts</p>
|
title={getLangText('Public Contracts')}
|
||||||
{(publicContracts.length > 0) ?
|
show={true}
|
||||||
publicContracts.map(
|
defaultExpanded={true}>
|
||||||
(contract) => {
|
{publicContracts.map((contract, i) => {
|
||||||
return (
|
return (
|
||||||
<ActionPanel title = {contract.name}
|
<ActionPanel
|
||||||
content = {contract.name}
|
key={i}
|
||||||
buttons = {<span>
|
title={contract.name}
|
||||||
<button className="btn btn-default btn-sm margin-left-2px">
|
content={contract.name}
|
||||||
UPDATE
|
buttons={
|
||||||
</button>
|
<div className="pull-right">
|
||||||
<button className="btn btn-default btn-sm margin-left-2px"
|
<button className="btn btn-default btn-sm margin-left-2px">
|
||||||
onClick={this.removeContract.bind(this, contract)}>
|
UPDATE
|
||||||
REMOVE
|
</button>
|
||||||
</button>
|
<button
|
||||||
</span>}
|
className="btn btn-default btn-sm margin-left-2px"
|
||||||
/>);
|
onClick={this.removeContract(contract)}>
|
||||||
}
|
REMOVE
|
||||||
) : null }
|
</button>
|
||||||
</div>}
|
</div>
|
||||||
|
}
|
||||||
{<div>
|
leftColumnWidth="40%"
|
||||||
<p>Private Contracts</p>
|
rightColumnWidth="60%"/>
|
||||||
{(privateContracts.length > 0) ?
|
);
|
||||||
privateContracts.map(
|
})}
|
||||||
(contract) => {
|
</CollapsibleParagraph>
|
||||||
|
<CollapsibleParagraph
|
||||||
|
title={getLangText('Private Contracts')}
|
||||||
|
show={true}
|
||||||
|
defaultExpanded={true}>
|
||||||
|
{privateContracts.map((contract, i) => {
|
||||||
return (
|
return (
|
||||||
<ActionPanel title = {contract.name}
|
<ActionPanel
|
||||||
content = {contract.name}
|
key={i}
|
||||||
buttons = {<span>
|
title={contract.name}
|
||||||
<button className="btn btn-default btn-sm margin-left-2px">
|
content={contract.name}
|
||||||
UPDATE
|
buttons={
|
||||||
</button>
|
<div className="pull-right">
|
||||||
<button className="btn btn-default btn-sm margin-left-2px"
|
<button className="btn btn-default btn-sm margin-left-2px">
|
||||||
onClick={this.removeContract.bind(this, contract)}>
|
UPDATE
|
||||||
REMOVE
|
</button>
|
||||||
</button>
|
<button
|
||||||
<button className="btn btn-default btn-sm margin-left-2px"
|
className="btn btn-default btn-sm margin-left-2px"
|
||||||
onClick={this.makeContractPublic.bind(this, contract)}>
|
onClick={this.removeContract(contract)}>
|
||||||
MAKE PUBLIC
|
REMOVE
|
||||||
</button>
|
</button>
|
||||||
</span>}
|
<button
|
||||||
/>);
|
className="btn btn-default btn-sm margin-left-2px"
|
||||||
}
|
onClick={this.makeContractPublic(contract)}>
|
||||||
) : null}
|
MAKE PUBLIC
|
||||||
</div>}
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
leftColumnWidth="40%"
|
||||||
|
rightColumnWidth="60%"/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CollapsibleParagraph>
|
||||||
</CollapsibleParagraph>
|
</CollapsibleParagraph>
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('Create Contract')}
|
title={getLangText('Create Contract')}
|
||||||
show={true}
|
show={true}
|
||||||
defaultExpanded={false}>
|
defaultExpanded={true}>
|
||||||
<CreateContractForm />
|
<CreateContractForm />
|
||||||
</CollapsibleParagraph>
|
</CollapsibleParagraph>
|
||||||
</CollapsibleParagraph>
|
</CollapsibleParagraph>
|
||||||
|
@ -52,19 +52,6 @@ export function sumNumList(l) {
|
|||||||
return sum;
|
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
|
Taken from http://stackoverflow.com/a/4795914/1263876
|
||||||
Behaves like C's format string function
|
Behaves like C's format string function
|
||||||
@ -208,3 +195,13 @@ function _mergeOptions(obj1, obj2) {
|
|||||||
export function escapeHTML(s) {
|
export function escapeHTML(s) {
|
||||||
return document.createElement('div').appendChild(document.createTextNode(s)).parentNode.innerHTML;
|
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;
|
||||||
|
}
|
@ -136,6 +136,7 @@ class Requests {
|
|||||||
delete(url, params) {
|
delete(url, params) {
|
||||||
let paramsCopy = this._merge(params);
|
let paramsCopy = this._merge(params);
|
||||||
let newUrl = this.prepareUrl(url, paramsCopy, true);
|
let newUrl = this.prepareUrl(url, paramsCopy, true);
|
||||||
|
|
||||||
return this.request('delete', newUrl);
|
return this.request('delete', newUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
/* Shrink the size of the headline for a nested element */
|
/* 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;
|
padding-left: 1em;
|
||||||
font-size: 90%;
|
font-size: 95%;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user