mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-10-31 16:00:05 -04:00
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
var React = require('react');
|
|
|
|
var Combobox = require('react-widgets').Combobox;
|
|
|
|
var getAccountDisplayList = require('../utils').getAccountDisplayList;
|
|
|
|
class AccountCombobox extends React.Component {
|
|
constructor() {
|
|
super();
|
|
this.onAccountChange = this.handleAccountChange.bind(this);
|
|
this.defaultProps = {
|
|
includeRoot: true,
|
|
disabled: false,
|
|
rootName: "New Top-level Account"
|
|
}
|
|
}
|
|
handleAccountChange(account) {
|
|
if (this.props.onChange != null &&
|
|
account.hasOwnProperty('AccountId') &&
|
|
(this.props.accounts.hasOwnProperty([account.AccountId]) ||
|
|
account.AccountId == -1)) {
|
|
this.props.onChange(account)
|
|
}
|
|
}
|
|
render() {
|
|
var accounts = getAccountDisplayList(this.props.accounts, this.props.accountChildren, this.props.includeRoot, this.props.rootName);
|
|
var className = "";
|
|
if (this.props.className)
|
|
className = this.props.className;
|
|
return (
|
|
<Combobox
|
|
data={accounts}
|
|
valueField='AccountId'
|
|
textField='Name'
|
|
defaultValue={this.props.value}
|
|
onChange={this.onAccountChange}
|
|
ref="account"
|
|
disabled={this.props.disabled}
|
|
suggest
|
|
filter='contains'
|
|
className={className} />
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = AccountCombobox;
|