From 8855107e52dcf6cb52c95b87033e64f1d2830faa Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sun, 28 May 2017 21:19:19 -0400 Subject: [PATCH] Simplify security editing UI --- js/components/SecuritiesTab.js | 81 +++++++++++++++---------- js/containers/SecuritiesTabContainer.js | 6 ++ static/css/stylesheet.css | 4 +- 3 files changed, 56 insertions(+), 35 deletions(-) diff --git a/js/components/SecuritiesTab.js b/js/components/SecuritiesTab.js index 4c6819b..a6282af 100644 --- a/js/components/SecuritiesTab.js +++ b/js/components/SecuritiesTab.js @@ -325,6 +325,14 @@ module.exports = React.createClass({ deletionFailedModal: false }; }, + componentWillReceiveProps: function(nextProps) { + if (nextProps.selectedSecurity == -1 && nextProps.security_list.length > 0) { + nextProps.onSelectSecurity(nextProps.security_list[0].SecurityId); + } + }, + handleSelectSecurity: function(security) { + this.props.onSelectSecurity(security.SecurityId); + }, handleNewSecurity: function() { this.setState({creatingNewSecurity: true}); }, @@ -357,43 +365,50 @@ module.exports = React.createClass({ render: function() { var noSecuritySelected = this.props.selectedSecurity == -1; - var selectedSecurity = null; + var selectedSecurity = -1; if (this.props.securities.hasOwnProperty(this.props.selectedSecurity)) selectedSecurity = this.props.securities[this.props.selectedSecurity]; return ( - - - - - - - - - - - - - - +
+ + + + + + + + + typeof item === 'string' ? item : item.Name + " - " + item.Description} + value={selectedSecurity} + onChange={this.handleSelectSecurity} + suggest + filter='contains' + ref="security" /> + + + + + +
); } }); diff --git a/js/containers/SecuritiesTabContainer.js b/js/containers/SecuritiesTabContainer.js index b7b46f6..e1c80db 100644 --- a/js/containers/SecuritiesTabContainer.js +++ b/js/containers/SecuritiesTabContainer.js @@ -11,8 +11,14 @@ function mapStateToProps(state) { && state.accounts.map[accountId].SecurityId == state.selectedSecurity) selectedSecurityAccounts.push(state.accounts.map[accountId]); } + var security_list = []; + for (var securityId in state.securities) { + if (state.securities.hasOwnProperty(securityId)) + security_list.push(state.securities[securityId]); + } return { securities: state.securities, + security_list: security_list, selectedSecurityAccounts: selectedSecurityAccounts, selectedSecurity: state.selectedSecurity, securityTemplates: state.securityTemplates diff --git a/static/css/stylesheet.css b/static/css/stylesheet.css index 9da7490..9cf2da4 100644 --- a/static/css/stylesheet.css +++ b/static/css/stylesheet.css @@ -63,7 +63,7 @@ div.accounttree-root div { height: 100%-100px; overflow: auto; } -.account-column, .securitylist-column { +.account-column { padding: 15px 15px 43px 15px; border-right: 1px solid #DDD; border-left: 1px solid #DDD; @@ -84,7 +84,7 @@ div.accounttree-root div { height: 100%; overflow: auto; } -.transactions-column, .securities-column { +.transactions-column { padding: 15px; border-right: 1px solid #DDD; }