From 422788a6a31b0001615c4f98fc848f904432aa8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 28 Apr 2021 13:22:23 +0200 Subject: [PATCH] Show comment counter and highlight if unread comments are available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- css/icons.scss | 4 +++- lib/Db/Card.php | 2 ++ lib/Service/CardService.php | 6 ++++-- src/components/cards/CardBadges.vue | 29 ++++++++++++++++++++++---- tests/unit/Db/CardTest.php | 3 +++ tests/unit/Service/CardServiceTest.php | 2 +- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/css/icons.scss b/css/icons.scss index c782f125d..6f2f35167 100644 --- a/css/icons.scss +++ b/css/icons.scss @@ -22,7 +22,9 @@ .icon-activity { @include icon-color('activity-dark', 'activity', $color-black); } - +.icon-comment--unread { + @include icon-color('comment', 'actions', $color-primary, 1, true); +} .avatardiv.circles { background: var(--color-primary); diff --git a/lib/Db/Card.php b/lib/Db/Card.php index 4168c7fe2..af2c665c5 100644 --- a/lib/Db/Card.php +++ b/lib/Db/Card.php @@ -49,6 +49,7 @@ class Card extends RelationalEntity { protected $notified = false; protected $deletedAt = 0; protected $commentsUnread = 0; + protected $commentsCount = 0; protected $relatedStack = null; protected $relatedBoard = null; @@ -75,6 +76,7 @@ class Card extends RelationalEntity { $this->addRelation('attachmentCount'); $this->addRelation('participants'); $this->addRelation('commentsUnread'); + $this->addRelation('commentsCount'); $this->addResolvable('owner'); $this->addRelation('relatedStack'); diff --git a/lib/Service/CardService.php b/lib/Service/CardService.php index 629185e21..0cb733c54 100644 --- a/lib/Service/CardService.php +++ b/lib/Service/CardService.php @@ -105,8 +105,10 @@ class CardService { $card->setAttachmentCount($this->attachmentService->count($cardId)); $user = $this->userManager->get($this->currentUser); $lastRead = $this->commentsManager->getReadMark('deckCard', (string)$card->getId(), $user); - $count = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId(), $lastRead); - $card->setCommentsUnread($count); + $countUnreadComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId(), $lastRead); + $countComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId()); + $card->setCommentsUnread($countUnreadComments); + $card->setCommentsCount($countComments); $stack = $this->stackMapper->find($card->getStackId()); $board = $this->boardService->find($stack->getBoardId()); diff --git a/src/components/cards/CardBadges.vue b/src/components/cards/CardBadges.vue index c77995f5f..5d046ec7f 100644 --- a/src/components/cards/CardBadges.vue +++ b/src/components/cards/CardBadges.vue @@ -22,7 +22,13 @@