@@ -6,6 +6,7 @@ import {BoardDiv} from '../styles/Base'
66import { bindActionCreators } from 'redux'
77import { connect } from 'react-redux'
88import Lane from './Lane'
9+ import { Container , Draggable } from 'react-smooth-dnd'
910
1011import * as boardActions from '../actions/BoardActions'
1112import * as laneActions from '../actions/LaneActions'
@@ -59,6 +60,20 @@ class BoardContainer extends Component {
5960 return this . props . reducerData . lanes . find ( lane => lane . id === laneId ) . cards [ cardIndex ]
6061 }
6162
63+ onDragStart = ( index , payload ) => {
64+ const { handleLaneDragStart} = this . props
65+ handleLaneDragStart ( payload . id )
66+ }
67+
68+ onLaneDrop = ( { removedIndex, addedIndex, payload} ) => {
69+ const { actions, handleLaneDragEnd} = this . props
70+ actions . moveLane ( { oldIndex : removedIndex , newIndex : addedIndex } )
71+ handleLaneDragEnd ( payload . id , addedIndex )
72+ }
73+
74+ getLaneDetails = ( index ) => {
75+ return this . props . reducerData . lanes [ index ]
76+ }
6277
6378 render ( ) {
6479 const { reducerData, style, ...otherProps } = this . props
@@ -85,22 +100,31 @@ class BoardContainer extends Component {
85100 ] )
86101
87102 return (
88- < BoardDiv style = { style } { ...otherProps } draggable = { false } >
103+ < BoardDiv style = { style } { ...otherProps } draggable = { false } >
104+ < Container
105+ orientation = "horizontal"
106+ onDragStart = { this . onDragStart }
107+ onDrop = { this . onLaneDrop }
108+ getChildPayload = { index => this . getLaneDetails ( index ) }
109+ groupName = "TrelloBoard" >
89110 { reducerData . lanes . map ( ( lane , index ) => {
90111 const { id, droppable, ...otherProps } = lane
91112 return (
92- < Lane
93- key = { id }
94- id = { id }
95- getCardDetails = { this . getCardDetails }
96- index = { index }
97- droppable = { droppable === undefined ? true : droppable }
98- { ...otherProps }
99- { ...passthroughProps }
100- />
113+ < Draggable key = { lane . id } >
114+ < Lane
115+ key = { id }
116+ id = { id }
117+ getCardDetails = { this . getCardDetails }
118+ index = { index }
119+ droppable = { droppable === undefined ? true : droppable }
120+ { ...otherProps }
121+ { ...passthroughProps }
122+ />
123+ </ Draggable >
101124 )
102125 } ) }
103- </ BoardDiv >
126+ </ Container >
127+ </ BoardDiv >
104128 )
105129 }
106130}
@@ -124,6 +148,8 @@ BoardContainer.propTypes = {
124148 hideCardDeleteIcon : PropTypes . bool ,
125149 handleDragStart : PropTypes . func ,
126150 handleDragEnd : PropTypes . func ,
151+ handleLaneDragStart : PropTypes . func ,
152+ handleLaneDragEnd : PropTypes . func ,
127153 customCardLayout : PropTypes . bool ,
128154 newCardTemplate : PropTypes . node ,
129155 customLaneHeader : PropTypes . element ,
@@ -135,6 +161,8 @@ BoardContainer.defaultProps = {
135161 onDataChange : ( ) => { } ,
136162 handleDragStart : ( ) => { } ,
137163 handleDragEnd : ( ) => { } ,
164+ handleLaneDragStart : ( ) => { } ,
165+ handleLaneDragEnd : ( ) => { } ,
138166 editable : false ,
139167 hideCardDeleteIcon : false ,
140168 draggable : false ,
0 commit comments