From da7fbeecafa9112990c82852c8b0233dbe46ead6 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sat, 13 Feb 2016 16:31:12 -0500 Subject: [PATCH] Move models.js to browserify/require() format --- static/AccountRegister.js | 10 ++++++++++ static/AccountSettingsModal.js | 21 +++++++++++++-------- static/AccountsTab.js | 5 +++++ static/MoneyGoApp.js | 7 +++++++ static/NewUserForm.js | 4 ++++ static/TopBar.js | 2 ++ static/index.html | 1 - static/models.js | 26 ++++++++++++++++++++++++-- 8 files changed, 65 insertions(+), 11 deletions(-) diff --git a/static/AccountRegister.js b/static/AccountRegister.js index fcf8b37..d831823 100644 --- a/static/AccountRegister.js +++ b/static/AccountRegister.js @@ -23,6 +23,16 @@ var Glyphicon = ReactBootstrap.Glyphicon; var DateTimePicker = require('react-widgets').DateTimePicker; var Combobox = require('react-widgets').Combobox; +var models = require('./models.js'); +var Security = models.Security; +var Account = models.Account; +var Split = models.Split; +var Transaction = models.Transaction; +var TransactionStatus = models.TransactionStatus; +var TransactionStatusList = models.TransactionStatusList; +var TransactionStatusMap = models.TransactionStatusMap; +var Error = models.Error; + var AccountCombobox = require('./AccountCombobox.js'); const TransactionRow = React.createClass({ diff --git a/static/AccountSettingsModal.js b/static/AccountSettingsModal.js index 99d41fe..6330830 100644 --- a/static/AccountSettingsModal.js +++ b/static/AccountSettingsModal.js @@ -1,9 +1,14 @@ var React = require('react'); -var Modal = require('react-bootstrap').Modal; -var Button = require('react-bootstrap').Button; -var ButtonGroup = require('react-bootstrap').ButtonGroup; -var Input = require('react-bootstrap').Input; +var ReactBootstrap = require('react-bootstrap'); +var Modal = ReactBootstrap.Modal; +var Button = ReactBootstrap.Button; +var ButtonGroup = ReactBootstrap.ButtonGroup; +var Input = ReactBootstrap.Input; + +var models = require('./models.js'); +var User = models.User; +var Error = models.Error; module.exports = React.createClass({ displayName: "AccountSettingsModal", @@ -12,10 +17,10 @@ module.exports = React.createClass({ name: props.user.Name, username: props.user.Username, email: props.user.Email, - password: BogusPassword, - confirm_password: BogusPassword, + password: models.BogusPassword, + confirm_password: models.BogusPassword, passwordChanged: false, - initial_password: BogusPassword}; + initial_password: models.BogusPassword}; }, getInitialState: function() { return this._getInitialState(this.props); @@ -74,7 +79,7 @@ module.exports = React.createClass({ return; } } else { - u.Password = BogusPassword; + u.Password = models.BogusPassword; } this.handleSaveSettings(u); diff --git a/static/AccountsTab.js b/static/AccountsTab.js index 92bb060..6dadf0c 100644 --- a/static/AccountsTab.js +++ b/static/AccountsTab.js @@ -18,6 +18,11 @@ var Collapse = ReactBootstrap.Collapse; var Combobox = require('react-widgets').Combobox; +var models = require('./models.js'); +var Security = models.Security; +var Account = models.Account; +var AccountTypeList = models.AccountTypeList; + var AccountCombobox = require('./AccountCombobox.js'); var AccountRegister = require('./AccountRegister.js'); diff --git a/static/MoneyGoApp.js b/static/MoneyGoApp.js index 75c42ef..b380b55 100644 --- a/static/MoneyGoApp.js +++ b/static/MoneyGoApp.js @@ -6,6 +6,13 @@ var Tabs = ReactBootstrap.Tabs; var Tab = ReactBootstrap.Tab; var Modal = ReactBootstrap.Modal; +var models = require('./models.js'); +var User = models.User; +var Session = models.Session; +var Security = models.Security; +var Account = models.Account; +var Error = models.Error; + var TopBar = require('./TopBar.js'); var NewUserForm = require('./NewUserForm.js'); var AccountSettingsModal = require('./AccountSettingsModal.js'); diff --git a/static/NewUserForm.js b/static/NewUserForm.js index 22a3d2e..618483c 100644 --- a/static/NewUserForm.js +++ b/static/NewUserForm.js @@ -5,6 +5,10 @@ var Input = require('react-bootstrap').Input; var Button = require('react-bootstrap').Button; var ButtonGroup = require('react-bootstrap').ButtonGroup; +var models = require('./models.js'); +var User = models.User; +var Error = models.Error; + module.exports = React.createClass({ getInitialState: function() { return {error: "", diff --git a/static/TopBar.js b/static/TopBar.js index 766ff5c..f763978 100644 --- a/static/TopBar.js +++ b/static/TopBar.js @@ -9,6 +9,8 @@ var MenuItem = ReactBootstrap.MenuItem; var Row = ReactBootstrap.Row; var Col = ReactBootstrap.Col; +var User = require('./models.js').User; + const LoginBar = React.createClass({ getInitialState: function() { return {username: '', password: ''}; diff --git a/static/index.html b/static/index.html index 4723ac2..4e0d5b0 100644 --- a/static/index.html +++ b/static/index.html @@ -12,7 +12,6 @@ - diff --git a/static/models.js b/static/models.js index 9ef84b5..299c5f0 100644 --- a/static/models.js +++ b/static/models.js @@ -16,8 +16,6 @@ function User() { this.Email = ""; } -const BogusPassword = "password"; - User.prototype.toJSON = function() { var json_obj = {}; json_obj.UserId = this.UserId; @@ -385,3 +383,27 @@ Error.prototype.isError = function() { return this.ErrorId != empty_error.ErrorId || this.ErrorString != empty_error.ErrorString; } + +module.exports = models = { + + // Classes + User: User, + Session: Session, + Security: Security, + Account: Account, + Split: Split, + Transaction: Transaction, + Error: Error, + + // Enums, Lists + AccountType: AccountType, + AccountTypeList: AccountTypeList, + SecurityType: SecurityType, + SecurityTypeList: SecurityTypeList, + TransactionStatus: TransactionStatus, + TransactionStatusList: TransactionStatusList, + TransactionStatusMap: TransactionStatusMap, + + // Constants + BogusPassword: "password" +};