Skip to content

Commit 2fd8b2b

Browse files
committed
SketchList Rename initial UI completed
1 parent b0a42d0 commit 2fd8b2b

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

client/modules/IDE/components/SketchList.jsx

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class SketchList extends React.Component {
2020
super(props);
2121
this.props.getProjects(this.props.username);
2222
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)
2425
};
2526
}
2627

@@ -37,13 +38,22 @@ class SketchList extends React.Component {
3738
});
3839
}
3940

41+
closeAllRenameBoxes() {
42+
this.setState({
43+
renameBoxDisplayed: new Array(this.props.sketches.length).fill(false)
44+
});
45+
}
46+
4047
render() {
4148
const username = this.props.username !== undefined ? this.props.username : this.props.user.username;
4249
return (
4350
<div
4451
className="sketches-table-container"
4552
role="presentation"
46-
onClick={e => this.closeAllDropdowns()}
53+
onClick={() => {
54+
this.closeAllDropdowns();
55+
this.closeAllRenameBoxes();
56+
}}
4757
>
4858
<Helmet>
4959
<title>{this.getSketchesTitle()}</title>
@@ -57,7 +67,7 @@ class SketchList extends React.Component {
5767
<tr>
5868
<th scope="col">Sketch</th>
5969
<th scope="col">Date created</th>
60-
<th scope="col">Date created</th>
70+
<th scope="col">Date updated</th>
6171
<th scope="col"></th>
6272
</tr>
6373
</thead>
@@ -72,10 +82,24 @@ class SketchList extends React.Component {
7282
this.closeAllDropdowns();
7383
return;
7484
}
85+
if (this.state.renameBoxDisplayed.some(el => el)) {
86+
this.closeAllRenameBoxes();
87+
return;
88+
}
7589
browserHistory.push(`/${username}/sketches/${sketch.id}`);
7690
}}
7791
>
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>
79103
<td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td>
80104
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
81105
<td className="sketch-list__dropdown-column">
@@ -126,7 +150,19 @@ class SketchList extends React.Component {
126150
File actions
127151
</div>
128152
<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+
>
130166
Rename
131167
</div>
132168
{ this.props.project.id &&

0 commit comments

Comments
 (0)