augur-ui-react-components
Advanced tools
Comparing version 3.6.14 to 3.6.16
{ | ||
"name": "augur-ui-react-components", | ||
"version": "3.6.14", | ||
"version": "3.6.16", | ||
"description": "Augur UI React Components", | ||
@@ -5,0 +5,0 @@ "author": "Augur Project", |
@@ -91,3 +91,3 @@ import React, { Component, PropTypes } from 'react'; | ||
{isClearable && !p.isMultiline && !!s.value && | ||
<button type="button" className="clear" onClick={this.handleClear}> | ||
<button type="button" className="button-text-only" onClick={this.handleClear}> | ||
<i></i> | ||
@@ -94,0 +94,0 @@ </button> |
@@ -56,5 +56,35 @@ import React, { PropTypes } from 'react'; | ||
<h2>Technical updates:</h2> | ||
<h3>November 15, 2016</h3> | ||
<ol> | ||
<li> | ||
Fixed market selector isExpired property calculation, distinguished it from isOpen. | ||
</li> | ||
<li> | ||
Added result (reported outcome / proportion correct) object field to market(s) selectors. | ||
</li> | ||
<li> | ||
For Airbitz logins, private keys are now stored in an Airbitz wallet instead of using the Airbitz dataKey as the Ethereum private key. (This change only affects Airbitz accounts.) | ||
</li> | ||
</ol> | ||
<h3>November 14, 2016</h3> | ||
<ol> | ||
<li> | ||
Scalar market order books now display "truncated" share quantities for very large quantities of millishares and microshares. | ||
</li> | ||
<li> | ||
Market preview tooltips now display non-truncated values for very large numbers. | ||
</li> | ||
<li> | ||
Categorical outcomes are now correctly rounded to the nearest integer (on eventResolution contract). | ||
</li> | ||
<li> | ||
Added check to make sure event is on the specified branch before penalizing (on consensus contract). Resolves the edge case of penalization of a reporter who is otherwise caught up when there are no events in a period. | ||
</li> | ||
<li> | ||
Added reporting proportion correct value to getMarketInfo array (on compositeGetters contract). | ||
</li> | ||
<li> | ||
Added event outcome to getMarketsInfo (on compositeGetters contract). | ||
</li> | ||
<li> | ||
Fixed a bug causing some reports to throw hash-mismatching errors during the reveal-report action. | ||
@@ -61,0 +91,0 @@ </li> |
@@ -60,5 +60,5 @@ import React, { Component, PropTypes } from 'react'; | ||
if (maxValue >= 1000000) { | ||
if (maxValue >= 10000000) { | ||
this.props.scalarShareDenomination.updateSelectedShareDenomination(marketID, MICRO_SHARE); | ||
} else if (maxValue >= 1000) { | ||
} else if (maxValue >= 10000) { | ||
this.props.scalarShareDenomination.updateSelectedShareDenomination(marketID, MILLI_SHARE); | ||
@@ -65,0 +65,0 @@ } else { |
@@ -15,3 +15,3 @@ import React from 'react'; | ||
<div className="market-header-actions"> | ||
{p.type === SCALAR && !p.isPendingReport && | ||
{p.type === SCALAR && p.selectedShareDenomination && !p.isPendingReport && | ||
<Dropdown | ||
@@ -18,0 +18,0 @@ default={p.selectedShareDenomination} |
@@ -13,3 +13,5 @@ import React from 'react'; | ||
const MarketProperties = (p) => { | ||
const shareVolume = setShareDenomination(getValue(p, 'volume.rounded'), p.selectedShareDenomination); | ||
const shareVolumeRounded = setShareDenomination(getValue(p, 'volume.rounded'), p.selectedShareDenomination); | ||
const shareVolumeFormatted = getValue(p, 'volume.formatted'); | ||
const shareDenomination = () => { | ||
@@ -96,3 +98,3 @@ // TODO be less hackish (sorry sprinkle) | ||
</li> | ||
{shareVolume && | ||
{shareVolumeRounded && | ||
<li className="property volume"> | ||
@@ -105,3 +107,3 @@ <a | ||
<span className="property-label">Volume:</span> | ||
<ValueDenomination className="property-value" formatted={shareVolume} denomination={shareDenomination()} /> | ||
<ValueDenomination className="property-value" formatted={shareVolumeRounded} denomination={shareDenomination()} /> | ||
</a> | ||
@@ -116,3 +118,3 @@ <ReactTooltip | ||
<span className="tooltip-text"> | ||
{shareVolume} total {p.volume.denomination} traded | ||
{shareVolumeFormatted} total {p.volume.denomination} traded | ||
</span> | ||
@@ -119,0 +121,0 @@ </ReactTooltip> |
@@ -23,3 +23,3 @@ import React, { Component, PropTypes } from 'react'; | ||
shareInputPlaceholder: generateShareInputPlaceholder(this.props.selectedShareDenomination), | ||
maxSharesDenominated: denominateShares(getValue(this.props, 'selectedOutcome.trade.maxNumShares.value', SHARE, this.props.selectedShareDenomination)), | ||
maxSharesDenominated: denominateShares(getValue(this.props, 'selectedOutcome.trade.maxNumShares.value', SHARE, this.props.selectedShareDenomination)), // NOTE -- this value is not currently used in the component, but may be used later, so leaving here until this decision is finalized | ||
sharesDenominated: denominateShares(getValue(this.props, 'selectedOutcome.trade.numShares'), SHARE, this.props.selectedShareDenomination) | ||
@@ -103,3 +103,2 @@ }; | ||
min="0" | ||
max={s.maxSharesDenominated} | ||
step="0.1" | ||
@@ -148,2 +147,3 @@ onChange={(value) => { this.handleSharesInput(value); }} | ||
// Determine numerical representation of from/to values for shares mutation calc | ||
const options = [SHARE, MILLI_SHARE, MICRO_SHARE]; | ||
@@ -170,6 +170,9 @@ let fromValue = 0; | ||
if (fromValue < toValue) { | ||
if (fromValue === toValue) { | ||
return shares; | ||
} else if (fromValue < toValue) { | ||
return shares * Math.pow(1000, toValue - fromValue); | ||
} | ||
// fromValue > toValue | ||
return shares / Math.pow(1000, Math.abs(toValue - fromValue)); | ||
@@ -176,0 +179,0 @@ } |
import { SHARE, MILLI_SHARE, MICRO_SHARE } from 'modules/market/constants/share-denominations'; | ||
import addCommas from 'utils/add-commas-to-number'; | ||
// This helper method is very specific in scope | ||
// It takes in the formatted shares in string format and returns a string denominated as specified | ||
// The mutation of the shares is done this way so no actual re-calculation is done to the underlying | ||
// values, just string manipulation for presentation | ||
function setShareDenomination(value, denomination) { | ||
@@ -21,6 +24,7 @@ if (value == null) { | ||
// The value is assumed to *always* be in 'SHARES' denomination | ||
function formatValue(value, amount) { | ||
const valueArray = value.split(''); | ||
let valueArray = value.split(''); | ||
// remove dot | ||
// remove dot + determine 0 pad amount | ||
const dotIndex = valueArray.indexOf('.'); | ||
@@ -34,4 +38,4 @@ let zeroPadAmount = amount; | ||
// Strip leading 0's | ||
let firstPositiveValue = 0; | ||
// Strip leading 0's OR returns original value if no values are positive | ||
let firstPositiveValue = -1; | ||
valueArray.some((value, i) => { | ||
@@ -45,14 +49,72 @@ if (parseInt(value, 10)) { | ||
}); | ||
if (firstPositiveValue) { | ||
if (firstPositiveValue !== -1) { | ||
valueArray.splice(0, firstPositiveValue); | ||
} else { | ||
return value; // Returns original value | ||
} | ||
// Append 0's | ||
for (let i = 0; i < zeroPadAmount; i++) { | ||
valueArray.push('0'); | ||
} | ||
// Strip Commas (added back in at the end) | ||
valueArray.forEach((value, i) => { | ||
if (value === ',') { | ||
valueArray.splice(i, 1); | ||
} | ||
}); | ||
return valueArray.join('').replace(/\B(?=(\d{3})+(?!\d))/g, ','); // return joined string w/ comma separating thousands, BIG assumption here is that we're always rounding to TWO decimal places | ||
// Handle postFixed denominations (part of the format-number method) | ||
valueArray = handlePostfixedUnit(valueArray, zeroPadAmount); | ||
return addCommas(valueArray.join('')); // return joined string w/ comma separating thousands | ||
} | ||
function handlePostfixedUnit(valueArray, zeroPadAmount) { | ||
const step = zeroPadAmount < 4; | ||
const gtTrillion = '> 1T'.split(''); | ||
let newValueArray = valueArray; | ||
switch (valueArray[newValueArray.length - 1]) { | ||
// Handle existing > 10000 values | ||
case ('K'): { | ||
newValueArray[newValueArray.length - 1] = step ? 'M' : 'B'; | ||
return newValueArray; | ||
} | ||
case ('M'): { | ||
if (step) { | ||
newValueArray[newValueArray.length - 1] = 'B'; | ||
} else { | ||
newValueArray = gtTrillion; | ||
} | ||
return newValueArray; | ||
} | ||
case ('B'): | ||
case ('T'): { | ||
newValueArray = gtTrillion; | ||
return newValueArray; | ||
} | ||
// Handle values that become greater than 10000 | ||
default: { | ||
// Append 0's | ||
for (let i = 0; i < zeroPadAmount; i++) { | ||
newValueArray.push('0'); | ||
} | ||
// Mirrors logic present in format-number | ||
if (newValueArray.length >= 13) { | ||
newValueArray = gtTrillion; | ||
} else if (newValueArray.length >= 11) { | ||
newValueArray.splice(newValueArray.length - 9); | ||
newValueArray.push('B'); | ||
} else if (newValueArray.length >= 8) { | ||
newValueArray.splice(newValueArray.length - 6); | ||
newValueArray.push('M'); | ||
} else if (newValueArray.length >= 5) { | ||
newValueArray.splice(newValueArray.length - 3); | ||
newValueArray.push('K'); | ||
} | ||
return newValueArray; | ||
} | ||
} | ||
} | ||
export default setShareDenomination; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2331923
328
43696