Last active
May 18, 2020 17:29
-
-
Save wdchris/7a8a62679e8efda5def4d9adb9dbe6a3 to your computer and use it in GitHub Desktop.
A function to filter Trello lists based on a label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const filterCards = (boards, filter) => | |
boards.reduce((result, board) => { | |
const cardsResult = board.lists.reduce((cards, list) => { | |
if ( | |
board.closed === false && | |
list.closed === false && | |
(filter.length === 0 || | |
list.name.toLowerCase() === filter.toLowerCase()) | |
) { | |
return cards.concat(list.cards.filter(card => card.closed === false)); | |
} | |
return cards; | |
}, []); | |
if (cardsResult.length > 0) { | |
result.push({ board: board, cards: cardsResult }); | |
} | |
return result; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment