Skip to content

Commit

Permalink
Merge pull request #73 from AugurProject/#29-user-open-orders
Browse files Browse the repository at this point in the history
User open orders
  • Loading branch information
thinkloop committed Aug 1, 2016
2 parents 49b1510 + bbe98fd commit f79d02c
Show file tree
Hide file tree
Showing 22 changed files with 213 additions and 100 deletions.
40 changes: 20 additions & 20 deletions build/components.jsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default function (appElement, selectors) {
<MarketPage
siteHeader={p.siteHeader}
selectedOutcome={p.selectedOutcome}
cancelOrder={p.cancelOrder}
orderCancellation={p.orderCancellation}
market={p.market}
numPendingReports={p.marketsTotals.numPendingReports}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import transactions from '../test/assertions/transactions';
import transactionsTotals from '../test/assertions/transactions-totals';
import url from '../test/assertions/url';
import selectedUserOpenOrdersGroup from '../test/assertions/selected-user-open-orders-group';
import cancelOrder from '../test/assertions/cancel-order';
import orderCancellation from '../test/assertions/order-cancellation';

export default {
activePage,
Expand All @@ -47,5 +47,5 @@ export default {
transactionsTotals,
url,
selectedUserOpenOrdersGroup,
cancelOrder
orderCancellation
};
6 changes: 3 additions & 3 deletions src/modules/common/less/buttons.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.button, .button:visited, {
.button, .button:visited {
display: inline-block;
height: 2.8em;
line-height: 2.8em;
Expand Down Expand Up @@ -101,7 +101,7 @@
color: #aaaabb;
background: transparent;
}
&:hover, {
&:hover {
color: #ffda00;
background: transparent;
text-shadow: 0 0 1px #dddd00;
Expand Down Expand Up @@ -192,4 +192,4 @@
color: white;
background: @color-dark-normal;
}
}
}
4 changes: 2 additions & 2 deletions src/modules/market/components/market-open-orders.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const OpenOrders = (p) => (
id={outcome.id}
name={outcome.name}
userOpenOrders={outcome.userOpenOrders}
cancelOrder={p.cancelOrder}
orderCancellation={p.orderCancellation}
/>
))
}
Expand All @@ -28,7 +28,7 @@ const OpenOrders = (p) => (
OpenOrders.propTypes = {
userOpenOrdersSummary: React.PropTypes.object,
outcomes: React.PropTypes.array,
cancelOrder: React.PropTypes.func.isRequired
orderCancellation: React.PropTypes.object.isRequired
};

export default OpenOrders;
5 changes: 3 additions & 2 deletions src/modules/market/components/market-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class MarketPage extends Component {
selectedOutcome: PropTypes.object,
priceTimeSeries: PropTypes.array,
numPendingReports: PropTypes.number,
cancelOrder: PropTypes.func.isRequired
orderCancellation: PropTypes.object.isRequired
};
constructor(props) {
super(props);
Expand Down Expand Up @@ -57,6 +57,7 @@ export default class MarketPage extends Component {
outcomes={p.market.outcomes}
selectedOutcome={p.selectedOutcome}
tradeSummary={p.market.tradeSummary}
userOpenOrdersSummary={p.market.userOpenOrdersSummary}
onSubmitPlaceTrade={p.market.onSubmitPlaceTrade}
/>
);
Expand All @@ -68,7 +69,7 @@ export default class MarketPage extends Component {
key="market-open-orders"
userOpenOrdersSummary={p.market.userOpenOrdersSummary}
outcomes={p.market.outcomes}
cancelOrder={p.cancelOrder}
orderCancellation={p.orderCancellation}
/>
);
}
Expand Down
61 changes: 51 additions & 10 deletions src/modules/open-orders/components/open-order.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import classnames from 'classnames';
import ValueDenomination from '../../common/components/value-denomination';

const OpenOrder = (p) => (
<tr className={classnames('open-order', { 'is-disabled': p.isCancelling || p.isCancelled })}>
<tr className={classnames('open-order', { 'is-disabled': [p.cancellationStatuses.CANCELLING, p.cancellationStatuses.CANCELLED].includes(p.status) })}>
<td className="outcome-name">
{p.outcomeName}
</td>
Expand All @@ -22,13 +22,9 @@ const OpenOrder = (p) => (
<ValueDenomination {...p.avgPrice} />
</td>
<td className="cancel">
<button
className="button cancel-order-action"
disabled={p.isCancelling || p.isCancelled}
title="Cancel order"
onClick={(event) => { p.cancelOrder(p.id, p.marketID, p.type); }}
>Cancel</button>

{
renderCancelNode(p.id, p.marketID, p.type, p.status, p.cancellationStatuses, p.cancelOrder, p.abortCancelOrderConfirmation, p.showCancelOrderConfirmation)
}
</td>
</tr>
);
Expand All @@ -40,9 +36,54 @@ OpenOrder.propTypes = {
type: React.PropTypes.string.isRequired,
avgPrice: React.PropTypes.object.isRequired,
unmatchedShares: React.PropTypes.object.isRequired,
isCancelling: React.PropTypes.bool.isRequired,
isCancelled: React.PropTypes.bool.isRequired,
cancellationStatuses: React.PropTypes.object.isRequired,
status: React.PropTypes.string,
abortCancelOrderConfirmation: React.PropTypes.func.isRequired,
showCancelOrderConfirmation: React.PropTypes.func.isRequired,
cancelOrder: React.PropTypes.func.isRequired
};

function renderCancelNode(orderID, marketID, type, status, cancellationStatuses, cancelOrder, abortCancelOrderConfirmation, showCancelOrderConfirmation) {
switch (status) {
case cancellationStatuses.CANCELLATION_CONFIRMATION:
return (
<span>
<button
className="button cancel-order-abort-confirmation"
title="No, don't cancel order"
onClick={(event) => {
abortCancelOrderConfirmation(orderID, marketID, type);
}}
>No</button>
<button
className="button cancel-order-action"
title="Yes, cancel order"
onClick={(event) => {
cancelOrder(orderID, marketID, type);
}}
>Yes</button>
</span>
);
case cancellationStatuses.CANCELLING:
return 'Cancelling';
case cancellationStatuses.CANCELLATION_FAILED:
return 'Failure';
case cancellationStatuses.CANCELLED:
return null;
default:
return (
<button
className="button cancel-order-action"
title="Cancel order"
onClick={(event) => {
showCancelOrderConfirmation(orderID, marketID, type);
}}
>
Cancel
</button>
);
}

}

export default OpenOrder;
8 changes: 6 additions & 2 deletions src/modules/open-orders/components/open-orders-group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const OpenOrdersGroup = (p) => {
key={openOrder.id}
outcomeName={p.name}
{...openOrder}
cancelOrder={p.cancelOrder}
status={p.orderCancellation[openOrder.id]}
cancellationStatuses={p.orderCancellation.cancellationStatuses}
cancelOrder={p.orderCancellation.cancelOrder}
abortCancelOrderConfirmation={p.orderCancellation.abortCancelOrderConfirmation}
showCancelOrderConfirmation={p.orderCancellation.showCancelOrderConfirmation}
/>
))}
</tbody>
Expand All @@ -37,7 +41,7 @@ const OpenOrdersGroup = (p) => {
OpenOrdersGroup.propTypes = {
userOpenOrders: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
name: React.PropTypes.string.isRequired,
cancelOrder: React.PropTypes.func.isRequired
orderCancellation: React.PropTypes.object.isRequired
};

export default OpenOrdersGroup;
19 changes: 17 additions & 2 deletions src/modules/open-orders/less/open-order.less
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
text-align: right;
}
.cancel {
padding: 0.1em 0em;
padding: 0.1em 0;
text-align: left;
min-width: 4.6em;
font-size: 0.6em;

.cancel-order-action {
padding: 0;
Expand All @@ -38,7 +40,6 @@
text-align: left;
color: @color-danger-active;
background: transparent;
font-size: 0.6em;

&:before {
content: '\f00d';
Expand All @@ -58,6 +59,20 @@
background: transparent !important;
}
}

.cancel-order-abort-confirmation {
padding: 0;
height: unset;
line-height: unset;
text-align: left;
background-color: transparent;
color: inherit;
margin-right: 1.4em;

&:hover {
font-weight: 700;
}
}
}

.open-order {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/trade/components/trade-builder-bid-ask.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classnames from 'classnames';
import ValueDenomination from '../../../modules/common/components/value-denomination';

const TradeBuilderBidAsk = (p) => (
<div className={classnames('trade-builder-bid-ask', p.className)}>
<div className={classnames('trade-builder-bid-ask', { 'is-of-current-user': p.bidAsk.isOfCurrentUser }, p.className)}>
<ValueDenomination
className={classnames('shares')}
{...p.bidAsk.shares}
Expand Down
12 changes: 11 additions & 1 deletion src/modules/trade/components/trade-builder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@ const TradePanel = (p) => (
/>
))}
</tbody>
{p.userOpenOrdersSummary != null && p.userOpenOrdersSummary.openOrdersCount != null && p.userOpenOrdersSummary.openOrdersCount.value > 0 &&
(<tbody>
<tr>
<td colSpan="9">
Prices at which you have open orders are underlined
</td>
</tr>
</tbody>)
}
</table>
);

TradePanel.propTypes = {
outcomes: React.PropTypes.array,
selectedOutcome: React.PropTypes.object
selectedOutcome: React.PropTypes.object,
userOpenOrdersSummary: React.PropTypes.object
};

export default TradePanel;
2 changes: 2 additions & 0 deletions src/modules/trade/components/trade-panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TradePanel = (p) => (
<div className="trade-panel">
<TradeBuilder
outcomes={p.outcomes}
userOpenOrdersSummary={p.userOpenOrdersSummary}
selectedOutcome={p.selectedOutcome}
/>

Expand All @@ -32,6 +33,7 @@ TradePanel.propTypes = {
outcomes: React.PropTypes.array,
selectedOutcome: React.PropTypes.object,
tradeSummary: React.PropTypes.object,
userOpenOrdersSummary: React.PropTypes.object,
onSubmitPlaceTrade: React.PropTypes.func
};

Expand Down
7 changes: 6 additions & 1 deletion src/modules/trade/less/trade-builder.less
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@

.trade-builder-bid-ask {
display: flex;
&.is-of-current-user {
.price .value {
text-decoration: underline;
}
}
.shares {
flex: 1.6;
text-align: right;
Expand Down Expand Up @@ -111,4 +116,4 @@
color: @color-warning-normal;
}
}
}
}
4 changes: 2 additions & 2 deletions src/selectors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import activePage from './selectors/active-page';
import authForm from './selectors/auth-form';
import { cancelOrder } from './selectors/cancel-order';
import orderCancellation from './selectors/order-cancellation';
import createMarketForm from './selectors/create-market-form';
import filters from './selectors/filters';
import keywords from './selectors/keywords';
Expand All @@ -19,7 +19,7 @@ import url from './selectors/url';
const selectors = {
activePage,
authForm,
cancelOrder,
orderCancellation,
createMarketForm,
filters,
keywords,
Expand Down
6 changes: 4 additions & 2 deletions src/selectors/bids-asks/select-bids-asks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default function selectOrderBook() {
bids: [
{
shares: makeNumber(776, 'Shares'),
price: makeNumber(0.5, 'eth')
price: makeNumber(0.5, 'eth'),
isOfCurrentUser: true
},
{
shares: makeNumber(87, 'Shares'),
Expand All @@ -27,7 +28,8 @@ export default function selectOrderBook() {
},
{
shares: makeNumber(2000, 'Shares'),
price: makeNumber(0.72, 'eth')
price: makeNumber(0.72, 'eth'),
isOfCurrentUser: Math.random() > 0.3
},
{
shares: makeNumber(5, 'Shares'),
Expand Down
27 changes: 0 additions & 27 deletions src/selectors/cancel-order.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/selectors/markets.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,6 @@ function makeMarkets(numMarkets = 50) {
id: `${m.id}${outcome.id}order${index}`,
type: parseInt(index, 10) % 2 === 1 ? 'buy' : 'sell',
marketID: m.id,
isCancelling: false,
isCancelled: false,
avgPrice: makeNumber(parseFloat(Math.random().toFixed(2)), 'eth'),
unmatchedShares: makeNumber(parseInt(Math.random() * 10, 10), 'shares'),
outcome: outcomeID,
Expand Down
Loading

0 comments on commit f79d02c

Please sign in to comment.