@@ -20,7 +20,8 @@ class SketchList extends React.Component {
20
20
super ( props ) ;
21
21
this . props . getProjects ( this . props . username ) ;
22
22
this . state = {
23
- actionDialogueDisplayed : new Array ( this . props . sketches . length ) . fill ( false )
23
+ actionDialogueDisplayed : new Array ( this . props . sketches . length ) . fill ( false ) ,
24
+ renameBoxDisplayed : new Array ( this . props . sketches . length ) . fill ( false )
24
25
} ;
25
26
}
26
27
@@ -37,13 +38,22 @@ class SketchList extends React.Component {
37
38
} ) ;
38
39
}
39
40
41
+ closeAllRenameBoxes ( ) {
42
+ this . setState ( {
43
+ renameBoxDisplayed : new Array ( this . props . sketches . length ) . fill ( false )
44
+ } ) ;
45
+ }
46
+
40
47
render ( ) {
41
48
const username = this . props . username !== undefined ? this . props . username : this . props . user . username ;
42
49
return (
43
50
< div
44
51
className = "sketches-table-container"
45
52
role = "presentation"
46
- onClick = { e => this . closeAllDropdowns ( ) }
53
+ onClick = { ( ) => {
54
+ this . closeAllDropdowns ( ) ;
55
+ this . closeAllRenameBoxes ( ) ;
56
+ } }
47
57
>
48
58
< Helmet >
49
59
< title > { this . getSketchesTitle ( ) } </ title >
@@ -57,7 +67,7 @@ class SketchList extends React.Component {
57
67
< tr >
58
68
< th scope = "col" > Sketch</ th >
59
69
< th scope = "col" > Date created</ th >
60
- < th scope = "col" > Date created </ th >
70
+ < th scope = "col" > Date updated </ th >
61
71
< th scope = "col" > </ th >
62
72
</ tr >
63
73
</ thead >
@@ -72,10 +82,24 @@ class SketchList extends React.Component {
72
82
this . closeAllDropdowns ( ) ;
73
83
return ;
74
84
}
85
+ if ( this . state . renameBoxDisplayed . some ( el => el ) ) {
86
+ this . closeAllRenameBoxes ( ) ;
87
+ return ;
88
+ }
75
89
browserHistory . push ( `/${ username } /sketches/${ sketch . id } ` ) ;
76
90
} }
77
91
>
78
- < th scope = "row" > < Link to = { `/${ username } /sketches/${ sketch . id } ` } > { sketch . name } </ Link > </ th >
92
+ < th scope = "row" >
93
+ < Link to = { `/${ username } /sketches/${ sketch . id } ` } >
94
+ { this . state . renameBoxDisplayed [ i ] ? '' : sketch . name }
95
+ </ Link >
96
+ { this . state . renameBoxDisplayed [ i ]
97
+ &&
98
+ < input
99
+ onClick = { e => e . stopPropagation ( ) }
100
+ />
101
+ }
102
+ </ th >
79
103
< td > { moment ( sketch . createdAt ) . format ( 'MMM D, YYYY h:mm A' ) } </ td >
80
104
< td > { moment ( sketch . updatedAt ) . format ( 'MMM D, YYYY h:mm A' ) } </ td >
81
105
< td className = "sketch-list__dropdown-column" >
@@ -126,7 +150,19 @@ class SketchList extends React.Component {
126
150
File actions
127
151
</ div >
128
152
< div className = "sketch-list__action-dashed-line" />
129
- < div className = "sketch-list__action-option" >
153
+ < div
154
+ role = "presentation"
155
+ className = "sketch-list__action-option"
156
+ onClick = { ( ) => {
157
+ this . closeAllRenameBoxes ( ) ;
158
+ const renameBoxDisplayed = new Array ( this . props . sketches . length ) . fill ( false ) ;
159
+ renameBoxDisplayed [ i ] = true ;
160
+ this . setState ( {
161
+ renameBoxDisplayed
162
+ } ) ;
163
+ this . closeAllDropdowns ( ) ;
164
+ } }
165
+ >
130
166
Rename
131
167
</ div >
132
168
{ this . props . project . id &&
0 commit comments