Skip to content
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

Pass cards prop to LaneFooter #486

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"redux-actions": "^2.6.1",
"redux-logger": "^3.0.6",
"trello-smooth-dnd": "1.0.0",
"uuid": "^3.3.2"
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/cli": "7.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/NewLaneForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import { LaneTitle, NewLaneButtons, Section } from 'rt/styles/Base'
import { AddButton, CancelButton } from 'rt/styles/Elements'
import NewLaneTitleEditor from 'rt/widgets/NewLaneTitleEditor'
import uuidv1 from 'uuid/v1'
import {v1 as uuidv1} from 'uuid'

class NewLane extends Component {
handleSubmit = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Provider} from 'react-redux'
import classNames from 'classnames'
import {applyMiddleware, createStore} from 'redux'
import logger from 'redux-logger'
import uuidv1 from 'uuid/v1'
import {v1 as uuidv1} from 'uuid'
import BoardContainer from './BoardContainer'
import createTranslate from 'rt/helpers/createTranslate'
import boardReducer from 'rt/reducers/BoardReducer'
Expand Down
90 changes: 65 additions & 25 deletions src/controllers/BoardContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
import pick from 'lodash/pick'
import isEqual from 'lodash/isEqual'
import Lane from './Lane'
import { PopoverWrapper } from 'react-popopo'
import {PopoverWrapper} from 'react-popopo'

import * as boardActions from 'rt/actions/BoardActions'
import * as laneActions from 'rt/actions/LaneActions'
Expand Down Expand Up @@ -170,16 +170,8 @@ class BoardContainer extends Component {
return (
<components.BoardWrapper style={style} {...otherProps} draggable={false}>
<PopoverWrapper>
<Container
orientation="horizontal"
onDragStart={this.onDragStart}
dragClass={laneDragClass}
dropClass={laneDropClass}
onDrop={this.onLaneDrop}
lockAxis="x"
getChildPayload={index => this.getLaneDetails(index)}
groupName={this.groupName}>
{reducerData.lanes.map((lane, index) => {
<div style={{display: 'flex'}}>
{reducerData.lanes.filter(l => l.immoveable).map((lane, index) => {
const {id, droppable, ...otherProps} = lane
const laneToRender = (
<Lane
Expand All @@ -198,13 +190,51 @@ class BoardContainer extends Component {
{...passthroughProps}
/>
)
return draggable && laneDraggable ? <Draggable key={lane.id}>{laneToRender}</Draggable> : laneToRender
return draggable && laneDraggable && !lane.immoveable ?
<Draggable key={lane.id}>{laneToRender}</Draggable> : laneToRender
})}
</Container>
<Container
orientation="horizontal"
onDragStart={this.onDragStart}
dragClass={laneDragClass}
dropClass={laneDropClass}
onDrop={this.onLaneDrop}
lockAxis="x"
getChildPayload={index => this.getLaneDetails(index)}
groupName={this.groupName}>
{reducerData.lanes.map((lane, index) => {
const {id, droppable, ...otherProps} = lane
const laneToRender = (
<Lane
key={id}
boardId={this.groupName}
components={components}
id={id}
getCardDetails={this.getCardDetails}
index={index}
droppable={droppable === undefined ? true : droppable}
style={laneStyle || lane.style || {}}
labelStyle={lane.labelStyle || {}}
cardStyle={this.props.cardStyle || lane.cardStyle}
editable={editable && !lane.disallowAddingCard}
{...otherProps}
{...passthroughProps}
/>
)

if (lane.immoveable) {
return <Draggable key={lane.id}><div/></Draggable>
}

return draggable && laneDraggable ?
<Draggable key={lane.id}>{laneToRender}</Draggable> : laneToRender
})}
</Container>
</div>
</PopoverWrapper>
{canAddLanes && (
<Container orientation="horizontal">
{editable && !addLaneMode ? <components.NewLaneSection t={t} onClick={this.showEditableLane} /> : (
{editable && !addLaneMode ? <components.NewLaneSection t={t} onClick={this.showEditableLane}/> : (
addLaneMode && <components.NewLaneForm onCancel={this.hideEditableLane} onAdd={this.addNewLane} t={t}/>
)}
</Container>
Expand Down Expand Up @@ -254,17 +284,27 @@ BoardContainer.propTypes = {
}

BoardContainer.defaultProps = {
t: v=>v,
onDataChange: () => {},
handleDragStart: () => {},
handleDragEnd: () => {},
handleLaneDragStart: () => {},
handleLaneDragEnd: () => {},
onCardUpdate: () => {},
onLaneAdd: () => {},
onLaneDelete: () => {},
onCardMoveAcrossLanes: () => {},
onLaneUpdate: () => {},
t: v => v,
onDataChange: () => {
},
handleDragStart: () => {
},
handleDragEnd: () => {
},
handleLaneDragStart: () => {
},
handleLaneDragEnd: () => {
},
onCardUpdate: () => {
},
onLaneAdd: () => {
},
onLaneDelete: () => {
},
onCardMoveAcrossLanes: () => {
},
onLaneUpdate: () => {
},
editable: false,
canAddLanes: false,
hideCardDeleteIcon: false,
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/Lane.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {connect} from 'react-redux'
import isEqual from 'lodash/isEqual'
import cloneDeep from 'lodash/cloneDeep'
import pick from 'lodash/pick'
import uuidv1 from 'uuid/v1'
import {v1 as uuidv1} from 'uuid'

import Container from 'rt/dnd/Container'
import Draggable from 'rt/dnd/Draggable'
Expand Down Expand Up @@ -270,7 +270,7 @@ class Lane extends Component {
{this.renderHeader({id, cards, ...otherProps})}
{this.renderDragContainer(isDraggingOver)}
{loading && <components.Loader />}
{showFooter && <components.LaneFooter onClick={this.toggleLaneCollapsed} collapsed={collapsed} />}
{showFooter && <components.LaneFooter onClick={this.toggleLaneCollapsed} collapsed={collapsed} cards={cards} />}
</components.Section>
)
}
Expand Down
2 changes: 1 addition & 1 deletion stories/CustomLaneFooter.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Board from '../src'

const data = require('./data/collapsible.json')

const LaneFooter = ({onClick, collapsed}) => <div onClick={onClick}>{collapsed ? 'click to expand' : 'click to collapse'}</div>
const LaneFooter = ({onClick, collapsed, cards}) => <div onClick={onClick}>{collapsed ? 'click to expand' : 'click to collapse'} {cards.length} card{cards.length > 1 && 's'}</div>

storiesOf('Custom Components', module).
add('LaneFooter', () => <Board collapsibleLanes components={{LaneFooter: LaneFooter}} data={data} />)
11 changes: 11 additions & 0 deletions stories/RestrictedLanes.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ storiesOf('Drag-n-Drop', module).add(
},
{info: 'Use props to disable dragging lanes but enable card dragging'}
)

storiesOf('Drag-n-Drop', module).add(
'Immoveable lane',
() => {
const dataCopy = JSON.parse(JSON.stringify(data))
dataCopy.lanes[0].immoveable = true
dataCopy.lanes[0].title = 'Immoveable'
return <Board data={dataCopy} draggable />
},
{info: 'Use props to disable dragging lanes but enable card dragging'}
)
Loading