OSDN Git Service

change the styles to coding popup
authorZhiting Lin <zlin035@uottawa.ca>
Tue, 14 Aug 2018 02:05:14 +0000 (10:05 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Tue, 14 Aug 2018 02:05:14 +0000 (10:05 +0800)
src/features/transactions/components/New/AdvancedTransactionForm.jsx
src/features/transactions/components/New/MultiSignTransactionDetails/TransactionDetails.jsx

index 1f5c2bc..01a319b 100644 (file)
@@ -144,8 +144,7 @@ class AdvancedTxForm extends React.Component {
               fieldProps={signTransaction}
               decode={this.props.decode}
               transaction={this.props.decodedTx}
-              btmAmountUnit={this.props.btmAmountUnit}
-              asset={this.props.asset}
+              showJsonModal={this.props.showJsonModal}
             />
 
             <FieldLabel>{lang === 'zh' ? '交易构建类型' : 'Transaction Build Type'}</FieldLabel>
@@ -244,6 +243,12 @@ export default BaseNew.connect(
   (dispatch) => ({
     ...BaseNew.mapDispatchToProps('transaction')(dispatch),
     decode: (transaction) => dispatch( actions.transaction.decode(transaction)),
+    showJsonModal: (body) => dispatch(actions.app.showModal(
+      body,
+      actions.app.hideModal,
+      null,
+      { wide: true }
+    )),
   }),
   reduxForm({
     form: 'AdvancedTransactionForm',
index 41d78d5..c62af4c 100644 (file)
@@ -2,8 +2,6 @@ import React from 'react'
 import pick from 'lodash/pick'
 import { FieldLabel } from 'features/shared/components'
 import disableAutocomplete from 'utility/disableAutocomplete'
-import { btmID } from 'utility/environment'
-import { normalizeGlobalBTMAmount , converIntToDec} from 'utility/buildInOutDisplay'
 import styles from './TransactionDetails.scss'
 
 
@@ -19,46 +17,14 @@ class TransactionDetails extends React.Component {
   constructor(props) {
     super(props)
     this.showDetailTransactions = this.showDetailTransactions.bind(this)
-    this.normalize = this.normalize.bind(this)
   }
 
   showDetailTransactions(e, json){
     e.preventDefault()
     const rawTransaction = JSON.parse(json).rawTransaction
-    this.props.decode(rawTransaction)
-  }
-
-  normalize(inouts) {
-    const items = []
-    let assets = this.props.asset
-
-    inouts.forEach(inout => {
-      const assetId = inout.assetId
-
-      let filteredAsset = assets
-      filteredAsset = filteredAsset.filter(asset => asset.id === assetId)
-
-      let alias = assetId
-      let amount = inout.amount
-
-      if(filteredAsset.length === 1){
-        alias =  filteredAsset[0].alias
-        amount = assetId===btmID?
-          normalizeGlobalBTMAmount(btmID, amount, this.props.btmAmountUnit):
-          converIntToDec(amount, filteredAsset[0].definition.decimals)
-      }
-
-      items.push({
-        type: inout.type,
-        amount: amount,
-        assetAlias: alias ,
-        assetId: assetId,
-        address: inout.address,
-        controlProgram: inout.controlProgram
-      })
+    this.props.decode(rawTransaction).then(() => {
+      this.props.showJsonModal(<pre>{JSON.stringify(this.props.transaction, null, 2)}</pre>)
     })
-
-    return items
   }
 
   render() {
@@ -67,77 +33,6 @@ class TransactionDetails extends React.Component {
 
     const lang = this.props.lang
 
-    const item = this.props.transaction
-    const btmAmountUnit = this.props.btmAmountUnit
-
-    let view = <div></div>
-    if (item.length !== 0) {
-      const fee = normalizeGlobalBTMAmount(btmID, item.fee, btmAmountUnit)
-
-      const inputs = this.normalize(item.inputs)
-      const outputs =  this.normalize(item.outputs)
-
-      const table = (inouts) =>
-        (inouts.map((inout, index) =>
-          <table key={index} className={styles.table}>
-            <tr>
-              <td className={styles.colLabel}> {lang === 'zh' ? '类型' : 'Type'}:</td>
-              <td><code>{inout.type}</code></td>
-            </tr>
-            <tr>
-              <td className={styles.colLabel}> {lang === 'zh' ? '地址' : 'Address'}:</td>
-              <td><code>{inout.address}</code></td>
-            </tr>
-            <tr>
-              <td className={styles.colLabel}> {lang === 'zh' ? '数量' : 'Amount'}:</td>
-              <td><code>{inout.amount}</code></td>
-            </tr>
-            <tr>
-              <td className={styles.colLabel}> {lang === 'zh' ? '资产' : 'Asset'}:</td>
-              <td><code>{inout.assetAlias}</code></td>
-            </tr>
-            <tr>
-              <td className={styles.colLabel}> {lang === 'zh' ? '合约程序' : 'Control Program'}:</td>
-              <td><code>{inout.controlProgram}</code></td>
-            </tr>
-          </table>))
-
-      view =  (<div  className={`form-group ${styles.view}`}>
-        <FieldLabel>{lang === 'zh' ? '交易内容' : 'Transaction Content'}</FieldLabel>
-
-        <div className={styles.main}>
-          <div className={styles.txID}>
-            <label>{lang === 'zh' ? '详情:' : 'Summary:'}</label>
-            <table key={'txsummary'} className={styles.table}>
-              <tr>
-                <td  className={styles.colLabel}>
-                  {lang === 'zh' ? '交易ID:' : 'Transaction ID:'}
-                </td>
-                <td>
-                  <code>{item.txId}</code>
-                </td>
-              </tr>
-              <tr>
-                <td  className={styles.colLabel}>Gas:</td>
-                <td><code>{fee}</code></td>
-              </tr>
-            </table>
-          </div>
-
-          <div>
-            <label>{lang === 'zh' ? '输入:' : 'Input:'}</label>
-            {table(inputs)}
-
-            <label>{lang === 'zh' ? '输出:' : 'Output:'}</label>
-            {table(outputs)}
-          </div>
-        </div>
-
-      </div>)
-    }
-
-
-
     return(
       <div className='form-group'>
         <FieldLabel>{lang === 'zh' ? '带签名交易' : 'To sign transaction'}</FieldLabel>
@@ -157,7 +52,6 @@ class TransactionDetails extends React.Component {
             {lang === 'zh' ? '展示交易内容':'Transaction details'}
           </button>
         </div>
-        {view}
       </div>
     )
   }