}
render() {
+ const idOnChange = (event) => {
+ this.props.fieldProps.id.onChange(event.target.value)
+ this.props.fieldProps.alias.onChange('')
+ }
+
+ const aliasOnChange = value => {
+ this.props.fieldProps.alias.onChange(value)
+ this.props.fieldProps.id.onChange('')
+ }
+
+ const idProps = Object.assign({...this.props.fieldProps.id}, {onChange: idOnChange})
+ const aliasProps = Object.assign({...this.props.fieldProps.alias}, {onChange: aliasOnChange})
+
return(
<div className='form-group'>
{this.props.title && <FieldLabel>{this.props.title}</FieldLabel>}
<input className='form-control'
type={this.state.type}
placeholder={`${this.props.title} ID`}
- {...this.props.fieldProps.id} />}
+ {...idProps} />}
{this.state.selected == ALIAS_SELECTED &&
<this.props.aliasField
className={styles.aliasFieldGroupItem}
placeholder={`Start typing ${this.props.title.toLowerCase()} alias...`}
- fieldProps={this.props.fieldProps.alias} />}
+ fieldProps={aliasProps} />}
</div>
{this.props.hint && <span className='help-block'>{this.props.hint}</span>}
constructor(props) {
super(props)
this.state = {
- showDropdown: false
+ showDropdown: false,
+ showAdvanced: false
}
this.submitWithValidation = this.submitWithValidation.bind(this)
}
disableSubmit(actions, normalTransaction) {
- // let isNormalShow = true
- // for (let key in normalTransaction){
- // isNormalShow = isNormalShow & normalTransaction[key].dirty
- // }
- // return !isNormalShow & actions.length == 0 & !this.state.showAdvanced
- // return actions.length == 0 & !this.state.showAdvanced
- return false
+ if (this.showAdvance) {
+ return actions.length == 0 & !this.state.showAdvanced
+ }
+
+ const hasValue = target => {
+ return !!(target && target.value)
+ }
+
+ return !((hasValue(normalTransaction.accountId) || hasValue(normalTransaction.accountAlias)) &&
+ (hasValue(normalTransaction.assetId)|| hasValue(normalTransaction.assetAlias)) &&
+ hasValue(normalTransaction.address) && (hasValue(normalTransaction.amount)))
}
removeActionItem(index) {