// Import all the objects we want to use from ReactBootstrap var ListGroup = ReactBootstrap.ListGroup; var ListGroupItem = ReactBootstrap.ListGroupItem; var Grid = ReactBootstrap.Grid; var Row = ReactBootstrap.Row; var Col = ReactBootstrap.Col; var Button = ReactBootstrap.Button; var ButtonGroup = ReactBootstrap.ButtonGroup; var Glyphicon = ReactBootstrap.Glyphicon; var Modal = ReactBootstrap.Modal; var Combobox = ReactWidgets.Combobox; const recursiveAccountDisplayInfo = function(account, prefix) { var name = prefix + account.Name; var accounts = [{AccountId: account.AccountId, Name: name}]; for (var i = 0; i < account.Children.length; i++) accounts = accounts.concat(recursiveAccountDisplayInfo(account.Children[i], name + "/")); return accounts }; const getAccountDisplayList = function(account_list, includeRoot, rootName) { var accounts = [] if (includeRoot) accounts.push({AccountId: -1, Name: rootName}); for (var i = 0; i < account_list.length; i++) { if (account_list[i].ParentAccountId == -1) accounts = accounts.concat(recursiveAccountDisplayInfo(account_list[i], "")); } return accounts; }; const AccountCombobox = React.createClass({ handleAccountChange: function(account) { if (this.props.onSelect != null && account.hasOwnProperty('AccountId') && this.props.account_map.hasOwnProperty([account.AccountId])) { this.props.onSelect(this.props.account_map[account.AccountId]) } }, render: function() { var accounts = getAccountDisplayList(this.props.accounts, true, "New Root Account"); return ( ); } }); const NewAccountModal = React.createClass({ getInitialState: function() { return { security: 1, parentaccountid: -1, type: 1, name: "" }; }, handleCancel: function() { if (this.props.onCancel != null) this.props.onCancel(); }, handleChange: function() { this.setState({ name: this.refs.name.getValue(), }); }, handleSecurityChange: function(security) { if (security.hasOwnProperty('SecurityId')) this.setState({ security: security.SecurityId }); }, handleTypeChange: function(type) { if (type.hasOwnProperty('TypeId')) this.setState({ type: type.TypeId }); }, handleParentChange: function(parentAccount) { this.setState({parentaccountid: parentAccount.AccountId}); }, handleSubmit: function() { var a = new Account(); a.Name = this.state.name; a.ParentAccountId = this.state.parentaccountid; a.SecurityId = this.state.security; a.Type = this.state.type; this.handleSaveSettings(a); }, handleSaveSettings: function(account) { if (this.props.onSubmit != null) this.props.onSubmit(account); }, render: function() { return ( Create New Account
); } }); const AccountsTab = React.createClass({ getInitialState: function() { return { creatingNewAccount: false }; }, handleNewAccount: function() { this.setState({creatingNewAccount: true}); }, handleEditAccount: function() { console.log("handleEditAccount"); }, handleDeleteAccount: function() { console.log("handleDeleteAccount"); }, handleCreationCancel: function() { this.setState({creatingNewAccount: false}); }, handleCreateAccount: function(account) { if (this.props.onCreateAccount != null) this.props.onCreateAccount(account); this.setState({creatingNewAccount: false}); }, render: function() { var accounts = this.props.accounts; var account_map = this.props.account_map; var listGroupItems = accounts.map(function(account) { return ( {account.Name} ); }); return ( {listGroupItems} blah ); } });