diff --git a/client/src/components/Card/Card.jsx b/client/src/components/Card/Card.jsx index d715ac3ce..f3b1af698 100755 --- a/client/src/components/Card/Card.jsx +++ b/client/src/components/Card/Card.jsx @@ -32,6 +32,7 @@ const Card = React.memo( listId, projectId, isPersisted, + attachmentsTotal, notificationsTotal, users, labels, @@ -107,7 +108,11 @@ const Card = React.memo( )}
{name}
{tasks.length > 0 && } - {(description || dueDate || stopwatch || notificationsTotal > 0) && ( + {(description || + dueDate || + stopwatch || + attachmentsTotal > 0 || + notificationsTotal > 0) && ( {notificationsTotal > 0 && ( )} + {attachmentsTotal > 0 && ( + + + + {attachmentsTotal} + + + )} )} {users.length > 0 && ( @@ -238,6 +251,7 @@ Card.propTypes = { listId: PropTypes.string.isRequired, projectId: PropTypes.string.isRequired, isPersisted: PropTypes.bool.isRequired, + attachmentsTotal: PropTypes.number.isRequired, notificationsTotal: PropTypes.number.isRequired, /* eslint-disable react/forbid-prop-types */ users: PropTypes.array.isRequired, diff --git a/client/src/containers/CardContainer.js b/client/src/containers/CardContainer.js index 898280a37..aaae0a3c4 100755 --- a/client/src/containers/CardContainer.js +++ b/client/src/containers/CardContainer.js @@ -35,6 +35,7 @@ const makeMapStateToProps = () => { const users = selectUsersByCardId(state, id); const labels = selectLabelsByCardId(state, id); const tasks = selectTasksByCardId(state, id); + const attachmentsTotal = selectors.selectAttachmentsTotalByCardId(state, id); const notificationsTotal = selectNotificationsTotalByCardId(state, id); const isCurrentUserEditor = @@ -53,6 +54,7 @@ const makeMapStateToProps = () => { listId, projectId, isPersisted, + attachmentsTotal, notificationsTotal, users, labels, diff --git a/client/src/selectors/cards.js b/client/src/selectors/cards.js index d1137dc84..a55829ab9 100644 --- a/client/src/selectors/cards.js +++ b/client/src/selectors/cards.js @@ -115,6 +115,23 @@ export const makeSelectTasksByCardId = () => export const selectTasksByCardId = makeSelectTasksByCardId(); +export const makeSelectAttachmentsTotalByCardId = () => + createSelector( + orm, + (_, id) => id, + ({ Card }, id) => { + const cardModel = Card.withId(id); + + if (!cardModel) { + return cardModel; + } + + return cardModel.attachments.count(); + }, + ); + +export const selectAttachmentsTotalByCardId = makeSelectAttachmentsTotalByCardId(); + export const makeSelectLastActivityIdByCardId = () => createSelector( orm, @@ -334,6 +351,8 @@ export default { selectTaskIdsByCardId, makeSelectTasksByCardId, selectTasksByCardId, + makeSelectAttachmentsTotalByCardId, + selectAttachmentsTotalByCardId, makeSelectLastActivityIdByCardId, selectLastActivityIdByCardId, makeSelectNotificationsByCardId,