Skip to content

Commit 74b4095

Browse files
authored
Merge pull request #343 from ocxers/master
Added the `onBeforeCardDelete` function
2 parents 4d1156f + 02c79b0 commit 74b4095

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
@@ -119,6 +119,7 @@ class BoardContainer extends Component {
119119
onDataChange,
120120
onCardAdd,
121121
onCardClick,
122+
onBeforeCardDelete,
122123
onCardDelete,
123124
onLaneScroll,
124125
onLaneClick,
@@ -141,6 +142,7 @@ class BoardContainer extends Component {
141142
'onLaneDelete',
142143
'onLaneUpdate',
143144
'onCardClick',
145+
'onBeforeCardDelete',
144146
'onCardDelete',
145147
'onCardAdd',
146148
'onLaneClick',
@@ -216,6 +218,7 @@ BoardContainer.propTypes = {
216218
eventBusHandle: PropTypes.func,
217219
onLaneScroll: PropTypes.func,
218220
onCardClick: PropTypes.func,
221+
onBeforeCardDelete: PropTypes.func,
219222
onCardDelete: PropTypes.func,
220223
onCardAdd: PropTypes.func,
221224
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) => {
@@ -237,6 +244,7 @@ class Lane extends Component {
237244
onLaneScroll,
238245
onCardClick,
239246
onCardAdd,
247+
onBeforeCardDelete,
240248
onCardDelete,
241249
onLaneDelete,
242250
onLaneUpdate,
@@ -281,6 +289,7 @@ Lane.propTypes = {
281289
droppable: PropTypes.bool,
282290
onCardMoveAcrossLanes: PropTypes.func,
283291
onCardClick: PropTypes.func,
292+
onBeforeCardDelete: PropTypes.func,
284293
onCardDelete: PropTypes.func,
285294
onCardAdd: PropTypes.func,
286295
onLaneDelete: PropTypes.func,

0 commit comments

Comments
 (0)