mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-07-02 20:28:38 -04:00
Move all components into 'components' subdirectory
This commit is contained in:
41
js/components/AccountCombobox.js
Normal file
41
js/components/AccountCombobox.js
Normal file
@ -0,0 +1,41 @@
|
||||
var React = require('react');
|
||||
|
||||
var Combobox = require('react-widgets').Combobox;
|
||||
|
||||
var getAccountDisplayList = require('../utils').getAccountDisplayList;
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: "AccountCombobox",
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
includeRoot: true,
|
||||
disabled: false,
|
||||
rootName: "New Top-level Account"
|
||||
};
|
||||
},
|
||||
handleAccountChange: function(account) {
|
||||
if (this.props.onChange != null &&
|
||||
account.hasOwnProperty('AccountId') &&
|
||||
(this.props.accounts.hasOwnProperty([account.AccountId]) ||
|
||||
account.AccountId == -1)) {
|
||||
this.props.onChange(account)
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
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.handleAccountChange}
|
||||
ref="account"
|
||||
disabled={this.props.disabled}
|
||||
className={className} />
|
||||
);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user