Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

#1066 Fix board's sidebar list didn't get updated after dragging card #1126

Merged
merged 1 commit into from
Aug 8, 2017
Merged
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
30 changes: 30 additions & 0 deletions src/components/board/Sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,36 @@ class Sidenav extends Component {

}

getCardIndex = (cardId) => {
const { view } = this.state;
let result = -1;

if (view && view.result) {
view.result.forEach( (card, index) => {
if (card && (card.cardId === cardId)) {
result = index;
}
});
}

return result;
}

removeCard = (cardId) => {
const { view } = this.state;
if (view && view.result) {
let cardIndex = this.getCardIndex(cardId);
if (cardIndex >= 0) {
this.setState(prev => update(prev, {
view: {
result: {$unset: [cardIndex]}
},
loading: {$set: false}
}));
}
}
}

componentDidMount = () => {
const {boardId} = this.props;
getLayout(boardId).then(res =>
Expand Down
5 changes: 5 additions & 0 deletions src/containers/Board.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class Board extends Component {
if(card.initLaneId === 0) {
// Adding card
addCard(board.boardId, targetLaneId, card.id, card.index);

if (this.sideNav) {
this.sideNav.removeCard(card.id);
}
}else{
// Moving card
if(card.initLaneId === targetLaneId){
Expand Down Expand Up @@ -196,6 +200,7 @@ class Board extends Component {
>
{sidenav && (
<Sidenav
ref={ (c) => this.sideNav = (c && c.refs && c.refs.instance) }
boardId={board.boardId}
viewId={sidenavViewId}
onClickOutside={() => this.setState({sidenav: false})}
Expand Down