-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extend event bus capabilities #417
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,6 +283,19 @@ eventBus.publish({type: 'MOVE_CARD', fromLaneId: 'PLANNED', toLaneId: 'WIP', car | |
//To update the lanes | ||
eventBus.publish({type: 'UPDATE_LANES', lanes: newLaneData}) | ||
|
||
//To update one lane | ||
eventBus.publish({type: 'UPDATE_LANE', lane: { id: 'TODO', title: 'teste' }}) | ||
|
||
//To add a new lane | ||
eventBus.publish({type: 'ADD_LANE', lane: { id: 'TODO', title: 'teste' }}) | ||
|
||
//To move one lane | ||
eventBus.publish({type: 'MOVE_LANE', fromIndex: 0, toIndex: 1 }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm asking myself if it was not better to create a new action based on id, not on index. What do you think, @dapi? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @LucasBadico ! I agree with you. If we pass an id we can fetch lane's index when need. What is you use case of One thought came. When we drug one lane, from example move it from index 0 to index 5. Actually all lanes from 1 to 5 index are moved ) Shall we emit events for all these lanes? Probably better way to emit event like "LANES_MOVED" and pass new ordered lanes set? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have some points.
|
||
|
||
//To remove a lane | ||
eventBus.publish({type: 'REMOVE_LANE', laneId: 'TODO' }) | ||
|
||
|
||
<Board data={data} eventBusHandle={setEventBus}/> | ||
``` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,14 +61,15 @@ class BoardContainer extends Component { | |
let eventBus = { | ||
publish: event => { | ||
switch (event.type) { | ||
case 'REFRESH_BOARD': | ||
return actions.loadBoard(event.data) | ||
|
||
case 'ADD_CARD': | ||
return actions.addCard({laneId: event.laneId, card: event.card}) | ||
case 'UPDATE_CARD': | ||
return actions.updateCard({laneId: event.laneId, card: event.card}) | ||
case 'REMOVE_CARD': | ||
return actions.removeCard({laneId: event.laneId, cardId: event.cardId}) | ||
case 'REFRESH_BOARD': | ||
return actions.loadBoard(event.data) | ||
case 'MOVE_CARD': | ||
return actions.moveCardAcrossLanes({ | ||
fromLaneId: event.fromLaneId, | ||
|
@@ -78,10 +79,18 @@ class BoardContainer extends Component { | |
}) | ||
case 'UPDATE_CARDS': | ||
return actions.updateCards({laneId: event.laneId, cards: event.cards}) | ||
|
||
case 'UPDATE_LANES': | ||
return actions.updateLanes(event.lanes) | ||
case 'UPDATE_LANE': | ||
return actions.updateLane(event.lane) | ||
case 'MOVE_LANE': | ||
return actions.moveLane({ oldIndex: event.fromIndex, newIndex: event.toIndex }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know @LucasBadico What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sense. Principle of least surprise. |
||
case 'REMOVE_LANE': | ||
return actions.moveLane({ laneId: event.laneId }) | ||
case 'ADD_LANE': | ||
return actions.addLane(event.lane) | ||
|
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one already was in code, but was not documented.