Skip to content

Commit 67b4b95

Browse files
authored
Merge pull request #299 from yashutanna/master
call onCardDelete handler in Lane when a card is deleted #298
2 parents 9493de6 + c4ba1f4 commit 67b4b95

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

src/controllers/Lane.js

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class Lane extends Component {
6868
}
6969
}
7070

71-
removeCard = (cardId) => {
71+
removeCard = cardId => {
72+
this.props.onCardDelete && this.props.onCardDelete(cardId, this.props.id)
7273
this.props.actions.removeCard({laneId: this.props.id, cardId: cardId})
7374
}
7475

@@ -143,7 +144,7 @@ class Lane extends Component {
143144
cardStyle,
144145
components,
145146
t
146-
} = this.props
147+
} = this.props
147148
const {addCardMode, collapsed} = this.state
148149

149150
const showableCards = collapsed ? [] : cards
@@ -155,15 +156,15 @@ class Lane extends Component {
155156
key={card.id}
156157
index={idx}
157158
style={card.style || cardStyle}
158-
className='react-trello-card'
159+
className="react-trello-card"
159160
onDelete={onDeleteCard}
160161
onClick={e => this.handleCardClick(e, card)}
161162
showDeleteButton={!hideCardDeleteIcon}
162163
tagStyle={tagStyle}
163164
{...card}
164165
/>
165166
)
166-
return draggable && cardDraggable && (!card.hasOwnProperty('draggable') || card.draggable) ? (
167+
return draggable && cardDraggable && (!card.hasOwnProperty('draggable') || card.draggable) ? (
167168
<Draggable key={card.id}>{cardToRender}</Draggable>
168169
) : (
169170
<span key={card.id}>{cardToRender}</span>
@@ -185,7 +186,9 @@ class Lane extends Component {
185186
{cardList}
186187
</Container>
187188
{editable && !addCardMode && <components.AddCardLink onClick={this.showEditableCard} t={t} />}
188-
{addCardMode && <components.NewCardForm onCancel={this.hideEditableCard} t={t} laneId={id} onAdd={this.addNewCard} />}
189+
{addCardMode && (
190+
<components.NewCardForm onCancel={this.hideEditableCard} t={t} laneId={id} onAdd={this.addNewCard} />
191+
)}
189192
</components.ScrollableLane>
190193
)
191194
}
@@ -194,21 +197,33 @@ class Lane extends Component {
194197
const {id} = this.props
195198
this.props.actions.removeLane({laneId: id})
196199
this.props.onLaneDelete(id)
197-
}
200+
}
198201

199-
updateTitle = (value) => {
202+
updateTitle = value => {
200203
this.props.actions.updateLane({id: this.props.id, title: value})
201-
this.props.onLaneUpdate(this.props.id, {title: value })
204+
this.props.onLaneUpdate(this.props.id, {title: value})
202205
}
203206

204207
renderHeader = () => {
205-
const { components } = this.props
206-
const pickedProps = pick(
207-
this.props,
208-
['id','label','title','titleStyle','cards', 'labelStyle','t','editLaneTitle','canAddLanes']
209-
)
208+
const {components} = this.props
209+
const pickedProps = pick(this.props, [
210+
'id',
211+
'label',
212+
'title',
213+
'titleStyle',
214+
'cards',
215+
'labelStyle',
216+
't',
217+
'editLaneTitle',
218+
'canAddLanes'
219+
])
210220
return (
211-
<components.LaneHeader {...pickedProps} onDelete={this.removeLane} onDoubleClick={this.toggleLaneCollapsed} updateTitle={this.updateTitle}/>
221+
<components.LaneHeader
222+
{...pickedProps}
223+
onDelete={this.removeLane}
224+
onDoubleClick={this.toggleLaneCollapsed}
225+
updateTitle={this.updateTitle}
226+
/>
212227
)
213228
}
214229

@@ -217,11 +232,7 @@ class Lane extends Component {
217232
}
218233

219234
render() {
220-
const {
221-
loading,
222-
isDraggingOver,
223-
collapsed
224-
} = this.state
235+
const {loading, isDraggingOver, collapsed} = this.state
225236
const {
226237
id,
227238
cards,
@@ -240,7 +251,12 @@ class Lane extends Component {
240251
const allClassNames = classNames('react-trello-lane', this.props.className || '')
241252
const showFooter = collapsibleLanes && cards.length > 0
242253
return (
243-
<components.Section {...otherProps} key={id} onClick={() => onLaneClick && onLaneClick(id)} draggable={false} className={allClassNames}>
254+
<components.Section
255+
{...otherProps}
256+
key={id}
257+
onClick={() => onLaneClick && onLaneClick(id)}
258+
draggable={false}
259+
className={allClassNames}>
244260
{this.renderHeader()}
245261
{this.renderDragContainer(isDraggingOver)}
246262
{loading && <components.Loader />}
@@ -290,7 +306,7 @@ Lane.defaultProps = {
290306
label: undefined,
291307
editable: false,
292308
onLaneUpdate: () => {},
293-
onCardAdd: () => {},
309+
onCardAdd: () => {}
294310
}
295311

296312
const mapDispatchToProps = dispatch => ({

0 commit comments

Comments
 (0)