From 5ff45cd4b44156bdaa98c866711fb793b8bddbdc Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Tue, 27 Sep 2016 11:30:39 -0400 Subject: [PATCH] Update everything for latest version of React --- Makefile | 2 +- js/AccountRegister.js | 120 +++++++++++++++++++---------------- js/AccountSettingsModal.js | 95 ++++++++++++++++------------ js/AccountsTab.js | 126 +++++++++++++++++++------------------ js/NewUserForm.js | 98 ++++++++++++++++------------- js/TopBar.js | 29 +++++---- 6 files changed, 256 insertions(+), 214 deletions(-) diff --git a/Makefile b/Makefile index d041b28..911a49c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -JS_SOURCES = $(wildcard js/*.js) +JS_SOURCES = $(wildcard js/*.js) $(wildcard js/*/*.js) all: static/bundle.js static/react-widgets diff --git a/js/AccountRegister.js b/js/AccountRegister.js index 073183d..936c86c 100644 --- a/js/AccountRegister.js +++ b/js/AccountRegister.js @@ -13,7 +13,12 @@ var Grid = ReactBootstrap.Grid; var Row = ReactBootstrap.Row; var Col = ReactBootstrap.Col; var Panel = ReactBootstrap.Panel; -var Input = ReactBootstrap.Input; +var Form = ReactBootstrap.Form; +var FormGroup = ReactBootstrap.FormGroup; +var FormControl = ReactBootstrap.FormControl; +var InputGroup = ReactBootstrap.InputGroup; +var ControlLabel = ReactBootstrap.ControlLabel; +var HelpBlock = ReactBootstrap.HelpBlock; var Button = ReactBootstrap.Button; var ButtonGroup = ReactBootstrap.ButtonGroup; var ButtonToolbar = ReactBootstrap.ButtonToolbar; @@ -127,7 +132,7 @@ const AmountInput = React.createClass({ } }, componentDidMount: function() { - this.refs.amount.getInputDOMNode().onblur = this.onBlur; + ReactDOM.findDOMNode(this.refs.amount).onblur = this.onBlur; }, onBlur: function() { var a; @@ -140,13 +145,13 @@ const AmountInput = React.createClass({ }); }, onChange: function() { - this.setState({Amount: this.refs.amount.getValue()}); + this.setState({Amount: ReactDOM.findDOMNode(this.refs.amount).value}); if (this.props.onChange) this.props.onChange(); }, getValue: function() { try { - var value = this.refs.amount.getValue(); + var value = ReactDOM.findDOMNode(this.refs.amount).value; var ret = new Big(value); this.setState({LastGoodAmount: value}); return ret; @@ -158,17 +163,17 @@ const AmountInput = React.createClass({ var symbol = "?"; if (this.props.security) symbol = this.props.security.Symbol; - var bsStyle = undefined; - if (this.props.bsStyle) - bsStyle = this.props.bsStyle; return ( - + + + {symbol} + + + ); } }); @@ -197,7 +202,7 @@ const AddEditTransactionModal = React.createClass({ handleDescriptionChange: function() { this.setState({ transaction: react_update(this.state.transaction, { - Description: {$set: this.refs.description.getValue()} + Description: {$set: ReactDOM.findDOMNode(this.refs.description).value} }) }); }, @@ -236,7 +241,7 @@ const AddEditTransactionModal = React.createClass({ handleUpdateNumber: function(split) { var transaction = this.state.transaction; transaction.Splits[split] = react_update(transaction.Splits[split], { - Number: {$set: this.refs['number-'+split].getValue()} + Number: {$set: ReactDOM.findDOMNode(this.refs['number-'+split]).value} }); this.setState({ transaction: transaction @@ -245,7 +250,7 @@ const AddEditTransactionModal = React.createClass({ handleUpdateMemo: function(split) { var transaction = this.state.transaction; transaction.Splits[split] = react_update(transaction.Splits[split], { - Memo: {$set: this.refs['memo-'+split].getValue()} + Memo: {$set: ReactDOM.findDOMNode(this.refs['memo-'+split]).value} }); this.setState({ transaction: transaction @@ -363,12 +368,12 @@ const AddEditTransactionModal = React.createClass({ splits.push(( - - + validationState={amountValidation}/> {deleteSplitButton} )); @@ -398,36 +403,39 @@ const AddEditTransactionModal = React.createClass({ {headerText} Transaction -
- - - - - - - + + + Date + + + + + + Description + + + + + + Status + + + + + # Memo @@ -443,7 +451,7 @@ const AddEditTransactionModal = React.createClass({ {this.state.errorAlert} - +
@@ -485,7 +493,7 @@ const ImportTransactionsModal = React.createClass({ this.props.onCancel(); }, handleImportChange: function() { - this.setState({importFile: this.refs.importfile.getValue()}); + this.setState({importFile: ReactDOM.findDOMNode(this.refs.importfile).value}); }, handleTypeChange: function(type) { this.setState({importType: type.TypeId}); @@ -612,13 +620,15 @@ const ImportTransactionsModal = React.createClass({ defaultValue={this.state.importType} disabled={disabledTypes} ref="importtype" /> - + {accountNameLabel} + + Select an OFX/QFX file to upload. + {progressBar} {panel} @@ -918,7 +928,7 @@ module.exports = React.createClass({ {this.state.error} -
- - + + Name + + + + + + Username + + - + + + + Email + + - + + + + Password + + - + + + + + Confirm Password + + - + ref="confirm_password"/> + + +
+
diff --git a/js/AccountsTab.js b/js/AccountsTab.js index af6b899..3a7478b 100644 --- a/js/AccountsTab.js +++ b/js/AccountsTab.js @@ -5,7 +5,10 @@ var ReactBootstrap = require('react-bootstrap'); var Grid = ReactBootstrap.Grid; var Row = ReactBootstrap.Row; var Col = ReactBootstrap.Col; -var Input = ReactBootstrap.Input; +var Form = ReactBootstrap.Form; +var FormGroup = ReactBootstrap.FormGroup; +var FormControl = ReactBootstrap.FormControl; +var ControlLabel = ReactBootstrap.ControlLabel; var Button = ReactBootstrap.Button; var ButtonGroup = ReactBootstrap.ButtonGroup; var Glyphicon = ReactBootstrap.Glyphicon; @@ -54,7 +57,7 @@ const AddEditAccountModal = React.createClass({ }, handleChange: function() { this.setState({ - name: this.refs.name.getValue(), + name: ReactDOM.findDOMNode(this.refs.name).value, }); }, handleSecurityChange: function(security) { @@ -100,52 +103,53 @@ const AddEditAccountModal = React.createClass({ {headerText} Account -
- - - - - - item.Name + " - " + item.Description} - defaultValue={this.state.security} - onChange={this.handleSecurityChange} - ref="security" /> - - - - - +
+ + Name + + + + + + Parent Account + + + + + + Security + + item.Name + " - " + item.Description} + defaultValue={this.state.security} + onChange={this.handleSecurityChange} + ref="security" /> + + + + Account Type + + + + +
@@ -208,12 +212,13 @@ const DeleteAccountModal = React.createClass({ parentAccount = "and any child accounts will be re-parented to: " + this.props.account_map[parentAccountId].Name; var warningString = "I understand that deleting this account cannot be undone and that all transactions " + parentAccount; - checkbox = (); + checkbox = ( + + {warningString} + ); } var warning = []; if (this.state.error.length != "") { @@ -232,21 +237,18 @@ const DeleteAccountModal = React.createClass({ {warning} -
- + + + Delete Account - {checkbox} - +
+
diff --git a/js/NewUserForm.js b/js/NewUserForm.js index 618483c..79e33a5 100644 --- a/js/NewUserForm.js +++ b/js/NewUserForm.js @@ -1,9 +1,15 @@ var React = require('react'); +var ReactDOM = require('react-dom'); -var Panel = require('react-bootstrap').Panel; -var Input = require('react-bootstrap').Input; -var Button = require('react-bootstrap').Button; -var ButtonGroup = require('react-bootstrap').ButtonGroup; +var ReactBootstrap = require('react-bootstrap'); +var Panel = ReactBootstrap.Panel; +var Form = ReactBootstrap.Form; +var FormGroup = ReactBootstrap.FormGroup; +var FormControl = ReactBootstrap.FormControl; +var ControlLabel = ReactBootstrap.ControlLabel; +var Col = ReactBootstrap.Col; +var Button = ReactBootstrap.Button; +var ButtonGroup = ReactBootstrap.ButtonGroup; var models = require('./models.js'); var User = models.User; @@ -43,14 +49,14 @@ module.exports = React.createClass({ this.props.onCancel(); }, handleChange: function() { - if (this.refs.password.getValue() != this.state.initial_password) + if (ReactDOM.findDOMNode(this.refs.password).value != this.state.initial_password) this.setState({passwordChanged: true}); this.setState({ - name: this.refs.name.getValue(), - username: this.refs.username.getValue(), - email: this.refs.email.getValue(), - password: this.refs.password.getValue(), - confirm_password: this.refs.confirm_password.getValue() + name: ReactDOM.findDOMNode(this.refs.name).value, + username: ReactDOM.findDOMNode(this.refs.username).value, + email: ReactDOM.findDOMNode(this.refs.email).value, + password: ReactDOM.findDOMNode(this.refs.password).value, + confirm_password: ReactDOM.findDOMNode(this.refs.confirm_password).value }); }, handleSubmit: function(e) { @@ -97,54 +103,62 @@ module.exports = React.createClass({ return ( {this.state.error} -
- + + Name + + - + + + + Username + + - + + + + Email + + - + + + + Password + + - + + + + + Confirm Password + + + ref="confirm_password"/> + + + + -
+
); } diff --git a/js/TopBar.js b/js/TopBar.js index f763978..cf21125 100644 --- a/js/TopBar.js +++ b/js/TopBar.js @@ -2,13 +2,16 @@ var React = require('react'); var ReactBootstrap = require('react-bootstrap'); var Alert = ReactBootstrap.Alert; -var Input = ReactBootstrap.Input; +var FormGroup = ReactBootstrap.FormGroup; +var FormControl = ReactBootstrap.FormControl; var Button = ReactBootstrap.Button; var DropdownButton = ReactBootstrap.DropdownButton; var MenuItem = ReactBootstrap.MenuItem; var Row = ReactBootstrap.Row; var Col = ReactBootstrap.Col; +var ReactDOM = require('react-dom'); + var User = require('./models.js').User; const LoginBar = React.createClass({ @@ -24,8 +27,8 @@ const LoginBar = React.createClass({ handleSubmit: function(e) { var user = new User(); e.preventDefault(); - user.Username = this.refs.username.getValue(); - user.Password = this.refs.password.getValue(); + user.Username = ReactDOM.findDOMNode(this.refs.username).value; + user.Password = ReactDOM.findDOMNode(this.refs.password).value; this.props.onLoginSubmit(user); }, handleNewUserSubmit: function(e) { @@ -35,7 +38,7 @@ const LoginBar = React.createClass({ render: function() { return (
- + @@ -43,28 +46,28 @@ const LoginBar = React.createClass({ onClick={this.handleNewUserSubmit}>Create New User - - + ref="password"/> - +
); } }); const LogoutBar = React.createClass({ - handleOnSelect: function(e, key) { + handleOnSelect: function(key) { if (key == 1) { if (this.props.onAccountSettings != null) this.props.onAccountSettings(); @@ -75,20 +78,20 @@ const LogoutBar = React.createClass({ render: function() { var signedInString = "Signed in as "+this.props.user.Name; return ( - +
- Account Settings - Logout + Account Settings + Logout
- +
); } });