mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-26 13:48:32 +00:00
Compare commits
2 Commits
v4.8.2
...
459-invita
| Author | SHA1 | Date | |
|---|---|---|---|
| cb56c7d0ad | |||
| 42ac813b6f |
6
.changes/unreleased/Feature-20251125-165811.yaml
Normal file
6
.changes/unreleased/Feature-20251125-165811.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
kind: Feature
|
||||||
|
body: Add a counter for invitations awaiting reply
|
||||||
|
time: 2025-11-25T16:58:11.780678466+01:00
|
||||||
|
custom:
|
||||||
|
Issue: "459"
|
||||||
|
SchemaChange: No schema change
|
||||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\CalendarBundle\Menu;
|
namespace Chill\CalendarBundle\Menu;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Repository\InviteRepository;
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
@@ -18,10 +19,12 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||||||
|
|
||||||
class UserMenuBuilder implements LocalMenuBuilderInterface
|
class UserMenuBuilder implements LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly Security $security, public TranslatorInterface $translator) {}
|
public function __construct(private readonly Security $security, public TranslatorInterface $translator, private readonly InviteRepository $inviteRepository) {}
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
|
$invitationsPending = $this->inviteRepository->countPendingInvitesByUser($this->security->getUser());
|
||||||
|
|
||||||
if ($this->security->isGranted('ROLE_USER')) {
|
if ($this->security->isGranted('ROLE_USER')) {
|
||||||
$menu->addChild('My calendar list', [
|
$menu->addChild('My calendar list', [
|
||||||
'route' => 'chill_calendar_calendar_list_my',
|
'route' => 'chill_calendar_calendar_list_my',
|
||||||
@@ -30,12 +33,14 @@ class UserMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'order' => 8,
|
'order' => 8,
|
||||||
'icon' => 'tasks',
|
'icon' => 'tasks',
|
||||||
]);
|
]);
|
||||||
$menu->addChild('invite.list.title', [
|
$menu->addChild(
|
||||||
'route' => 'chill_calendar_invitations_list_my',
|
$this->translator->trans('invite.menu with counter', ['nb' => $invitationsPending]),
|
||||||
])
|
['route' => 'chill_calendar_invitations_list_my']
|
||||||
|
)
|
||||||
->setExtras([
|
->setExtras([
|
||||||
'order' => 9,
|
'order' => 9,
|
||||||
'icon' => 'tasks',
|
'icon' => 'tasks',
|
||||||
|
'counter' => 0 < $invitationsPending ? $invitationsPending : null,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,25 @@ class InviteRepository implements ObjectRepository
|
|||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function countPendingInvitesByUser(User $user): int
|
||||||
|
{
|
||||||
|
$qb = $this->entityRepository->createQueryBuilder('i');
|
||||||
|
|
||||||
|
$qb->select('COUNT(i)')
|
||||||
|
->where(
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->eq('i.user', ':user'),
|
||||||
|
$qb->expr()->eq('i.status', ':status')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setParameters([
|
||||||
|
'user' => $user,
|
||||||
|
'status' => Invite::PENDING,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $qb->getQuery()->getSingleScalarResult();
|
||||||
|
}
|
||||||
|
|
||||||
public function buildAcceptedInviteByUserAndDateRangeQuery(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to)
|
public function buildAcceptedInviteByUserAndDateRangeQuery(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to)
|
||||||
{
|
{
|
||||||
$qb = $this->entityRepository->createQueryBuilder('i');
|
$qb = $this->entityRepository->createQueryBuilder('i');
|
||||||
|
|||||||
@@ -6,3 +6,11 @@ chill_calendar:
|
|||||||
few {# rendez-vous sont ignorés par le filtre de date. Modifiez le filtre de date pour les voir apparaitre.}
|
few {# rendez-vous sont ignorés par le filtre de date. Modifiez le filtre de date pour les voir apparaitre.}
|
||||||
other {# rendez-vous sont ignorés par le filtre de date. Modifiez le filtre de date pour les voir apparaitre.}
|
other {# rendez-vous sont ignorés par le filtre de date. Modifiez le filtre de date pour les voir apparaitre.}
|
||||||
}
|
}
|
||||||
|
invite:
|
||||||
|
menu with counter: >-
|
||||||
|
{nb, plural,
|
||||||
|
=0 {Mes invitations}
|
||||||
|
one {# invitation}
|
||||||
|
few {# invitations}
|
||||||
|
other {# invitations}
|
||||||
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ invite:
|
|||||||
list:
|
list:
|
||||||
none: Il n'y aucun invitation
|
none: Il n'y aucun invitation
|
||||||
title: Mes invitations
|
title: Mes invitations
|
||||||
|
number of invitations waiting: Invitations en attente
|
||||||
|
|
||||||
# exports
|
# exports
|
||||||
Exports of calendar: Exports des rendez-vous
|
Exports of calendar: Exports des rendez-vous
|
||||||
|
|||||||
Reference in New Issue
Block a user