React = require 'react' _ = require 'underscore' {AccountStore} = require 'nylas-exports' {Menu, ButtonDropdown} = require 'nylas-component-kit' class AccountContactField extends React.Component @displayName: 'AccountContactField' @propTypes: value: React.PropTypes.object account: React.PropTypes.object, onChange: React.PropTypes.func.isRequired render: =>
{"From:"}
{@_renderFromPicker()}
_renderFromPicker: -> if @props.account? && @props.value? label = @props.value.toString() if @props.account.aliases.length is 0 return @_renderAccountSpan(label) return {label}} menu={@_renderAliasesMenu(@props.account)}/> else return @_renderAccountSpan("Please select an account") _renderAliasesMenu: (account) => alias } itemContent={ (alias) -> alias } onSelect={@_onChooseAlias.bind(@, account)} /> _renderAccountSpan: (label) -> {label} _onChooseAlias: (account, alias) => @props.onChange(account.meUsingAlias(alias)) @refs.dropdown.toggleDropdown() module.exports = AccountContactField