improve title rendering on workflows

This commit is contained in:
Julien Fastré 2022-02-25 12:09:53 +01:00
parent b7d6d69101
commit 2b257cc402
5 changed files with 39 additions and 12 deletions

View File

@ -13,6 +13,7 @@ namespace Chill\DocStoreBundle\Workflow;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -28,8 +29,10 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
/** /**
* TODO: injecter le repository directement. * TODO: injecter le repository directement.
*/ */
public function __construct(EntityManagerInterface $em, TranslatorInterface $translator) public function __construct(
{ EntityManagerInterface $em,
TranslatorInterface $translator
) {
$this->repository = $em->getRepository(AccompanyingCourseDocument::class); $this->repository = $em->getRepository(AccompanyingCourseDocument::class);
$this->translator = $translator; $this->translator = $translator;
} }
@ -53,7 +56,11 @@ class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandler
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
{ {
return $this->translator->trans('workflow.Document (n°%doc%)', ['%doc%' => $entityWorkflow->getRelatedEntityId()]); $doc = $this->getRelatedEntity($entityWorkflow);
return $this->translator->trans('workflow.Document (n°%doc%)', ['%doc%' => $entityWorkflow->getRelatedEntityId()])
.' - '.$doc->getTitle()
;
} }
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingCourseDocument public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingCourseDocument

View File

@ -5,7 +5,7 @@
<div> <div>
<div class="item-row col"> <div class="item-row col">
<h2>{{ w.title }} - ({{ w.workflow.text }})</h2> <h2>{{ w.title }}</h2>
<div class="flex-grow-1 ms-3 h3"> <div class="flex-grow-1 ms-3 h3">
<div class="visually-hidden"> <div class="visually-hidden">
{{ w.relatedEntityClass }} {{ w.relatedEntityClass }}

View File

@ -77,9 +77,7 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
{ {
list($blankEntityWorkflow, $workflowsAvailable, $entityWorkflows) = $this->getWorkflowsForRelated($relatedEntityClass, $relatedEntityId); list($blankEntityWorkflow, $workflowsAvailable, $entityWorkflows) = $this->getWorkflowsForRelated($relatedEntityClass, $relatedEntityId);
dump($supplementaryRelated);
foreach ($supplementaryRelated as $supplementary) { foreach ($supplementaryRelated as $supplementary) {
dump($supplementary);
list($supplementaryBlankEntityWorkflow, $supplementaryWorkflowsAvailable, $supplementaryEntityWorkflows) list($supplementaryBlankEntityWorkflow, $supplementaryWorkflowsAvailable, $supplementaryEntityWorkflows)
= $this->getWorkflowsForRelated($supplementary['relatedEntityClass'], $supplementary['relatedEntityId']); = $this->getWorkflowsForRelated($supplementary['relatedEntityClass'], $supplementary['relatedEntityId']);

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Workflow; namespace Chill\PersonBundle\Workflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository;
@ -24,9 +25,15 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH
private TranslatorInterface $translator; private TranslatorInterface $translator;
public function __construct(AccompanyingPeriodWorkEvaluationRepository $repository, TranslatorInterface $translator) private TranslatableStringHelperInterface $translatableStringHelper;
{
public function __construct(
AccompanyingPeriodWorkEvaluationRepository $repository,
TranslatableStringHelperInterface $translatableStringHelper,
TranslatorInterface $translator
) {
$this->repository = $repository; $this->repository = $repository;
$this->translatableStringHelper = $translatableStringHelper;
$this->translator = $translator; $this->translator = $translator;
} }
@ -41,7 +48,11 @@ class AccompanyingPeriodWorkEvaluationWorkflowHandler implements EntityWorkflowH
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
{ {
return $this->translator->trans('workflow.Evaluation (n°%eval%)', ['%eval%' => $entityWorkflow->getRelatedEntityId()]); $evaluation = $this->getRelatedEntity($entityWorkflow);
return $this->translator->trans(
'workflow.Evaluation (n°%eval%)', ['%eval%' => $entityWorkflow->getRelatedEntityId()]
).' - '.$this->translatableStringHelper->localize($evaluation->getEvaluation()->getTitle());
} }
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluation public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWorkEvaluation

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Workflow; namespace Chill\PersonBundle\Workflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
@ -23,9 +24,15 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
private TranslatorInterface $translator; private TranslatorInterface $translator;
public function __construct(AccompanyingPeriodWorkRepository $repository, TranslatorInterface $translator) private TranslatableStringHelperInterface $translatableStringHelper;
{
public function __construct(
AccompanyingPeriodWorkRepository $repository,
TranslatableStringHelperInterface $translatableStringHelper,
TranslatorInterface $translator
) {
$this->repository = $repository; $this->repository = $repository;
$this->translatableStringHelper = $translatableStringHelper;
$this->translator = $translator; $this->translator = $translator;
} }
@ -39,7 +46,11 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
{ {
return $this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()]); $work = $this->getRelatedEntity($entityWorkflow);
return
$this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()])
.' - '.$this->translatableStringHelper->localize($work->getSocialAction()->getTitle());
} }
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWork public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWork