this.handleBlur = this.handleBlur.bind(this)
}
+ componentDidMount() {
+ if(this.props.fieldProps.value){
+ const value = (this.props.fieldProps.value/ Math.pow(10, 8)).toString()
+
+ this.props.fieldProps.onChange(
+ parseBTMAmount(value, this.props.decimal )
+ )
+ this.setState({ value: ( this.props.decimal === 0 ? value: addZeroToDecimalPosition( value, this.props.decimal ) ) })
+ }
+ }
+
+ componentDidUpdate(prevProps){
+ if(prevProps.decimal !== this.props.decimal){
+ const value = (prevProps.fieldProps.value/ Math.pow(10, prevProps.decimal)).toString()
+
+ this.props.fieldProps.onChange(
+ parseBTMAmount(value, this.props.decimal )
+ )
+ this.setState({ value: ( this.props.decimal === 0 ? value: addZeroToDecimalPosition( value, this.props.decimal ) ) })
+ }
+ }
handleBlur(event) {
const value = event.target.value
- this.setState({ value: addZeroToDecimalPosition( value, this.props.decimal ) })
+ if( this.props.decimal > 0 ){
+ this.setState({ value: addZeroToDecimalPosition( value, this.props.decimal ) })
+ }
if (this.props.fieldProps.onBlur) {
// Swallow the event to prevent Redux Form from
// extracting the form value
this.handleBlur = this.handleBlur.bind(this)
}
+ componentDidMount() {
+ if(this.props.fieldProps.value){
+ this.props.fieldProps.onChange(
+ parseBTMAmount(this.props.fieldProps.value, this.state.pos )
+ )
+ this.setState({ value: addZeroToDecimalPosition( this.props.fieldProps.value, this.state.pos ) })
+ }
+ }
toggleDropwdown() {
this.setState({ showDropdown: !this.state.showDropdown })
<div className='form-group'>
{this.props.title && <FieldLabel>{this.props.title}</FieldLabel>}
<div className='input-group'>
- {<input className='form-control'
+ <input className='form-control'
type={this.state.type}
{...fieldProps}
value={formatBTMAmount(this.state.value, this.state.pos)}
autoFocus={!!this.props.autoFocus}
onBlur={this.handleBlur}
onChange={this.handleChange}
- />}
+ />
<div className={`input-group-btn ${this.state.showDropdown && 'open'}`}>
const btmAmounUnitVisible = (assetAlias.value === 'BTM' ||
assetId.value === 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' )
- const decimal = this.props.decimal
+ const decimal = this.props.decimal || 0
const classNames = [styles.main]
if (type.error) classNames.push(styles.error)
}}
/>}
- {visible.amount && !btmAmounUnitVisible && !decimal &&
- <TextField title={ lang === 'zh' ? '数量' :'Amount' } fieldProps={amount} />}
-
- {visible.amount && !btmAmounUnitVisible && decimal &&
+ {visible.amount && !btmAmounUnitVisible &&
<AmountInputMask title={ lang === 'zh' ? '数量' :'Amount' } fieldProps={amount} decimal={decimal} />}
{visible.amount && btmAmounUnitVisible &&
const range = rangeOptions.find(item => item.label === event.target.value)
gas.price.onChange(range.value)
}
- const assetDecimal = this.props.assetDecimal(this.props.fields)
+ const assetDecimal = this.props.assetDecimal(this.props.fields) || 0
const showAvailableBalance = (accountAlias.value || accountId.value) &&
(assetAlias.value || assetId.value)
this.estimateNormalTransactionGas()
},
}}/>
- {!showBtmAmountUnit && !assetDecimal &&
- <TextField title={lang === 'zh' ? '数量' : 'Amount'} fieldProps={amount}
- />}
- {!showBtmAmountUnit && assetDecimal &&
+ {!showBtmAmountUnit &&
<AmountInputMask title={lang === 'zh' ? '数量' : 'Amount'} fieldProps={amount} decimal={assetDecimal}
/>}
{showBtmAmountUnit &&