Skip to content

Commit 02c79b0

Browse files
committed
Added the onBeforeCardDelete function to support the Confirm Delete option. By this event, users can do something (eg. cancel delete) before delete the card.
1 parent a797c4d commit 02c79b0

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ This is the container component that encapsulates the lanes and cards
139139
| onDataChange | function | Called everytime the data changes due to user interaction or event bus: `onDataChange(newData)` |
140140
| onCardClick | function | Called when a card is clicked: `onCardClick(cardId, metadata, laneId)` |
141141
| onCardAdd | function | Called when a new card is added: `onCardAdd(card, laneId)` |
142+
| onBeforeCardDelete | function | Called before delete a card, please call the `callback()` if confirm to delete a card: `onConfirmCardDelete(callback)`
142143
| onCardDelete | function | Called when a card is deleted: `onCardDelete(cardId, laneId)` |
143144
| onCardMoveAcrossLanes | function | Called when a card is moved across lanes `onCardMoveAcrossLanes(fromLaneId, toLaneId, cardId, index)` |
144145
| onLaneAdd | function | Called when a new lane is added: `onLaneAdd(params)` |

src/controllers/BoardContainer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class BoardContainer extends Component {
116116
onDataChange,
117117
onCardAdd,
118118
onCardClick,
119+
onBeforeCardDelete,
119120
onCardDelete,
120121
onLaneScroll,
121122
onLaneClick,
@@ -138,6 +139,7 @@ class BoardContainer extends Component {
138139
'onLaneDelete',
139140
'onLaneUpdate',
140141
'onCardClick',
142+
'onBeforeCardDelete',
141143
'onCardDelete',
142144
'onCardAdd',
143145
'onLaneClick',
@@ -213,6 +215,7 @@ BoardContainer.propTypes = {
213215
eventBusHandle: PropTypes.func,
214216
onLaneScroll: PropTypes.func,
215217
onCardClick: PropTypes.func,
218+
onBeforeCardDelete: PropTypes.func,
216219
onCardDelete: PropTypes.func,
217220
onCardAdd: PropTypes.func,
218221
onLaneAdd: PropTypes.func,

src/controllers/Lane.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ class Lane extends Component {
6969
}
7070

7171
removeCard = cardId => {
72-
this.props.onCardDelete && this.props.onCardDelete(cardId, this.props.id)
73-
this.props.actions.removeCard({laneId: this.props.id, cardId: cardId})
72+
if (this.props.onBeforeCardDelete && typeof this.props.onBeforeCardDelete === 'function') {
73+
this.props.onBeforeCardDelete(() => {
74+
this.props.onCardDelete && this.props.onCardDelete(cardId, this.props.id)
75+
this.props.actions.removeCard({laneId: this.props.id, cardId: cardId})
76+
})
77+
} else {
78+
this.props.onCardDelete && this.props.onCardDelete(cardId, this.props.id)
79+
this.props.actions.removeCard({laneId: this.props.id, cardId: cardId})
80+
}
7481
}
7582

7683
handleCardClick = (e, card) => {
@@ -231,6 +238,7 @@ class Lane extends Component {
231238
onLaneScroll,
232239
onCardClick,
233240
onCardAdd,
241+
onBeforeCardDelete,
234242
onCardDelete,
235243
onLaneDelete,
236244
onLaneUpdate,
@@ -275,6 +283,7 @@ Lane.propTypes = {
275283
droppable: PropTypes.bool,
276284
onCardMoveAcrossLanes: PropTypes.func,
277285
onCardClick: PropTypes.func,
286+
onBeforeCardDelete: PropTypes.func,
278287
onCardDelete: PropTypes.func,
279288
onCardAdd: PropTypes.func,
280289
onLaneDelete: PropTypes.func,

0 commit comments

Comments
 (0)