Skip to content

Commit

Permalink
Firebase - Section 13
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jun 6, 2015
1 parent 631007d commit f3d0640
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions todos/src/list-item.jsx
Expand Up @@ -6,7 +6,8 @@ module.exports = React.createClass({
getInitialState: function() {
return {
text: this.props.item.text,
done: this.props.item.done
done: this.props.item.done,
textChanged: false
}
},
componentWillMount: function() {
Expand All @@ -24,17 +25,41 @@ module.exports = React.createClass({
<input type="text"
className="form-control"
value={this.state.text}
onChange={this.handleTextChange}
/>
<span className="input-group-btn">
<button className="btn btn-default">
{this.changesButtons()}
<button
className="btn btn-default"
onClick={this.handleDeleteClick}
>
Delete
</button>
</span>
</div>
},
changesButtons: function() {
if(!this.state.textChanged) {
return null
} else {
return <span>
<button className="btn btn-default">Save</button>
<button className="btn btn-default">Undo</button>
</span>
}
},
handleTextChange: function(event) {
this.setState({
text: event.target.value,
textChanged: true
});
},
handleDoneChange: function(event) {
var update = {done: event.target.checked}
this.setState(update);
this.fb.update(update);
},
handleDeleteClick: function() {
this.fb.remove();
}
});

0 comments on commit f3d0640

Please sign in to comment.