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

Commit

Permalink
Merge pull request #1126 from metasfresh/dev-1066
Browse files Browse the repository at this point in the history
#1066 Fix board's sidebar list didn't get updated after dragging card
  • Loading branch information
metas-ts authored Aug 8, 2017
2 parents f53d072 + 2a7d29f commit 17f3a13
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
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

0 comments on commit 17f3a13

Please sign in to comment.