Created
December 19, 2014 19:16
-
-
Save jimrubenstein/aeb7a8d2ba1a1217b2e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React= require('react/addons'); | |
var Router = require('react-router'); | |
var AppConstants = require('../../constants/AppConstants'); | |
var GroupActionCreators = require('../../actions/GroupActionCreators'); | |
var Link = Router.Link; | |
module.exports = React.createClass({ | |
mixins: [Router.Navigation], | |
getInitialState: function() { | |
return { | |
value: this.props.value || "" | |
} | |
}, | |
onChange: function(evt) { | |
this.setState({ | |
value: evt.target.value | |
}); | |
}, | |
onKeyUp: function(evt) { | |
if (evt.keyCode == AppConstants.ENTER_KEY_CODE) { | |
this.save(); | |
} | |
}, | |
save: function() | |
{ | |
var Group = { | |
name: this.state.value, | |
contacts: [] | |
}; | |
GroupActionCreators.createGroup(Group); | |
this.transitionTo("group_list"); | |
}, | |
render: function() { | |
var from = "group_list"; | |
var value = this.state.value; | |
return ( | |
<div className="page-container"> | |
<div className="header bar bar-nav"> | |
<Link to={ from } className="icon icon-left-nav pull-left" /> | |
<h1 className="title">New Group</h1> | |
</div> | |
<div className="content"> | |
<input type="text" | |
ref="group_name" | |
placeholder="Group name" | |
onChange={ this.onChange } | |
onKeyUp={ this.onKeyUp } | |
autoFocus={ true } | |
value={ value } | |
/> | |
<button className="btn btn-block btn-positive" | |
onClick={ this.save } | |
>Create Group</button> | |
</div> | |
</div> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment