Skip to content

Commit 8344361

Browse files
committed
Clean up notes when removing a lane
Related to #13.
1 parent ebdd4cd commit 8344361

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

immutable_app/app/components/Lane.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Lane extends React.Component {
3838
value={lane.get('name')}
3939
onEdit={name => props.updateLane({id: laneId, name, editing: false})} />
4040
<div className="lane-delete">
41-
<button onClick={this.deleteLane.bind(this, laneId)}>x</button>
41+
<button onClick={this.deleteLane.bind(this, lane)}>x</button>
4242
</div>
4343
</div>
4444
<Notes
@@ -49,9 +49,17 @@ class Lane extends React.Component {
4949
</div>
5050
);
5151
}
52-
deleteLane(laneId, e) {
52+
deleteLane(lane, e) {
5353
e.stopPropagation();
5454

55+
const laneId = lane.get('id');
56+
57+
// Clean up notes
58+
lane.get('notes').forEach(noteId => {
59+
this.props.detachFromLane(laneId, noteId);
60+
this.props.deleteNote(noteId);
61+
});
62+
5563
this.props.deleteLane(laneId);
5664
}
5765
addNote(laneId, e) {

kanban_app/app/components/Lane.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Lane extends React.Component {
3838
value={lane.name}
3939
onEdit={name => props.updateLane({id: laneId, name, editing: false})} />
4040
<div className="lane-delete">
41-
<button onClick={this.deleteLane.bind(this, laneId)}>x</button>
41+
<button onClick={this.deleteLane.bind(this, lane)}>x</button>
4242
</div>
4343
</div>
4444
<Notes
@@ -49,9 +49,17 @@ class Lane extends React.Component {
4949
</div>
5050
);
5151
}
52-
deleteLane(laneId, e) {
52+
deleteLane(lane, e) {
5353
e.stopPropagation();
5454

55+
const laneId = lane.id;
56+
57+
// Clean up notes
58+
lane.notes.forEach(noteId => {
59+
this.props.detachFromLane(laneId, noteId);
60+
this.props.deleteNote(noteId);
61+
});
62+
5563
this.props.deleteLane(laneId);
5664
}
5765
addNote(laneId, e) {

0 commit comments

Comments
 (0)