File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ module.exports = React.createClass({
66 getInitialState : function ( ) {
77 return {
88 text : this . props . item . text ,
9- done : this . props . item . done
9+ done : this . props . item . done ,
10+ textChanged : false
1011 }
1112 } ,
1213 componentWillMount : function ( ) {
@@ -24,17 +25,41 @@ module.exports = React.createClass({
2425 < input type = "text"
2526 className = "form-control"
2627 value = { this . state . text }
28+ onChange = { this . handleTextChange }
2729 />
2830 < span className = "input-group-btn" >
29- < button className = "btn btn-default" >
31+ { this . changesButtons ( ) }
32+ < button
33+ className = "btn btn-default"
34+ onClick = { this . handleDeleteClick }
35+ >
3036 Delete
3137 </ button >
3238 </ span >
3339 </ div >
3440 } ,
41+ changesButtons : function ( ) {
42+ if ( ! this . state . textChanged ) {
43+ return null
44+ } else {
45+ return < span >
46+ < button className = "btn btn-default" > Save</ button >
47+ < button className = "btn btn-default" > Undo</ button >
48+ </ span >
49+ }
50+ } ,
51+ handleTextChange : function ( event ) {
52+ this . setState ( {
53+ text : event . target . value ,
54+ textChanged : true
55+ } ) ;
56+ } ,
3557 handleDoneChange : function ( event ) {
3658 var update = { done : event . target . checked }
3759 this . setState ( update ) ;
3860 this . fb . update ( update ) ;
61+ } ,
62+ handleDeleteClick : function ( ) {
63+ this . fb . remove ( ) ;
3964 }
4065} ) ;
You can’t perform that action at this time.
0 commit comments