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:
LenaertsJ 2025-01-23 11:34:16 +00:00 committed by Julien Fastré
parent 9e191f1b5b
commit 9a5fd67842
28 changed files with 267 additions and 33 deletions

View File

@ -0,0 +1,6 @@
kind: Feature
body: 'Notification list: display the concerned person''s badges in the list'
time: 2025-01-23T12:27:36.851039416+01:00
custom:
Issue: "319"
SchemaChange: No schema change

View File

@ -15,10 +15,13 @@ use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
final readonly class ActivityNotificationHandler implements NotificationHandlerInterface
{
public function __construct(private ActivityRepository $activityRepository) {}
public function __construct(private ActivityRepository $activityRepository, private TranslatableStringHelperInterface $translatableStringHelper) {}
public function getTemplate(Notification $notification, array $options = []): string
{
@ -37,4 +40,30 @@ final readonly class ActivityNotificationHandler implements NotificationHandlerI
{
return Activity::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $activity = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('activity.deleted');
}
return new TranslatableMessage('activity.title', [
'date' => $activity->getDate(),
'type' => $this->translatableStringHelper->localize($activity->getActivityType()->getName()),
]);
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $activity = $this->getRelatedEntity($notification)) {
return [];
}
return $activity->getPersonsAssociated();
}
public function getRelatedEntity(Notification $notification): ?Activity
{
return $this->activityRepository->find($notification->getRelatedEntityId());
}
}

View File

@ -14,3 +14,5 @@ export:
describe_action_with_subject: >-
Filtré par personne ayant eu un échange entre le {date_from, date} et le {date_to, date}, et un de ces sujets choisis: {reasons}
activity:
title: Échange du {date, date, long} - {type}

View File

@ -101,6 +101,7 @@ activity:
Insert a document: Insérer un document
Remove a document: Supprimer le document
comment: Commentaire
deleted: Échange supprimé
No documents: Aucun document
# activity filter in list page

View File

@ -69,7 +69,7 @@ final readonly class AccompanyingCourseDocumentWorkflowHandler implements Entity
return $this->translator->trans('workflow.Document deleted');
}
return $this->translator->trans('workflow.Document (n°%doc%)', ['%doc%' => $entityWorkflow->getRelatedEntityId()])
return $this->translator->trans('entity_display_title.Document (n°%doc%)', ['%doc%' => $entityWorkflow->getRelatedEntityId()])
.' - '.$doc->getTitle();
}

View File

@ -94,3 +94,7 @@ CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE: Supprimer un document
CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE: Voir les documents
CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS: Voir les détails d'un document
CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE: Modifier un document
entity_display_title:
Document (n°%doc%): "Document (n°%doc%)"
Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval%

View File

@ -0,0 +1,2 @@
entity_display_title:
Doc for evaluation (n°%eval%): Evaluatiedocument (n°%eval%)

View File

@ -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,
];
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}
}
}

View File

@ -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) }}

View File

@ -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,

View File

@ -11,5 +11,5 @@
}) %}
</div>
{% else %}
<h2>{{ 'workflow.deleted_title'|trans }}</h2>
<h2>{{ 'workflow.deleted'|trans }}</h2>
{% endif %}

View File

@ -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());
}
}

View File

@ -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:

View File

@ -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

View File

@ -15,6 +15,8 @@ use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
final readonly class AccompanyingPeriodNotificationHandler implements NotificationHandlerInterface
{
@ -37,4 +39,27 @@ final readonly class AccompanyingPeriodNotificationHandler implements Notificati
{
return AccompanyingPeriod::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $period = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('accompanying_period.deleted');
}
return new TranslatableMessage('periods.title', ['id' => $period->getId()]);
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $period = $this->getRelatedEntity($notification)) {
return [];
}
return $period->getParticipations()->getValues();
}
public function getRelatedEntity(Notification $notification): ?AccompanyingPeriod
{
return $this->accompanyingPeriodRepository->find($notification->getRelatedEntityId());
}
}

View File

@ -15,6 +15,8 @@ use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocumentRepository;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
final readonly class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implements NotificationHandlerInterface
{
@ -38,4 +40,33 @@ final readonly class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler
{
return AccompanyingPeriodWorkEvaluationDocument::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $eval = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('evaluation.deleted');
}
return new TranslatableMessage(
'accompanying_course_evaluation_document.title',
[
'id' => $eval->getId(),
'doc_title' => $eval->getTitle(),
]
);
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $eval = $this->getRelatedEntity($notification)) {
return [];
}
return $eval->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork()->getPersons()->getValues();
}
public function getRelatedEntity(Notification $notification): ?AccompanyingPeriodWorkEvaluationDocument
{
return $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($notification->getRelatedEntityId());
}
}

View File

@ -13,12 +13,15 @@ namespace Chill\PersonBundle\Notification;
use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationHandlerInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
final readonly class AccompanyingPeriodWorkNotificationHandler implements NotificationHandlerInterface
{
public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) {}
public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository, private TranslatableStringHelperInterface $translatableStringHelper) {}
public function getTemplate(Notification $notification, array $options = []): string
{
@ -37,4 +40,30 @@ final readonly class AccompanyingPeriodWorkNotificationHandler implements Notifi
{
return AccompanyingPeriodWork::class === $notification->getRelatedEntityClass();
}
public function getTitle(Notification $notification, array $options = []): TranslatableInterface
{
if (null === $work = $this->getRelatedEntity($notification)) {
return new TranslatableMessage('accompanying_course_work.deleted');
}
return new TranslatableMessage('accompanying_period_work.title', [
'id' => $work->getId(),
'action_title' => $this->translatableStringHelper->localize($work->getSocialAction()->getTitle()),
]);
}
public function getAssociatedPersons(Notification $notification, array $options = []): array
{
if (null === $work = $this->getRelatedEntity($notification)) {
return [];
}
return $work->getPersons()->getValues();
}
public function getRelatedEntity(Notification $notification): ?AccompanyingPeriodWork
{
return $this->accompanyingPeriodWorkRepository->find($notification->getRelatedEntityId());
}
}

View File

@ -244,7 +244,7 @@ export default {
};
</script>
<style lang="scss">
<style lang="scss" scoped>
.filtered {
filter: grayscale(1) opacity(0.6);
}

View File

@ -372,7 +372,11 @@ export default {
};
</script>
<style lang="scss">
<style lang="scss" scoped>
@import "ChillMainAssets/module/bootstrap/shared";
@import "ChillPersonAssets/chill/scss/mixins";
@import "ChillMainAssets/chill/scss/chill_variables";
.lastname:before {
content: " ";
}
@ -384,6 +388,12 @@ div.flex-table {
width: 33%;
}
@include media-breakpoint-down(sm) {
div.item-col:first-child {
width: unset;
}
}
div.item-col:last-child {
justify-content: flex-start;
}

View File

@ -74,7 +74,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
}
return $this->translator->trans(
'workflow.Doc for evaluation (n°%eval%)',
'entity_display_title.Doc for evaluation (n°%eval%)',
['%eval%' => $entityWorkflow->getRelatedEntityId()]
).' ('.$this->translatableStringHelper->localize($doc->getAccompanyingPeriodWorkEvaluation()
->getEvaluation()->getTitle()).') '.$doc->getTitle();

View File

@ -56,7 +56,7 @@ readonly class AccompanyingPeriodWorkEvaluationWorkflowHandler implements Entity
$evaluation = $this->getRelatedEntity($entityWorkflow);
return $this->translator->trans(
'workflow.Evaluation (n°%eval%)',
'entity_display_title.Evaluation (n°%eval%)',
['%eval%' => $entityWorkflow->getRelatedEntityId()]
).' - '.$this->translatableStringHelper->localize($evaluation->getEvaluation()->getTitle());
}

View File

@ -59,7 +59,7 @@ readonly class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHa
}
return
$this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()])
$this->translator->trans('entity_display_title.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()])
.' - '.$this->translatableStringHelper->localize($work->getSocialAction()->getTitle());
}

View File

@ -118,6 +118,7 @@ household_composition:
}
periods:
title: Parcours d'accompagnement (n°{id})
show closed periods: >-
{nb_items, plural,
=0 {Aucun parcours clôturé}
@ -177,5 +178,9 @@ exports:
}
accompanying_course_evaluation_document:
title: Évaluation (n°{id}) - {doc_title}
duplicated_at: >-
Dupliqué le {at, date, long} à {at, time, short}
accompanying_period_work:
title: Action d'accompagnement (n°{id}) - {action_title}

View File

@ -732,6 +732,7 @@ origin:
noActiveAfter: désactivé après
evaluation:
deleted: Évaluation supprimé
delay: Délai
notificationDelay: Délai de notification
url: Lien internet
@ -788,6 +789,7 @@ person_admin:
# specific to accompanying period
accompanying_period:
deleted: Parcours d'accompagnment supprimé
dates: Période
dates_from_%opening_date%: Ouvert depuis le %opening_date%
dates_from_%opening_date%_to_%closing_date%: Ouvert du %opening_date% au %closing_date%
@ -876,6 +878,7 @@ Accompanying Course Action: Action d'accompagnement
Are you sure you want to remove this work of the accompanying period %name% ?: Êtes-vous sûr de vouloir supprimer cette action du parcours d'accompagnement %name% ?
The accompanying period work has been successfully removed.: L'action d'accompagnement a été supprimée.
accompanying_course_work:
deleted: Action d'accompagnement supprimé
create: Créer une action
Create accompanying course work: Créer une action d'accompagnement
Edit accompanying course work: Modifier une action d'accompagnement
@ -962,7 +965,6 @@ Display draft periods created by me: Affiche les parcours en attente de confirma
Number of periods: Nombre de parcours
workflow:
Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval%
doc for evaluation deleted: Document supprimé dans une évaluation
SocialAction deleted: Action sociale supprimée
signature_list:
@ -1470,3 +1472,8 @@ generic_doc:
filter:
keys:
accompanying_period_work_evaluation_document: Document des actions d'accompagnement
entity_display_title:
Evaluation (n°%eval%): "Évaluation (n°%eval%)"
Work (n°%w%): "Action d'accompagnement (n°%w%)"
Accompanying Course (n°%w%): "Parcours d'accompagnement (n°%w%)"

View File

@ -578,9 +578,6 @@ Linked evaluations: Gerelateerde evaluaties
My accompanying periods: Mijn hulpverleningstrajecten
My accompanying periods in draft: Mijn hulpverleningstrajecten in ontwerp
workflow:
Doc for evaluation (n°%eval%): Evaluatiedocument n°%eval%
period_by_user_list:
Period by user: Hulpverleningstrajecten per gebruiker
Pick a user: Selecteer een gebruiker om zijn/haar hulpverleningstrajecten te zien