feat: Show how many cards a list holds
A board level switch, off by default. With it on, each list puts its card count on the add-card button. Useful to a board that is being kept to a size and noise to one that is not, which is why it is a choice rather than always on. The count is every card in the list, not the ones a filter leaves visible. Those answer different questions: how full is this list, versus how many match what I am looking at right now. The first is the one a counter is for, and it is also what the same switch counts in Pro, so a board keeps its meaning across an upgrade. The column matches Pro's name, type and default, so the setting survives that upgrade rather than being dropped on the way.
This commit is contained in:
@@ -65,6 +65,27 @@ export const makeSelectFilteredCardIdsByListId = () =>
|
||||
|
||||
export const selectFilteredCardIdsByListId = makeSelectFilteredCardIdsByListId();
|
||||
|
||||
// How many cards the list holds.
|
||||
//
|
||||
// Unfiltered on purpose: a filter hides cards, it does not remove them, and a
|
||||
// count that fell as the filter narrowed would say the list had emptied.
|
||||
export const makeSelectCardCountByListId = () =>
|
||||
createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
({ List }, id) => {
|
||||
const listModel = List.withId(id);
|
||||
|
||||
if (!listModel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return listModel.getCardsModelArray().length;
|
||||
},
|
||||
);
|
||||
|
||||
export const selectCardCountByListId = makeSelectCardCountByListId();
|
||||
|
||||
export const selectIsListWithIdAvailableForCurrentUser = createSelector(
|
||||
orm,
|
||||
(_, id) => id,
|
||||
@@ -171,6 +192,8 @@ export default {
|
||||
selectCardIdsByListId,
|
||||
makeSelectFilteredCardIdsByListId,
|
||||
selectFilteredCardIdsByListId,
|
||||
makeSelectCardCountByListId,
|
||||
selectCardCountByListId,
|
||||
selectIsListWithIdAvailableForCurrentUser,
|
||||
selectCurrentListId,
|
||||
selectCurrentList,
|
||||
|
||||
Reference in New Issue
Block a user