1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

feat: Attachments icon on front of cards

Closes #225
This commit is contained in:
Maksim Eltyshev 2024-10-22 21:38:04 +02:00
parent 96a1049fb6
commit 0bc2975797
3 changed files with 36 additions and 1 deletions

View file

@ -32,6 +32,7 @@ const Card = React.memo(
listId, listId,
projectId, projectId,
isPersisted, isPersisted,
attachmentsTotal,
notificationsTotal, notificationsTotal,
users, users,
labels, labels,
@ -107,7 +108,11 @@ const Card = React.memo(
)} )}
<div className={styles.name}>{name}</div> <div className={styles.name}>{name}</div>
{tasks.length > 0 && <Tasks items={tasks} />} {tasks.length > 0 && <Tasks items={tasks} />}
{(description || dueDate || stopwatch || notificationsTotal > 0) && ( {(description ||
dueDate ||
stopwatch ||
attachmentsTotal > 0 ||
notificationsTotal > 0) && (
<span className={styles.attachments}> <span className={styles.attachments}>
{notificationsTotal > 0 && ( {notificationsTotal > 0 && (
<span <span
@ -143,6 +148,14 @@ const Card = React.memo(
</span> </span>
</span> </span>
)} )}
{attachmentsTotal > 0 && (
<span className={classNames(styles.attachment, styles.attachmentLeft)}>
<span className={styles.attachmentContent}>
<Icon name="attach" />
{attachmentsTotal}
</span>
</span>
)}
</span> </span>
)} )}
{users.length > 0 && ( {users.length > 0 && (
@ -238,6 +251,7 @@ Card.propTypes = {
listId: PropTypes.string.isRequired, listId: PropTypes.string.isRequired,
projectId: PropTypes.string.isRequired, projectId: PropTypes.string.isRequired,
isPersisted: PropTypes.bool.isRequired, isPersisted: PropTypes.bool.isRequired,
attachmentsTotal: PropTypes.number.isRequired,
notificationsTotal: PropTypes.number.isRequired, notificationsTotal: PropTypes.number.isRequired,
/* eslint-disable react/forbid-prop-types */ /* eslint-disable react/forbid-prop-types */
users: PropTypes.array.isRequired, users: PropTypes.array.isRequired,

View file

@ -35,6 +35,7 @@ const makeMapStateToProps = () => {
const users = selectUsersByCardId(state, id); const users = selectUsersByCardId(state, id);
const labels = selectLabelsByCardId(state, id); const labels = selectLabelsByCardId(state, id);
const tasks = selectTasksByCardId(state, id); const tasks = selectTasksByCardId(state, id);
const attachmentsTotal = selectors.selectAttachmentsTotalByCardId(state, id);
const notificationsTotal = selectNotificationsTotalByCardId(state, id); const notificationsTotal = selectNotificationsTotalByCardId(state, id);
const isCurrentUserEditor = const isCurrentUserEditor =
@ -53,6 +54,7 @@ const makeMapStateToProps = () => {
listId, listId,
projectId, projectId,
isPersisted, isPersisted,
attachmentsTotal,
notificationsTotal, notificationsTotal,
users, users,
labels, labels,

View file

@ -115,6 +115,23 @@ export const makeSelectTasksByCardId = () =>
export const selectTasksByCardId = 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 = () => export const makeSelectLastActivityIdByCardId = () =>
createSelector( createSelector(
orm, orm,
@ -334,6 +351,8 @@ export default {
selectTaskIdsByCardId, selectTaskIdsByCardId,
makeSelectTasksByCardId, makeSelectTasksByCardId,
selectTasksByCardId, selectTasksByCardId,
makeSelectAttachmentsTotalByCardId,
selectAttachmentsTotalByCardId,
makeSelectLastActivityIdByCardId, makeSelectLastActivityIdByCardId,
selectLastActivityIdByCardId, selectLastActivityIdByCardId,
makeSelectNotificationsByCardId, makeSelectNotificationsByCardId,