OSDN Git Service

update account selection in transaction
authorZhiting Lin <zlin035@uottawa.ca>
Thu, 11 Jul 2019 02:53:29 +0000 (10:53 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Thu, 11 Jul 2019 02:53:29 +0000 (10:53 +0800)
src/features/app/components/Container.jsx
src/features/app/reducers.js
src/features/core/components/CoreIndex/CoreIndex.jsx
src/features/core/components/CoreIndex/CoreIndex.scss
src/features/transactions/components/New/AdvancedTransactionForm.jsx
src/features/transactions/components/New/CrossChain/CrossChainTransaction.jsx
src/features/transactions/components/New/FormActionItem.jsx
src/features/transactions/components/New/New.jsx
src/features/transactions/components/New/NormalTransactionForm.jsx
src/features/transactions/components/New/Vote.jsx

index 5118a15..d66af15 100644 (file)
@@ -39,7 +39,7 @@ class Container extends React.Component {
   }
 
   componentDidMount() {
-    this.props.fetchKeyItem().then(resp => {
+    this.props.fetchAccountItem().then(resp => {
       if (resp.data.length == 0) {
         this.setState({noAccountItem: true})
         this.props.updateAccountInit(false)
@@ -120,6 +120,6 @@ export default connect(
     showRoot: () => dispatch(actions.app.showRoot),
     showInitialization: () => dispatch(actions.app.showInitialization()),
     updateAccountInit: (param) => dispatch(actions.app.updateAccountInit(param)),
-    fetchKeyItem: () => dispatch(actions.key.fetchItems())
+    fetchAccountItem: () => dispatch(actions.account.fetchItems())
   })
 )( withI18n() (Container) )
index 3f8160d..8237bf9 100644 (file)
@@ -97,7 +97,7 @@ export const flashMessages = (state = {}, action) => {
     }
 
     case 'ERROR': {
-      return newError(state, action.payload.message)
+      return newError(state, action.payload.message||action.payload.msg)
     }
 
     case 'USER_LOG_IN': {
index 21ab780..98fb194 100644 (file)
@@ -172,8 +172,8 @@ class CoreIndex extends React.Component {
         <PageTitle
           title={t('coreIndex.coreStatus')}
           actions={[
-            <button className='btn btn-link' onClick={this.consolePopup}>
-              <img src={require('images/console-window.svg')}/>
+            <button className={`btn btn-link ${styles.actionBtn}`} onClick={this.consolePopup}>
+              <span>{t('console.title')}</span> <img src={require('images/console-window.svg')}/>
             </button>
           ]}
         />
index e43624d..c0185b9 100644 (file)
@@ -9,6 +9,11 @@
     vertical-align: top;
   }
 }
+.actionBtn{
+  img{
+    margin-bottom: 3px;
+  }
+}
 
 .row{
   line-height: 30px;
@@ -149,4 +154,4 @@ code {
   -webkit-transition: .4s;
   transition: .4s;
   border-radius: 50%;
-}
\ No newline at end of file
+}
index 3fb7d33..b54a49a 100644 (file)
@@ -46,10 +46,20 @@ class AdvancedTxForm extends React.Component {
 
   addActionItem(type) {
     const counter = this.state.counter
-    this.props.fields.actions.addField({
-      type: type,
-      ID: counter
-    })
+    let obj
+    if(type === 'spend_account' || type === 'veto'){
+      obj = {
+        type: type,
+        ID: counter,
+        accountAlias: this.props.currentAccount
+      }
+    }else{
+      obj = {
+        type: type,
+        ID: counter,
+      }
+    }
+    this.props.fields.actions.addField(obj)
     this.closeDropdown()
     this.setState({
       counter: counter+1
@@ -111,7 +121,7 @@ class AdvancedTxForm extends React.Component {
         <FormSection title='Actions'>
           {actions.map((action, index) =>
             <ActionItem
-              key={action.ID.value}
+              key={`form-action-${action.ID.value}`}
               index={index}
               fieldProps={action}
               accounts={this.props.accounts}
@@ -245,7 +255,8 @@ const mapDispatchToProps = (dispatch) => ({
 export default withNamespaces('translations') (BaseNew.connect(
   (state, ownProps) => ({
     ...BaseNew.mapStateToProps('transaction')(state, ownProps),
-    decodedTx: state.transaction.decodedTx
+    decodedTx: state.transaction.decodedTx,
+    currentAccount : state.account.currentAccount
   }),
   mapDispatchToProps,
   reduxForm({
index c3446ab..058843f 100644 (file)
@@ -143,6 +143,7 @@ class CrossChainTransaction extends React.Component {
                   id: accountId,
                   alias: accountAlias
                 }}
+                disabled
               />
 
               <ObjectSelectorField
index ae53178..45dc8cb 100644 (file)
@@ -115,6 +115,7 @@ class ActionItem extends React.Component {
               id: accountId,
               alias: accountAlias
             }}
+            disabled
           />}
 
         {visible.receiver &&
index 564c4f9..86026df 100644 (file)
@@ -47,8 +47,6 @@ class Form extends React.Component {
   handleFormEmpty() {
     if(this.props.normalSelected){
       const array = [
-        'accountAlias',
-        'accountId',
         'assetAlias',
         'assetId',
         'password']
@@ -66,8 +64,6 @@ class Form extends React.Component {
       this.props.advform['password'])
     }else if(this.props.voteSelected){
       const array = [
-        'accountAlias',
-        'accountId',
         'amount',
         'nodePubkey'
       ]
@@ -80,8 +76,6 @@ class Form extends React.Component {
       return true
     }else if(this.props.crossChainSelected){
       const array = [
-        'accountAlias',
-        'accountId',
         'assetAlias',
         'assetId',
         'address',
index efd1e15..4637208 100644 (file)
@@ -170,6 +170,7 @@ class NormalTxForm extends React.Component {
                   id: accountId,
                   alias: accountAlias
                 }}
+                disabled
               />
               <div>
                 <ObjectSelectorField
index b2d0d9a..058e408 100644 (file)
@@ -140,6 +140,7 @@ class Vote extends React.Component {
                   id: accountId,
                   alias: accountAlias
                 }}
+                disabled
               />
               <div>
                 <TextField