show in dashboard and overview all my assigned cards and on private boards all due cards

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2020-08-21 13:56:58 +02:00
committed by Julius Härtl
parent aa244108c8
commit 3880b25705
3 changed files with 24 additions and 11 deletions

View File

@@ -109,17 +109,30 @@ class OverviewService {
public function findAssignedCards(string $userId): array {
$userBoards = $this->findAllBoardsFromUser($userId);
$allAssignedCards = [];
$findCards = [];
foreach ($userBoards as $userBoard) {
$service = $this;
$allAssignedCards[] = array_map(static function ($card) use ($service, $userBoard, $userId) {
$service->enrich($card, $userId);
$cardData = $card->jsonSerialize();
$cardData['boardId'] = $userBoard->getId();
return $cardData;
}, $this->cardMapper->findAssignedCards($userBoard->getId(), $userId));
if (count($userBoard->getAcl()) == 0) {
// get cards with due date
$findCards[] = array_map(static function ($card) use ($service, $userBoard, $userId) {
$service->enrich($card, $userId);
$cardData = $card->jsonSerialize();
$cardData['boardId'] = $userBoard->getId();
return $cardData;
}, $this->cardMapper->findAllWithDue($userBoard->getId()));
} else {
// get assigned cards
$findCards[] = array_map(static function ($card) use ($service, $userBoard, $userId) {
$service->enrich($card, $userId);
$cardData = $card->jsonSerialize();
$cardData['boardId'] = $userBoard->getId();
return $cardData;
}, $this->cardMapper->findAssignedCards($userBoard->getId(), $userId));
}
}
return $allAssignedCards;
return $findCards;
}
// FIXME: This is duplicate code with the board service