mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 04:53:49 +00:00
Resolve "Afficher les noms des usagers et l'entité concerné par l'entité notifiée dans la liste des notifications"
This commit is contained in:
@@ -309,6 +309,7 @@ class NotificationController extends AbstractController
|
||||
$templateData[] = [
|
||||
'template' => $this->notificationHandlerManager->getTemplate($notification),
|
||||
'template_data' => $this->notificationHandlerManager->getTemplateData($notification),
|
||||
'handler' => $this->notificationHandlerManager->getHandler($notification),
|
||||
'notification' => $notification,
|
||||
];
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Notification;
|
||||
|
||||
use Chill\MainBundle\Entity\Notification;
|
||||
use Symfony\Contracts\Translation\TranslatableInterface;
|
||||
|
||||
interface NotificationHandlerInterface
|
||||
{
|
||||
@@ -29,4 +30,13 @@ interface NotificationHandlerInterface
|
||||
* Return true if the handler supports the handling for this notification.
|
||||
*/
|
||||
public function supports(Notification $notification, array $options = []): bool;
|
||||
|
||||
public function getTitle(Notification $notification, array $options = []): TranslatableInterface;
|
||||
|
||||
/*
|
||||
* return list<Person>
|
||||
*/
|
||||
public function getAssociatedPersons(Notification $notification, array $options = []): array;
|
||||
|
||||
public function getRelatedEntity(Notification $notification): ?object;
|
||||
}
|
||||
|
@@ -13,11 +13,10 @@ namespace Chill\MainBundle\Notification;
|
||||
|
||||
use Chill\MainBundle\Entity\Notification;
|
||||
use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
final readonly class NotificationHandlerManager
|
||||
{
|
||||
public function __construct(private iterable $handlers, private EntityManagerInterface $em) {}
|
||||
public function __construct(private iterable $handlers) {}
|
||||
|
||||
/**
|
||||
* @throw NotificationHandlerNotFound if handler is not found
|
||||
|
@@ -10,6 +10,19 @@ div.notification {
|
||||
margin-right: 0.3em;
|
||||
}
|
||||
}
|
||||
h4.notification-subtitle {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
ul.notification-related-entities {
|
||||
margin: 0.5rem 0;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
|
||||
& > li {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
}
|
||||
div.read {
|
||||
h2.notification-title,
|
||||
h6.notification-title {
|
||||
@@ -52,7 +65,7 @@ div.notification-show {
|
||||
li {
|
||||
span.item-key {
|
||||
display: inline-block;
|
||||
width: 3em;
|
||||
padding: 0.1em 0.3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,4 +110,4 @@ span.counter {
|
||||
padding: 0 0.4rem;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,21 +11,59 @@
|
||||
</h2>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro insert_onthefly(type, entity, parent = null) %}
|
||||
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
|
||||
action: 'show', displayBadge: true,
|
||||
targetEntity: { name: type, id: entity.id },
|
||||
buttonText: entity|chill_entity_render_string,
|
||||
isDead: entity.deathdate is defined and entity.deathdate is not null,
|
||||
parent: parent
|
||||
} %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro relatedEntity(c) %}
|
||||
{% if c.data is defined %}
|
||||
{% set notification = c.data.notification %}
|
||||
{% set handler = c.data.handler %}
|
||||
<div class="item-row">
|
||||
<h4 class="notification-subtitle">
|
||||
<span>{{ handler.getTitle(notification)|trans }}</span>
|
||||
</h4>
|
||||
</div>
|
||||
{% set associateds = handler.getAssociatedPersons(notification) %}
|
||||
{% if associateds|length > 0 %}
|
||||
<div class="item-row">
|
||||
<ul class="notification-related-entities">
|
||||
{% for ap in associateds %}
|
||||
<li>
|
||||
{% if ap.person is defined %}
|
||||
{{ _self.insert_onthefly('person', ap.person) }}
|
||||
{% else %}
|
||||
{{ _self.insert_onthefly('person', ap) }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
{% macro header(c) %}
|
||||
<div class="item-row notification-header mt-2">
|
||||
<div class="item-col">
|
||||
<ul class="small_in_title">
|
||||
{% if c.step is not defined or c.step == 'inbox' %}
|
||||
<li class="notification-from">
|
||||
<span class="item-key">
|
||||
<abbr title="{{ 'notification.received_from' | trans }}">
|
||||
{{ "notification.from" | trans }} :
|
||||
</abbr>
|
||||
</span>
|
||||
<span class="item-key">
|
||||
<abbr title="{{ 'notification.received_from' | trans }}">
|
||||
{{ "notification.from" | trans }} :
|
||||
</abbr>
|
||||
</span>
|
||||
{% if not c.notification.isSystem %}
|
||||
<span class="badge-user">
|
||||
{{ c.notification.sender | chill_entity_render_string({'at_date': c.notification.date}) }}
|
||||
</span>
|
||||
{{ c.notification.sender | chill_entity_render_string({'at_date': c.notification.date}) }}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="badge-user system">{{ "notification.is_system" | trans }}</span>
|
||||
{% endif %}
|
||||
@@ -185,6 +223,7 @@
|
||||
>
|
||||
{{ _self.title(_context) }}
|
||||
</button>
|
||||
{{ _self.relatedEntity(_context) }}
|
||||
{{ _self.header(_context) }}
|
||||
</div>
|
||||
<div
|
||||
@@ -198,6 +237,7 @@
|
||||
{{ _self.actions(_context) }}
|
||||
{% else %}
|
||||
{{ _self.title(_context) }}
|
||||
{{ _self.relatedEntity(_context) }}
|
||||
{{ _self.header(_context) }}
|
||||
{{ _self.content(_context) }}
|
||||
{{ _self.actions(_context) }}
|
||||
|
@@ -23,7 +23,9 @@
|
||||
{% include '@ChillMain/Notification/_list_item.html.twig' with {
|
||||
'data': {
|
||||
'template': handler.getTemplate(notification),
|
||||
'template_data': handler.getTemplateData(notification)
|
||||
'template_data': handler.getTemplateData(notification),
|
||||
'handler': handler,
|
||||
'notification': notification
|
||||
},
|
||||
'action_button': false,
|
||||
'full_content': true,
|
||||
|
@@ -11,5 +11,5 @@
|
||||
}) %}
|
||||
</div>
|
||||
{% else %}
|
||||
<h2>{{ 'workflow.deleted_title'|trans }}</h2>
|
||||
<h2>{{ 'workflow.deleted'|trans }}</h2>
|
||||
{% endif %}
|
||||
|
@@ -17,6 +17,8 @@ use Chill\MainBundle\Notification\NotificationHandlerInterface;
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Translation\TranslatableMessage;
|
||||
use Symfony\Contracts\Translation\TranslatableInterface;
|
||||
|
||||
class WorkflowNotificationHandler implements NotificationHandlerInterface
|
||||
{
|
||||
@@ -29,7 +31,7 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
|
||||
|
||||
public function getTemplateData(Notification $notification, array $options = []): array
|
||||
{
|
||||
$entityWorkflow = $this->entityWorkflowRepository->find($notification->getRelatedEntityId());
|
||||
$entityWorkflow = $this->getRelatedEntity($notification);
|
||||
|
||||
return [
|
||||
'entity_workflow' => $entityWorkflow,
|
||||
@@ -61,4 +63,29 @@ class WorkflowNotificationHandler implements NotificationHandlerInterface
|
||||
{
|
||||
return EntityWorkflow::class === $notification->getRelatedEntityClass();
|
||||
}
|
||||
|
||||
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
|
||||
{
|
||||
if (null === $entityWorkflow = $this->getRelatedEntity($notification)) {
|
||||
return new TranslatableMessage('workflow.deleted');
|
||||
}
|
||||
|
||||
return new TranslatableMessage($this->entityWorkflowManager->getHandler($entityWorkflow)->getEntityTitle($entityWorkflow));
|
||||
}
|
||||
|
||||
public function getAssociatedPersons(Notification $notification, array $options = []): array
|
||||
{
|
||||
if (null === $entityWorkflow = $this->getRelatedEntity($notification)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$associatedPersons = $this->entityWorkflowManager->getHandler($entityWorkflow)->getEntityData($entityWorkflow)['persons'];
|
||||
|
||||
return is_array($associatedPersons) ? $associatedPersons : $associatedPersons->getValues();
|
||||
}
|
||||
|
||||
public function getRelatedEntity(Notification $notification): ?EntityWorkflow
|
||||
{
|
||||
return $this->entityWorkflowRepository->find($notification->getRelatedEntityId());
|
||||
}
|
||||
}
|
||||
|
@@ -508,6 +508,7 @@ Follow workflow: Suivre la décision
|
||||
Workflow history: Historique de la décision
|
||||
|
||||
workflow:
|
||||
deleted: Workflow supprimé
|
||||
Created by: Créé par
|
||||
My decision: Ma décision
|
||||
Next step: Prochaine étape
|
||||
@@ -526,9 +527,6 @@ workflow:
|
||||
Only those users are allowed: Seuls ces utilisateurs sont autorisés
|
||||
My workflows: Mes workflows
|
||||
No workflow: Aucun workflow
|
||||
Evaluation (n°%eval%): "Évaluation (n°%eval%)"
|
||||
Document (n°%doc%): "Document (n°%doc%)"
|
||||
Work (n°%w%): "Action d'accompagnement (n°%w%)"
|
||||
subscribed: Workflows suivis
|
||||
cc: Workflows dont je suis en copie
|
||||
dest: Workflows en attente d'action
|
||||
@@ -575,7 +573,6 @@ workflow:
|
||||
transition_destinee_emails_help: Le lien sécurisé sera envoyé à chaque adresse indiquée
|
||||
sent_through_secured_link: Envoi par lien sécurisé
|
||||
public_views_by_ip: Visualisation par adresse IP
|
||||
deleted_title: Workflow supprimé
|
||||
May not associate a document: Le workflow ne concerne pas un document
|
||||
|
||||
public_link:
|
||||
|
@@ -395,9 +395,6 @@ workflow:
|
||||
Only those users are allowed: Seuls ces utilisateurs sont autorisés
|
||||
My workflows: Mes workflows
|
||||
No workflow: Aucun workflow
|
||||
Evaluation (n°%eval%): "Évaluation (n°%eval%)"
|
||||
Document (n°%doc%): "Document (n°%doc%)"
|
||||
Work (n°%w%): "Action d'accompagnement (n°%w%)"
|
||||
subscribed: Workflows suivis
|
||||
dest: Workflows en attente d'action
|
||||
cc: Workflows dont je suis en copie
|
||||
|
Reference in New Issue
Block a user