mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Feature: show 'Cc' for notications as Cc
This commit is contained in:
parent
94046aab81
commit
3de5d29fe8
@ -14,6 +14,7 @@ namespace Chill\MainBundle\Controller;
|
|||||||
use Chill\MainBundle\Entity\Notification;
|
use Chill\MainBundle\Entity\Notification;
|
||||||
use Chill\MainBundle\Entity\NotificationComment;
|
use Chill\MainBundle\Entity\NotificationComment;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||||
use Chill\MainBundle\Form\NotificationCommentType;
|
use Chill\MainBundle\Form\NotificationCommentType;
|
||||||
use Chill\MainBundle\Form\NotificationType;
|
use Chill\MainBundle\Form\NotificationType;
|
||||||
use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound;
|
use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound;
|
||||||
@ -21,6 +22,7 @@ use Chill\MainBundle\Notification\NotificationHandlerManager;
|
|||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Repository\NotificationRepository;
|
use Chill\MainBundle\Repository\NotificationRepository;
|
||||||
use Chill\MainBundle\Repository\UserRepository;
|
use Chill\MainBundle\Repository\UserRepository;
|
||||||
|
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
|
||||||
use Chill\MainBundle\Security\Authorization\NotificationVoter;
|
use Chill\MainBundle\Security\Authorization\NotificationVoter;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@ -68,7 +70,8 @@ class NotificationController extends AbstractController
|
|||||||
NotificationHandlerManager $notificationHandlerManager,
|
NotificationHandlerManager $notificationHandlerManager,
|
||||||
PaginatorFactory $paginatorFactory,
|
PaginatorFactory $paginatorFactory,
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
UserRepository $userRepository
|
UserRepository $userRepository,
|
||||||
|
EntityWorkflowRepository $entityWorkflowRepository
|
||||||
) {
|
) {
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
@ -79,6 +82,7 @@ class NotificationController extends AbstractController
|
|||||||
$this->paginatorFactory = $paginatorFactory;
|
$this->paginatorFactory = $paginatorFactory;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->userRepository = $userRepository;
|
$this->userRepository = $userRepository;
|
||||||
|
$this->entityWorkflowRepository = $entityWorkflowRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -345,6 +349,7 @@ class NotificationController extends AbstractController
|
|||||||
'appendCommentForm' => isset($appendCommentForm) ? $appendCommentForm->createView() : null,
|
'appendCommentForm' => isset($appendCommentForm) ? $appendCommentForm->createView() : null,
|
||||||
'editedCommentForm' => isset($editedCommentForm) ? $editedCommentForm->createView() : null,
|
'editedCommentForm' => isset($editedCommentForm) ? $editedCommentForm->createView() : null,
|
||||||
'editedCommentId' => $commentId ?? null,
|
'editedCommentId' => $commentId ?? null,
|
||||||
|
'notificationCc' => $this->isNotificationCc($notification),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// we mark the notification as read after having computed the response
|
// we mark the notification as read after having computed the response
|
||||||
@ -364,6 +369,21 @@ class NotificationController extends AbstractController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isNotificationCc(Notification $notification): bool
|
||||||
|
{
|
||||||
|
$notificationCc = false;
|
||||||
|
|
||||||
|
if ($notification->getRelatedEntityClass() === EntityWorkflow::class) {
|
||||||
|
$relatedEntity = $this->entityWorkflowRepository->findOneBy(['id' => $notification->getRelatedEntityId()]);
|
||||||
|
|
||||||
|
if ($relatedEntity->getCurrentStepCreatedBy() !== $this->security->getUser()) {
|
||||||
|
$notificationCc = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $notificationCc;
|
||||||
|
}
|
||||||
|
|
||||||
private function itemsForTemplate(array $notifications): array
|
private function itemsForTemplate(array $notifications): array
|
||||||
{
|
{
|
||||||
$templateData = [];
|
$templateData = [];
|
||||||
@ -373,6 +393,7 @@ class NotificationController extends AbstractController
|
|||||||
'template' => $this->notificationHandlerManager->getTemplate($notification),
|
'template' => $this->notificationHandlerManager->getTemplate($notification),
|
||||||
'template_data' => $this->notificationHandlerManager->getTemplateData($notification),
|
'template_data' => $this->notificationHandlerManager->getTemplateData($notification),
|
||||||
'notification' => $notification,
|
'notification' => $notification,
|
||||||
|
'isNotificationCc' => $this->isNotificationCc($notification),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,9 @@ class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $environment->render('@ChillMain/Notification/extension_list_notifications_for.html.twig', [
|
return $environment->render('@ChillMain/Notification/extension_list_notifications_for.html.twig', [
|
||||||
'notifications' => $notifications, 'appendCommentForms' => $appendCommentForms,
|
'notifications' => $notifications,
|
||||||
|
'appendCommentForms' => $appendCommentForms,
|
||||||
|
'notificationCc' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,27 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if c.notification.addressees|length > 0 %}
|
{% if c.notification.addressees|length > 0 %}
|
||||||
<li class="notification-to">
|
<li class="notification-to">
|
||||||
<span class="item-key">
|
{% if c.notification_cc is defined %}
|
||||||
|
{% if c.notification_cc %}
|
||||||
|
<span class="item-key">
|
||||||
|
<abbr title="{{ 'notification.sent_cc'|trans }}">
|
||||||
|
{{ 'notification.cc'|trans }} :
|
||||||
|
</abbr>
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="item-key">
|
||||||
|
<abbr title="{{ 'notification.sent_to'|trans }}">
|
||||||
|
{{ 'notification.to'|trans }} :
|
||||||
|
</abbr>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<span class="item-key">
|
||||||
<abbr title="{{ 'notification.sent_to'|trans }}">
|
<abbr title="{{ 'notification.sent_to'|trans }}">
|
||||||
{{ 'notification.to'|trans }} :
|
{{ 'notification.to'|trans }} :
|
||||||
</abbr>
|
</abbr>
|
||||||
</span>
|
</span>
|
||||||
|
{% endif %}
|
||||||
{% for a in c.notification.addressees %}
|
{% for a in c.notification.addressees %}
|
||||||
<span class="badge-user">
|
<span class="badge-user">
|
||||||
{{ a|chill_entity_render_string }}
|
{{ a|chill_entity_render_string }}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
'full_content': true,
|
'full_content': true,
|
||||||
'fold_item': true,
|
'fold_item': true,
|
||||||
'action_button': true,
|
'action_button': true,
|
||||||
|
'notification_cc': notificationCc,
|
||||||
} %}{#
|
} %}{#
|
||||||
#}
|
#}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -50,7 +50,8 @@
|
|||||||
{% for data in datas %}
|
{% for data in datas %}
|
||||||
{% set notification = data.notification %}
|
{% set notification = data.notification %}
|
||||||
{% include 'ChillMainBundle:Notification:_list_item.html.twig' with {
|
{% include 'ChillMainBundle:Notification:_list_item.html.twig' with {
|
||||||
'fold_item': true
|
'fold_item': true,
|
||||||
|
'notification_cc': data.isNotificationCc
|
||||||
} %}
|
} %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
},
|
},
|
||||||
'action_button': false,
|
'action_button': false,
|
||||||
'full_content': true,
|
'full_content': true,
|
||||||
'fold_item': false
|
'fold_item': false,
|
||||||
|
'notification_cc': notificationCc
|
||||||
} %}
|
} %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -525,7 +525,9 @@ notification:
|
|||||||
list: Notifications
|
list: Notifications
|
||||||
Sent: Envoyé
|
Sent: Envoyé
|
||||||
to: À
|
to: À
|
||||||
|
cc: Cc
|
||||||
sent_to: Destinataire(s)
|
sent_to: Destinataire(s)
|
||||||
|
sent_cc: En copie
|
||||||
from: De
|
from: De
|
||||||
received_from: Expéditeur
|
received_from: Expéditeur
|
||||||
you were notified by %sender%: Vous avez été notifié par %sender%
|
you were notified by %sender%: Vous avez été notifié par %sender%
|
||||||
|
@ -446,7 +446,9 @@ notification:
|
|||||||
list: Notifications
|
list: Notifications
|
||||||
Sent: Envoyé
|
Sent: Envoyé
|
||||||
to: À
|
to: À
|
||||||
|
cc: Cc
|
||||||
sent_to: Destinataire(s)
|
sent_to: Destinataire(s)
|
||||||
|
sent_cc: En copie
|
||||||
from: De
|
from: De
|
||||||
received_from: Expéditeur
|
received_from: Expéditeur
|
||||||
you were notified by %sender%: Vous avez été notifié par %sender%
|
you were notified by %sender%: Vous avez été notifié par %sender%
|
||||||
|
Loading…
x
Reference in New Issue
Block a user