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({
6
6
getInitialState : function ( ) {
7
7
return {
8
8
text : this . props . item . text ,
9
- done : this . props . item . done
9
+ done : this . props . item . done ,
10
+ textChanged : false
10
11
}
11
12
} ,
12
13
componentWillMount : function ( ) {
@@ -24,17 +25,41 @@ module.exports = React.createClass({
24
25
< input type = "text"
25
26
className = "form-control"
26
27
value = { this . state . text }
28
+ onChange = { this . handleTextChange }
27
29
/>
28
30
< 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
+ >
30
36
Delete
31
37
</ button >
32
38
</ span >
33
39
</ div >
34
40
} ,
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
+ } ,
35
57
handleDoneChange : function ( event ) {
36
58
var update = { done : event . target . checked }
37
59
this . setState ( update ) ;
38
60
this . fb . update ( update ) ;
61
+ } ,
62
+ handleDeleteClick : function ( ) {
63
+ this . fb . remove ( ) ;
39
64
}
40
65
} ) ;
You can’t perform that action at this time.
0 commit comments