1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-09-21 04:10:05 -04:00
moneygo/js/components/AccountsTab.js

742 lines
22 KiB
JavaScript
Raw Normal View History

var React = require('react');
var ReactDOM = require('react-dom');
var ReactBootstrap = require('react-bootstrap');
var Grid = ReactBootstrap.Grid;
var Row = ReactBootstrap.Row;
var Col = ReactBootstrap.Col;
var Form = ReactBootstrap.Form;
var FormGroup = ReactBootstrap.FormGroup;
var FormControl = ReactBootstrap.FormControl;
var Checkbox = ReactBootstrap.Checkbox;
var ControlLabel = ReactBootstrap.ControlLabel;
var Button = ReactBootstrap.Button;
var ButtonGroup = ReactBootstrap.ButtonGroup;
var Glyphicon = ReactBootstrap.Glyphicon;
var ListGroup = ReactBootstrap.ListGroup;
var ListGroupItem = ReactBootstrap.ListGroupItem;
2016-02-13 10:46:08 -05:00
var Alert = ReactBootstrap.Alert;
var Modal = ReactBootstrap.Modal;
var Collapse = ReactBootstrap.Collapse;
2017-05-31 21:04:01 -04:00
var Tabs = ReactBootstrap.Tabs;
var Tab = ReactBootstrap.Tab;
var Panel = ReactBootstrap.Panel;
var Combobox = require('react-widgets').Combobox;
2015-07-04 11:42:52 -04:00
var models = require('../models');
var Security = models.Security;
var Account = models.Account;
2017-05-31 21:04:01 -04:00
var AccountType = models.AccountType;
var AccountTypeList = models.AccountTypeList;
var AccountCombobox = require('./AccountCombobox');
var AccountRegister = require('./AccountRegister');
class AddEditAccountModal extends React.Component {
getInitialState(props) {
2015-07-04 21:55:49 -04:00
var s = {
accountid: -1,
security: 1,
parentaccountid: -1,
type: 1,
2017-05-31 21:04:01 -04:00
name: "",
ofxurl: "",
ofxorg: "",
ofxfid: "",
ofxuser: "",
ofxbankid: "",
ofxacctid: "",
ofxaccttype: "CHECKING",
ofxclientuid: "",
ofxappid: "",
ofxappver: "",
ofxversion: "",
ofxnoindent: false,
};
if (!props) {
return s;
} else if (props.editAccount != null) {
s.accountid = props.editAccount.AccountId;
s.name = props.editAccount.Name;
s.security = props.editAccount.SecurityId;
s.parentaccountid = props.editAccount.ParentAccountId;
s.type = props.editAccount.Type;
s.ofxurl = props.editAccount.OFXURL;
s.ofxorg = props.editAccount.OFXORG;
s.ofxfid = props.editAccount.OFXFID;
s.ofxuser = props.editAccount.OFXUser;
s.ofxbankid = props.editAccount.OFXBankID;
s.ofxacctid = props.editAccount.OFXAcctID;
s.ofxaccttype = props.editAccount.OFXAcctType;
s.ofxclientuid = props.editAccount.OFXClientUID;
s.ofxappid = props.editAccount.OFXAppID;
s.ofxappver = props.editAccount.OFXAppVer;
s.ofxversion = props.editAccount.OFXVersion;
s.ofxnoindent = props.editAccount.OFXNoIndent;
} else if (props.initialParentAccount != null) {
s.security = props.initialParentAccount.SecurityId;
s.parentaccountid = props.initialParentAccount.AccountId;
s.type = props.initialParentAccount.Type;
2015-07-04 21:55:49 -04:00
}
return s;
}
constructor() {
super();
this.state = this.getInitialState();
this.onCancel = this.handleCancel.bind(this);
this.onChange = this.handleChange.bind(this);
this.onNoIndentClick = this.handleNoIndentClick.bind(this);
this.onSecurityChange = this.handleSecurityChange.bind(this);
this.onTypeChange = this.handleTypeChange.bind(this);
this.onParentChange = this.handleParentChange.bind(this);
this.onSubmit = this.handleSubmit.bind(this);
}
componentWillReceiveProps(nextProps) {
if (nextProps.show && !this.props.show) {
this.setState(this.getInitialState(nextProps));
}
}
handleCancel() {
if (this.props.onCancel != null)
this.props.onCancel();
}
handleChange() {
this.setState({
name: ReactDOM.findDOMNode(this.refs.name).value,
2017-05-31 21:04:01 -04:00
ofxurl: ReactDOM.findDOMNode(this.refs.ofxurl).value,
ofxorg: ReactDOM.findDOMNode(this.refs.ofxorg).value,
ofxfid: ReactDOM.findDOMNode(this.refs.ofxfid).value,
ofxuser: ReactDOM.findDOMNode(this.refs.ofxuser).value,
ofxbankid: ReactDOM.findDOMNode(this.refs.ofxbankid).value,
ofxacctid: ReactDOM.findDOMNode(this.refs.ofxacctid).value,
ofxaccttype: ReactDOM.findDOMNode(this.refs.ofxaccttype).value,
ofxclientuid: ReactDOM.findDOMNode(this.refs.ofxclientuid).value,
ofxappid: ReactDOM.findDOMNode(this.refs.ofxappid).value,
ofxappver: ReactDOM.findDOMNode(this.refs.ofxappver).value,
ofxversion: ReactDOM.findDOMNode(this.refs.ofxversion).value,
});
}
2017-05-31 21:04:01 -04:00
handleNoIndentClick() {
2017-05-31 21:04:01 -04:00
this.setState({ofxnoindent: !this.state.ofxnoindent});
}
handleSecurityChange(security) {
if (security.hasOwnProperty('SecurityId'))
this.setState({
security: security.SecurityId
});
}
handleTypeChange(type) {
if (type.hasOwnProperty('TypeId'))
this.setState({
type: type.TypeId
});
}
handleParentChange(parentAccount) {
this.setState({parentaccountid: parentAccount.AccountId});
}
handleSubmit() {
var a = new Account();
2015-07-04 21:55:49 -04:00
if (this.props.editAccount != null)
a.AccountId = this.state.accountid;
a.Name = this.state.name;
a.ParentAccountId = this.state.parentaccountid;
a.SecurityId = this.state.security;
a.Type = this.state.type;
2017-05-31 21:04:01 -04:00
a.OFXURL = this.state.ofxurl;
a.OFXORG = this.state.ofxorg;
a.OFXFID = this.state.ofxfid;
a.OFXUser = this.state.ofxuser;
a.OFXBankID = this.state.ofxbankid;
a.OFXAcctID = this.state.ofxacctid;
a.OFXAcctType = this.state.ofxaccttype;
a.OFXClientUID = this.state.ofxclientuid;
a.OFXAppID = this.state.ofxappid;
a.OFXAppVer = this.state.ofxappver;
a.OFXVersion = this.state.ofxversion;
2017-06-04 16:01:42 -04:00
a.OFXNoIndent = this.state.ofxnoindent;
2017-05-31 21:04:01 -04:00
if (this.props.onSubmit != null)
2015-07-04 21:55:49 -04:00
this.props.onSubmit(a);
}
render() {
2015-07-04 21:55:49 -04:00
var headerText = (this.props.editAccount != null) ? "Edit" : "Create New";
var buttonText = (this.props.editAccount != null) ? "Save Changes" : "Create Account";
2015-07-04 21:55:49 -04:00
var rootName = (this.props.editAccount != null) ? "Top-level Account" : "New Top-level Account";
2017-05-31 21:04:01 -04:00
var ofxBankIdName = "Broker ID";
var ofxAcctType = [];
if (this.state.type != AccountType.Investment) {
ofxBankIdName = "Bank ID";
ofxAcctType = (
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Account Type</Col>
<Col xs={10}>
<FormControl
componentClass="select"
placeholder="select"
value={this.state.ofxaccttype}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxaccttype">
<option value="CHECKING">Checking</option>
<option value="SAVINGS">Savings</option>
2017-06-04 16:01:42 -04:00
<option value="CC">Credit Card</option>
2017-05-31 21:04:01 -04:00
<option value="MONEYMRKT">Money Market</option>
<option value="CREDITLINE">Credit Line</option>
<option value="CD">CD</option>
</FormControl>
</Col>
</FormGroup>
);
}
var bankIdDisabled = (this.state.type != AccountType.Investment && this.state.ofxaccttype == "CC") ? true : false;
return (
<Modal show={this.props.show} onHide={this.onCancel}>
<Modal.Header closeButton>
2015-07-04 21:55:49 -04:00
<Modal.Title>{headerText} Account</Modal.Title>
</Modal.Header>
<Modal.Body>
2017-05-31 21:04:01 -04:00
<Tabs defaultActiveKey={1} id="editAccountTabs">
<Tab eventKey={1} title="General">
<Form horizontal onSubmit={this.onSubmit}>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Name</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.name}
onChange={this.onChange}
ref="name"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Parent Account</Col>
<Col xs={10}>
<AccountCombobox
accounts={this.props.accounts}
2016-10-05 13:36:47 -04:00
accountChildren={this.props.accountChildren}
value={this.state.parentaccountid}
rootName={rootName}
onChange={this.onParentChange}
ref="parent" />
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Security</Col>
<Col xs={10}>
<Combobox
suggest
2016-10-05 13:36:47 -04:00
data={this.props.security_list}
valueField='SecurityId'
textField={item => typeof item === 'string' ? item : item.Name + " - " + item.Description}
defaultValue={this.state.security}
onChange={this.onSecurityChange}
ref="security" />
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Account Type</Col>
<Col xs={10}>
<Combobox
suggest
data={AccountTypeList}
valueField='TypeId'
textField='Name'
defaultValue={this.state.type}
onChange={this.onTypeChange}
ref="type" />
</Col>
</FormGroup>
2017-05-31 21:04:01 -04:00
</Form>
</Tab>
<Tab eventKey={2} title="Sync (OFX)">
<Form horizontal onSubmit={this.onSubmit}>
2017-05-31 21:04:01 -04:00
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>OFX URL</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxurl}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxurl"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>ORG</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxorg}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxorg"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>FID</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxfid}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxfid"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Username</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxuser}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxuser"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>{ofxBankIdName}</Col>
<Col xs={10}>
<FormControl type="text"
disabled={bankIdDisabled}
2017-05-31 21:04:01 -04:00
value={this.state.ofxbankid}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxbankid"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Account ID</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxacctid}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxacctid"/>
</Col>
</FormGroup>
{ofxAcctType}
<Panel collapsible header="Advanced Settings">
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Client UID</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxclientuid}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxclientuid"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>App ID</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxappid}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxappid"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>App Version</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxappver}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxappver"/>
</Col>
</FormGroup>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>OFX Version</Col>
<Col xs={10}>
<FormControl type="text"
value={this.state.ofxversion}
onChange={this.onChange}
2017-05-31 21:04:01 -04:00
ref="ofxversion"/>
</Col>
</FormGroup>
<FormGroup>
<Col xsOffset={2} xs={10}>
<Checkbox
checked={this.state.ofxnoindent ? "checked" : ""}
onClick={this.onNoIndentClick}>
2017-05-31 21:04:01 -04:00
Don't indent OFX request files
</Checkbox>
</Col>
</FormGroup>
</Panel>
</Form>
</Tab>
</Tabs>
</Modal.Body>
<Modal.Footer>
<ButtonGroup className="pull-right">
<Button onClick={this.onCancel} bsStyle="warning">Cancel</Button>
<Button onClick={this.onSubmit} bsStyle="success">{buttonText}</Button>
</ButtonGroup>
</Modal.Footer>
</Modal>
);
}
}
class DeleteAccountModal extends React.Component {
getInitialState(props) {
if (!props)
var accountid = -1;
else if (props.initialAccount != null)
var accountid = props.initialAccount.AccountId;
else if (props.accounts.length > 0)
var accountid = props.accounts[0].AccountId;
2015-07-04 21:11:00 -04:00
else
var accountid = -1;
return {
error: "",
2015-07-04 21:11:00 -04:00
accountid: accountid,
checked: false,
show: false
};
}
constructor() {
super();
this.state = this.getInitialState();
this.onCancel = this.handleCancel.bind(this);
this.onChange = this.handleChange.bind(this);
this.onCheckboxClick = this.handleCheckboxClick.bind(this);
this.onSubmit = this.handleSubmit.bind(this);
}
componentWillReceiveProps(nextProps) {
if (nextProps.show && !this.props.show) {
this.setState(this.getInitialState(nextProps));
}
}
handleCancel() {
2015-07-04 21:11:00 -04:00
if (this.props.onCancel != null)
this.props.onCancel();
}
handleChange(account) {
2015-07-04 21:11:00 -04:00
this.setState({accountid: account.AccountId});
}
handleCheckboxClick() {
2015-07-04 21:11:00 -04:00
this.setState({checked: !this.state.checked});
}
handleSubmit() {
2016-10-05 13:36:47 -04:00
if (this.props.accounts.hasOwnProperty(this.state.accountid)) {
2015-07-04 21:11:00 -04:00
if (this.state.checked) {
if (this.props.onSubmit != null)
2016-10-05 13:36:47 -04:00
this.props.onSubmit(this.props.accounts[this.state.accountid]);
2015-07-04 21:11:00 -04:00
} else {
this.setState({error: "You must confirm you wish to delete this account."});
}
} else {
this.setState({error: "You must select an account."});
}
}
render() {
2015-07-04 21:11:00 -04:00
var checkbox = [];
2016-10-05 13:36:47 -04:00
if (this.props.accounts.hasOwnProperty(this.state.accountid)) {
var parentAccountId = this.props.accounts[this.state.accountid].ParentAccountId;
2015-07-04 21:11:00 -04:00
var parentAccount = "will be deleted and any child accounts will become top-level accounts.";
if (parentAccountId != -1)
2016-10-05 13:36:47 -04:00
parentAccount = "and any child accounts will be re-parented to: " + this.props.accounts[parentAccountId].Name;
2015-07-04 21:11:00 -04:00
var warningString = "I understand that deleting this account cannot be undone and that all transactions " + parentAccount;
checkbox = (
<FormGroup>
<Col xsOffset={2} sm={10}>
<Checkbox
checked={this.state.checked ? "checked" : ""}
onClick={this.onCheckboxClick}>
{warningString}
</Checkbox>
</Col>
</FormGroup>);
2015-07-04 21:11:00 -04:00
}
var warning = [];
if (this.state.error.length != "") {
warning = (
<Alert bsStyle="danger"><strong>Error: </strong>{this.state.error}</Alert>
);
}
return (
<Modal
show={this.props.show}
onHide={this.onCancel}
ref="modal">
2015-07-04 21:11:00 -04:00
<Modal.Header closeButton>
<Modal.Title>Delete Account</Modal.Title>
</Modal.Header>
<Modal.Body>
{warning}
<Form horizontal onSubmit={this.onSubmit}>
<FormGroup>
<Col componentClass={ControlLabel} xs={2}>Delete Account</Col>
<Col xs={10}>
<AccountCombobox
includeRoot={false}
accounts={this.props.accounts}
2016-10-05 13:36:47 -04:00
accountChildren={this.props.accountChildren}
value={this.state.accountid}
onChange={this.onChange}/>
</Col>
</FormGroup>
{checkbox}
</Form>
2015-07-04 21:11:00 -04:00
</Modal.Body>
<Modal.Footer>
<ButtonGroup className="pull-right">
<Button onClick={this.onCancel} bsStyle="warning">Cancel</Button>
<Button onClick={this.onSubmit} bsStyle="success">Delete Account</Button>
2015-07-04 21:11:00 -04:00
</ButtonGroup>
</Modal.Footer>
</Modal>
);
}
}
2015-07-04 21:11:00 -04:00
class AccountTreeNode extends React.Component {
constructor() {
super();
this.state = {expanded: false};
this.onToggle = this.handleToggle.bind(this);
this.onChildSelect = this.handleChildSelect.bind(this);
this.onSelect = this.handleSelect.bind(this);
}
handleToggle(e) {
2015-07-04 11:42:52 -04:00
e.preventDefault();
this.setState({expanded:!this.state.expanded});
}
handleChildSelect(account) {
2015-07-04 11:42:52 -04:00
if (this.props.onSelect != null)
this.props.onSelect(account);
}
handleSelect() {
2015-07-04 11:42:52 -04:00
if (this.props.onSelect != null)
this.props.onSelect(this.props.account);
}
render() {
var glyph = this.state.expanded ? 'minus' : 'plus';
2016-10-05 13:36:47 -04:00
var active = (this.props.selectedAccount != -1 &&
this.props.account.AccountId == this.props.selectedAccount);
2015-07-04 11:42:52 -04:00
var buttonStyle = active ? "info" : "link";
var self = this;
2016-10-05 13:36:47 -04:00
var children = this.props.accountChildren[this.props.account.AccountId].map(function(childId) {
var account = self.props.accounts[childId];
2015-07-04 11:42:52 -04:00
return (
<AccountTreeNode
2016-02-13 10:19:28 -05:00
key={account.AccountId}
2015-07-04 11:42:52 -04:00
account={account}
selectedAccount={self.props.selectedAccount}
2016-10-05 13:36:47 -04:00
accounts={self.props.accounts}
accountChildren={self.props.accountChildren}
onSelect={self.onChildSelect}/>
2015-07-04 11:42:52 -04:00
);
});
var accounttreeClasses = "accounttree"
var expandButton = [];
if (children.length > 0) {
2015-07-04 11:42:52 -04:00
expandButton.push((
<Button onClick={this.onToggle}
2016-02-13 10:19:28 -05:00
key={1}
2015-07-04 11:42:52 -04:00
bsSize="xsmall"
bsStyle="link"
className="accounttree-expandbutton">
<Glyphicon glyph={glyph} bsSize="xsmall"/>
</Button>
));
} else {
2015-07-04 11:42:52 -04:00
accounttreeClasses += "-nochildren";
}
2015-07-04 11:42:52 -04:00
return (
<div className={accounttreeClasses}>
{expandButton}
<Button onClick={this.onSelect}
2015-07-04 11:42:52 -04:00
bsStyle={buttonStyle}
className="accounttree-name">
{this.props.account.Name}
</Button>
<Collapse in={this.state.expanded}>
<div>
{children}
</div>
</Collapse>
2015-07-04 11:42:52 -04:00
</div>
);
}
}
2015-07-04 11:42:52 -04:00
class AccountTree extends React.Component {
constructor() {
super();
this.state = {height: 0};
this.onSelect = this.handleSelect.bind(this);
}
handleSelect(account) {
2015-07-04 11:42:52 -04:00
if (this.props.onSelect != null) {
this.props.onSelect(account);
}
}
resize() {
var div = ReactDOM.findDOMNode(this);
this.setState({height: div.parentElement.clientHeight - 73});
}
componentDidMount() {
this.resize();
var self = this;
$(window).resize(function() {self.resize();});
}
render() {
2015-07-04 11:42:52 -04:00
var accounts = this.props.accounts;
var children = [];
2016-10-05 13:36:47 -04:00
for (var accountId in accounts) {
if (accounts.hasOwnProperty(accountId) &&
accounts[accountId].isRootAccount()) {
2015-07-04 11:42:52 -04:00
children.push((<AccountTreeNode
2016-10-05 13:36:47 -04:00
key={accounts[accountId].AccountId}
account={accounts[accountId]}
selectedAccount={this.props.selectedAccount}
accounts={this.props.accounts}
accountChildren={this.props.accountChildren}
onSelect={this.onSelect}/>));
2016-10-05 13:36:47 -04:00
}
2015-07-04 11:42:52 -04:00
}
var style = {height: this.state.height + "px"};
2015-07-04 11:42:52 -04:00
return (
<div className="accounttree-root" style={style} >
2015-07-04 11:42:52 -04:00
{children}
</div>
);
}
}
2015-07-04 11:42:52 -04:00
class AccountsTab extends React.Component {
constructor() {
super();
this.state = {
2015-07-04 21:11:00 -04:00
creatingNewAccount: false,
2015-07-04 21:55:49 -04:00
editingAccount: false,
2015-07-04 21:11:00 -04:00
deletingAccount: false
};
this.onNewAccount = this.handleNewAccount.bind(this);
this.onEditAccount = this.handleEditAccount.bind(this);
this.onDeleteAccount = this.handleDeleteAccount.bind(this);
this.onCreationCancel = this.handleCreationCancel.bind(this);
this.onEditingCancel = this.handleEditingCancel.bind(this);
this.onDeletionCancel = this.handleDeletionCancel.bind(this);
this.onCreateAccount = this.handleCreateAccount.bind(this);
this.onUpdateAccount = this.handleUpdateAccount.bind(this);
this.onRemoveAccount = this.handleRemoveAccount.bind(this);
this.onAccountSelected = this.handleAccountSelected.bind(this);
}
handleNewAccount() {
this.setState({creatingNewAccount: true});
}
handleEditAccount() {
2015-07-04 21:55:49 -04:00
this.setState({editingAccount: true});
}
handleDeleteAccount() {
2015-07-04 21:11:00 -04:00
this.setState({deletingAccount: true});
}
handleCreationCancel() {
this.setState({creatingNewAccount: false});
}
handleEditingCancel() {
2015-07-04 21:55:49 -04:00
this.setState({editingAccount: false});
}
handleDeletionCancel() {
2015-07-04 21:11:00 -04:00
this.setState({deletingAccount: false});
}
handleCreateAccount(account) {
if (this.props.onCreateAccount != null)
this.props.onCreateAccount(account);
this.setState({creatingNewAccount: false});
}
handleUpdateAccount(account) {
2015-07-04 21:55:49 -04:00
if (this.props.onUpdateAccount != null)
this.props.onUpdateAccount(account);
this.setState({editingAccount: false});
}
handleRemoveAccount(account) {
2015-07-04 21:11:00 -04:00
if (this.props.onDeleteAccount != null)
this.props.onDeleteAccount(account);
2016-10-05 13:36:47 -04:00
this.setState({deletingAccount: false});
}
handleAccountSelected(account) {
2016-10-05 13:36:47 -04:00
this.props.onSelectAccount(account.AccountId);
2017-05-22 20:36:36 -04:00
this.props.onFetchTransactionPage(account, 20, 0);
}
render() {
2016-10-05 13:36:47 -04:00
var disabled = (this.props.selectedAccount == -1) ? true : false;
2016-10-05 13:36:47 -04:00
var selectedAccount = null;
if (this.props.accounts.hasOwnProperty(this.props.selectedAccount))
selectedAccount = this.props.accounts[this.props.selectedAccount];
2015-07-04 21:55:49 -04:00
return (
<Grid fluid className="fullheight"><Row className="fullheight">
<Col xs={2} className="fullheight account-column">
2015-07-04 21:55:49 -04:00
<AddEditAccountModal
show={this.state.creatingNewAccount}
2016-10-05 13:36:47 -04:00
initialParentAccount={selectedAccount}
accounts={this.props.accounts}
2016-10-05 13:36:47 -04:00
accountChildren={this.props.accountChildren}
onCancel={this.onCreationCancel}
onSubmit={this.onCreateAccount}
2016-10-05 13:36:47 -04:00
security_list={this.props.security_list}/>
2015-07-04 21:55:49 -04:00
<AddEditAccountModal
show={this.state.editingAccount}
2016-10-05 13:36:47 -04:00
editAccount={selectedAccount}
2015-07-04 21:55:49 -04:00
accounts={this.props.accounts}
2016-10-05 13:36:47 -04:00
accountChildren={this.props.accountChildren}
onCancel={this.onEditingCancel}
onSubmit={this.onUpdateAccount}
2016-10-05 13:36:47 -04:00
security_list={this.props.security_list}/>
2015-07-04 21:11:00 -04:00
<DeleteAccountModal
show={this.state.deletingAccount}
2016-10-05 13:36:47 -04:00
initialAccount={selectedAccount}
2015-07-04 21:11:00 -04:00
accounts={this.props.accounts}
2016-10-05 13:36:47 -04:00
accountChildren={this.props.accountChildren}
onCancel={this.onDeletionCancel}
onSubmit={this.onRemoveAccount}/>
2015-07-04 11:42:52 -04:00
<AccountTree
2016-10-05 13:36:47 -04:00
accounts={this.props.accounts}
accountChildren={this.props.accountChildren}
selectedAccount={this.props.selectedAccount}
onSelect={this.onAccountSelected}/>
<ButtonGroup className="account-buttongroup">
<Button onClick={this.onNewAccount} bsStyle="success">
<Glyphicon glyph='plus-sign' /></Button>
<Button onClick={this.onEditAccount}
2015-07-04 21:55:49 -04:00
bsStyle="primary" disabled={disabled}>
<Glyphicon glyph='cog' /></Button>
<Button onClick={this.onDeleteAccount}
2015-07-04 21:55:49 -04:00
bsStyle="danger" disabled={disabled}>
<Glyphicon glyph='trash' /></Button>
</ButtonGroup>
</Col><Col xs={10} className="fullheight transactions-column">
2015-08-05 21:25:25 -04:00
<AccountRegister
2017-05-22 20:36:36 -04:00
pageSize={20}
2016-10-05 13:36:47 -04:00
selectedAccount={this.props.selectedAccount}
2015-08-05 21:25:25 -04:00
accounts={this.props.accounts}
2016-10-05 13:36:47 -04:00
accountChildren={this.props.accountChildren}
2017-05-22 20:36:36 -04:00
securities={this.props.securities}
2017-05-24 19:47:18 -04:00
transactions={this.props.transactions}
2017-05-22 20:36:36 -04:00
transactionPage={this.props.transactionPage}
2017-06-04 16:01:42 -04:00
imports={this.props.imports}
onFetchAllAccounts={this.props.onFetchAllAccounts}
2017-05-24 19:47:18 -04:00
onCreateTransaction={this.props.onCreateTransaction}
onUpdateTransaction={this.props.onUpdateTransaction}
onDeleteTransaction={this.props.onDeleteTransaction}
onSelectTransaction={this.props.onSelectTransaction}
onUnselectTransaction={this.props.onUnselectTransaction}
2017-06-04 16:01:42 -04:00
onFetchTransactionPage={this.props.onFetchTransactionPage}
onOpenImportModal={this.props.onOpenImportModal}
onCloseImportModal={this.props.onCloseImportModal}
onImportOFX={this.props.onImportOFX}
onImportOFXFile={this.props.onImportOFXFile}
onImportGnucash={this.props.onImportGnucash} />
</Col>
</Row></Grid>
);
}
}
module.exports = AccountsTab;