From 9a5fd67842faa426c2356a6be1423855e38bd310 Mon Sep 17 00:00:00 2001 From: LenaertsJ Date: Thu, 23 Jan 2025 11:34:16 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20"Afficher=20les=20noms=20des=20usager?= =?UTF-8?q?s=20et=20l'entit=C3=A9=20concern=C3=A9=20par=20l'entit=C3=A9=20?= =?UTF-8?q?notifi=C3=A9e=20dans=20la=20liste=20des=20notifications"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unreleased/Feature-20250123-122736.yaml | 6 +++ .../ActivityNotificationHandler.php | 31 ++++++++++- .../translations/messages+intl-icu.fr.yml | 2 + .../translations/messages.fr.yml | 1 + ...ompanyingCourseDocumentWorkflowHandler.php | 2 +- .../translations/messages.fr.yml | 4 ++ .../translations/messages.nl.yml | 2 + .../Controller/NotificationController.php | 1 + .../NotificationHandlerInterface.php | 10 ++++ .../NotificationHandlerManager.php | 3 +- .../public/chill/scss/notification.scss | 17 +++++- .../views/Notification/_list_item.html.twig | 54 ++++++++++++++++--- .../views/Notification/show.html.twig | 4 +- .../Workflow/_notification_include.html.twig | 2 +- .../WorkflowNotificationHandler.php | 29 +++++++++- .../translations/messages.fr.yml | 5 +- .../translations/messages.nl.yml | 3 -- .../AccompanyingPeriodNotificationHandler.php | 25 +++++++++ ...kEvaluationDocumentNotificationHandler.php | 31 +++++++++++ ...ompanyingPeriodWorkNotificationHandler.php | 31 ++++++++++- .../components/Household.vue | 2 +- .../_components/Entity/PersonRenderBox.vue | 12 ++++- ...dWorkEvaluationDocumentWorkflowHandler.php | 2 +- ...ingPeriodWorkEvaluationWorkflowHandler.php | 2 +- .../AccompanyingPeriodWorkWorkflowHandler.php | 2 +- .../translations/messages+intl-icu.fr.yaml | 5 ++ .../translations/messages.fr.yml | 9 +++- .../translations/messages.nl.yml | 3 -- 28 files changed, 267 insertions(+), 33 deletions(-) create mode 100644 .changes/unreleased/Feature-20250123-122736.yaml create mode 100644 src/Bundle/ChillDocStoreBundle/translations/messages.nl.yml diff --git a/.changes/unreleased/Feature-20250123-122736.yaml b/.changes/unreleased/Feature-20250123-122736.yaml new file mode 100644 index 000000000..8707f1a8d --- /dev/null +++ b/.changes/unreleased/Feature-20250123-122736.yaml @@ -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 diff --git a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php index 8eb219fd2..83cbe949e 100644 --- a/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php +++ b/src/Bundle/ChillActivityBundle/Notification/ActivityNotificationHandler.php @@ -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()); + } } diff --git a/src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml index 0807861cc..e05a7efd2 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages+intl-icu.fr.yml @@ -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} diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index a4d73728b..81b075bdb 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -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 diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index 193568286..57ab8e0b3 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -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(); } diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml index 05713ff28..7ea95bcda 100644 --- a/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.fr.yml @@ -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% diff --git a/src/Bundle/ChillDocStoreBundle/translations/messages.nl.yml b/src/Bundle/ChillDocStoreBundle/translations/messages.nl.yml new file mode 100644 index 000000000..f4d8dd453 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/translations/messages.nl.yml @@ -0,0 +1,2 @@ +entity_display_title: + Doc for evaluation (n°%eval%): Evaluatiedocument (n°%eval%) diff --git a/src/Bundle/ChillMainBundle/Controller/NotificationController.php b/src/Bundle/ChillMainBundle/Controller/NotificationController.php index 7ca6a3465..1580b1fa0 100644 --- a/src/Bundle/ChillMainBundle/Controller/NotificationController.php +++ b/src/Bundle/ChillMainBundle/Controller/NotificationController.php @@ -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, ]; } diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerInterface.php b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerInterface.php index 58ee8372c..4caf396fe 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerInterface.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerInterface.php @@ -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 + */ + public function getAssociatedPersons(Notification $notification, array $options = []): array; + + public function getRelatedEntity(Notification $notification): ?object; } diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php index aa6e700bc..1f623a3d6 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationHandlerManager.php @@ -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 diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/notification.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/notification.scss index 3f7601721..8c8abe509 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/notification.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/notification.scss @@ -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%; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/_list_item.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/_list_item.html.twig index 80074f32e..f9516f92f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/_list_item.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/_list_item.html.twig @@ -11,21 +11,59 @@ {% 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 %} +
+

+ {{ handler.getTitle(notification)|trans }} +

+
+ {% set associateds = handler.getAssociatedPersons(notification) %} + {% if associateds|length > 0 %} +
+ +
+ {% endif %} + {% endif %} +{% endmacro %} {% macro header(c) %}
    {% if c.step is not defined or c.step == 'inbox' %}
  • - - - {{ "notification.from" | trans }} : - - + + + {{ "notification.from" | trans }} : + + {% if not c.notification.isSystem %} - {{ c.notification.sender | chill_entity_render_string({'at_date': c.notification.date}) }} - + {{ c.notification.sender | chill_entity_render_string({'at_date': c.notification.date}) }} + {% else %} {{ "notification.is_system" | trans }} {% endif %} @@ -185,6 +223,7 @@ > {{ _self.title(_context) }} + {{ _self.relatedEntity(_context) }} {{ _self.header(_context) }}
{% else %} -

{{ 'workflow.deleted_title'|trans }}

+

{{ 'workflow.deleted'|trans }}

{% endif %} diff --git a/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php b/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php index 99cc163ed..68bf0a55d 100644 --- a/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php +++ b/src/Bundle/ChillMainBundle/Workflow/Notification/WorkflowNotificationHandler.php @@ -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()); + } } diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index d2a760d53..d1c4ba169 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -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: diff --git a/src/Bundle/ChillMainBundle/translations/messages.nl.yml b/src/Bundle/ChillMainBundle/translations/messages.nl.yml index cd6cbc6a4..22bb6a50e 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.nl.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.nl.yml @@ -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 diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php index 668f868ae..b7f3970d5 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodNotificationHandler.php @@ -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()); + } } diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php index 40aff8570..38ef06b4f 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkEvaluationDocumentNotificationHandler.php @@ -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()); + } } diff --git a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php index e147fa520..546e9f6ca 100644 --- a/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php +++ b/src/Bundle/ChillPersonBundle/Notification/AccompanyingPeriodWorkNotificationHandler.php @@ -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()); + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue index 704adf94b..56798341a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue @@ -244,7 +244,7 @@ export default { }; -