OSDN Git Service

trigger the estimate fee on the button click and the ammount onblur
authorZhiting Lin <zlin035@uottawa.ca>
Thu, 27 Sep 2018 08:25:58 +0000 (16:25 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Thu, 27 Sep 2018 08:25:58 +0000 (16:25 +0800)
src/features/transactions/components/New/NormalTransactionForm.jsx

index 894ccee..d812dfd 100644 (file)
@@ -82,12 +82,25 @@ class NormalTxForm extends React.Component {
       id: counter
     })
     this.setState({
-      counter: counter+1
+      counter: counter+1,
+      estimateGas: null
     })
   }
 
   removeReceiverItem(index) {
-    this.props.fields.receivers.removeField(index)
+    const receiver = this.props.fields.receivers
+    const promise = new Promise(function(resolve, reject) {
+      try {
+        receiver.removeField(index)
+        resolve()
+      } catch (err) {
+        reject(err)
+      }
+    })
+
+    promise.then(
+      () =>  this.estimateNormalTransactionGas()
+    )
   }
 
   estimateNormalTransactionGas() {
@@ -170,6 +183,9 @@ class NormalTxForm extends React.Component {
     const lang = this.props.lang;
     [accountAlias, accountId, assetAlias, assetId].forEach(key => {
       key.onBlur = this.estimateNormalTransactionGas.bind(this)
+    });
+    (receivers.map(receiver => receiver.amount)).forEach(amount =>{
+      amount.onBlur = this.estimateNormalTransactionGas.bind(this)
     })
 
     let submitLabel = lang === 'zh' ? '提交交易' : 'Submit transaction'