Skip to content

Commit b3caf57

Browse files
committed
finish implementing the lanes
1 parent 5137223 commit b3caf57

7 files changed

Lines changed: 114 additions & 33 deletions

File tree

app/actions/LaneActions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import alt from '../libs/alt';
22

3-
export default alt.generateActions('create','attachToLane',
4-
'detachFromLane');
3+
export default alt.generateActions(
4+
'create','update','delete',
5+
'attachToLane','detachFromLane');

app/components/App.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ export default class App extends React.Component {
2323
addItem() {
2424
LaneActions.create({name: 'New lane'});
2525
}
26+
27+
28+
2629
}

app/components/Editable.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class Note extends React.Component {
3535
}
3636
renderValue() {
3737
const onDelete = this.props.onDelete;
38-
38+
3939
return (
4040
<div onClick={this.edit}>
4141
<span className="value">{this.props.value}</span>

app/components/Lane.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default class Lane extends React.Component {
1515
this.addNote = this.addNote.bind(this, id);
1616
this.deleteNote = this.deleteNote.bind(this, id);
1717
this.editName = this.editName.bind(this,id);
18+
//this.deleteLane = this.deleteLane.bind(this,id);
1819
}
1920
render() {
2021
const {lane, ...props} = this.props;
@@ -23,7 +24,8 @@ export default class Lane extends React.Component {
2324
<div {...props}>
2425
<div className="lane-header">
2526
<Editable className="lane-name" value={lane.name}
26-
onEdit={this.editName}/>
27+
onEdit={this.editName}
28+
/*onDelete={this.deleteLane}*//>
2729
<div className="lane-add-note">
2830
<button onClick={this.addNote}>+</button>
2931
</div>
@@ -52,6 +54,15 @@ export default class Lane extends React.Component {
5254
NoteActions.delete(noteId);
5355
}
5456
editName(id,name){
55-
console.log('edited lane name',id,name);
57+
if(name) {
58+
LaneActions.update({id, name});
59+
}
60+
else {
61+
LaneActions.delete(id);
62+
}
5663
}
64+
65+
/*deleteLane(id){
66+
LaneActions.delete(id);
67+
}*/
5768
}

app/components/Lanes.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ export default class Lanes extends React.Component {
1010
renderLane(lane) {
1111
return <Lane className="lane" key={lane.id} lane={lane} />;
1212
}
13+
14+
1315
}

app/main.css

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,87 @@
11
body {
22
background: #f0f0f0;
3+
34
font-family: sans-serif;
45
}
56

6-
.add-note{
7-
background-color: #fdfdfd;
8-
border: 1px solid #ccc;
9-
}
7+
.lane {
8+
display: inline-block;
9+
10+
margin: 1em;
1011

11-
.notes{
12-
margin: 0.5em;
13-
padding-left:0;
12+
background-color: #efefef;
13+
border: 1px solid #ccc;
14+
border-radius: 0.5em;
1415

15-
max-width: 10em;
16-
list-style: none;
16+
min-width: 10em;
17+
vertical-align: top;
1718
}
1819

19-
.note{
20-
margin-bottom: 0.5em;
21-
padding: 0.5em;
20+
.lane-header {
21+
overflow: auto;
22+
23+
padding: 1em;
24+
25+
color: #efefef;
26+
background-color: #333;
2227

23-
background-color: #fdfdfd;
24-
box-shadow: 0 0 0.3em 0.03em rgba(0,0,0,0.3);
28+
border-top-left-radius: 0.5em;
29+
border-top-right-radius: 0.5em;
2530
}
2631

27-
.note:hover{
28-
box-shadow: 0 0 0.3em 0.03em rgba(0,0,0,0.7);
29-
transition: 0.6s;
32+
.lane-name {
33+
float: left;
3034
}
3135

32-
.note .value{
33-
display: inline-block;
36+
.lane-add-note {
37+
float: right;
38+
39+
margin-left: 0.5em;
3440
}
3541

36-
.note .delete{
37-
float: right;
42+
.add-lane, .lane-add-note button {
43+
background-color: #fdfdfd;
44+
border: 1px solid #ccc;
45+
}
3846

39-
padding: 0;
47+
.notes {
48+
margin: 0.5em;
49+
padding-left: 0;
4050

41-
background-color: #fdfdfd;
42-
border:none;
51+
max-width: 10em;
52+
list-style: none;
53+
}
4354

44-
cursor: pointer;
55+
.note {
56+
margin-bottom: 0.5em;
57+
padding: 0.5em;
4558

46-
visibility: hidden;
59+
background-color: #fdfdfd;
60+
box-shadow: 0 0 0.3em .03em rgba(0,0,0,.3);
4761
}
62+
.note:hover {
63+
box-shadow: 0 0 0.3em .03em rgba(0,0,0,.7);
4864

49-
.note:hover .delete{
50-
visibility: visible;
65+
transition: .6s;
66+
}
67+
68+
.note .value {
69+
/* force to use inline-block so that it gets minimum height */
70+
display: inline-block;
71+
}
72+
73+
.note .delete {
74+
float: right;
75+
76+
padding: 0;
77+
78+
background-color: #fdfdfd;
79+
border: none;
80+
81+
cursor: pointer;
82+
83+
visibility: hidden;
84+
}
85+
.note:hover .delete {
86+
visibility: visible;
5187
}

app/stores/LaneStore.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,34 @@ class LaneStore {
2020
});
2121
}
2222

23+
update({id,name}){
24+
const lanes = this.lanes;
25+
const targetId = this.findLane(id);
26+
27+
if(targetId < 0) {
28+
return;
29+
}
30+
31+
lanes[targetId].name = name;
32+
33+
this.setState({lanes});
34+
35+
}
36+
37+
delete(id){
38+
const lanes = this.lanes;
39+
const targetId = this.findLane(id);
40+
41+
if(targetId < 0) {
42+
return;
43+
}
44+
45+
this.setState({
46+
lanes: lanes.slice(0, targetId).concat(lanes.slice(targetId + 1))
47+
});
48+
49+
}
50+
2351
attachToLane({laneId,noteId}){
2452
if(!noteId){
2553
this.waitFor(NoteStore);

0 commit comments

Comments
 (0)