From 29d57934a1106d5dd9baa6e7c5562a6c2826eb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 10 Jun 2024 17:09:02 +0200 Subject: [PATCH] Update workflow rendering with date context Code updates have been made in multiple files to ensure that when entities are rendered, it includes the appropriate context relating to the date. This adjustment has been primarily made in template files where the `chill_entity_render_box` function is used. These changes help to provide users with more accurate information regarding the state of an entity at a specific time. --- .../Resources/views/Entity/CommentEmbeddable.html.twig | 4 ++-- .../Resources/views/Workflow/_decision.html.twig | 8 ++++---- .../Resources/views/Workflow/_history.html.twig | 8 ++++---- .../Resources/views/Workflow/macro_breadcrumb.html.twig | 8 ++++---- .../Normalizer/EntityWorkflowStepNormalizer.php | 2 +- .../Serializer/Normalizer/WorkflowNormalizer.php | 3 ++- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig index 1dcd9cbf7..5395df212 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig @@ -40,10 +40,10 @@ {{ 'by_user'|trans ~ ' ' }} {% endif %} - {{ user|chill_entity_render_box(options['user']) }} + {{ user|chill_entity_render_box({'at_date': comment.date}) }} {% endif %} {% endif %} -{{ closing_box|raw }} \ No newline at end of file +{{ closing_box|raw }} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig index 2aec17cf9..0056c503d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_decision.html.twig @@ -31,14 +31,14 @@
{{ 'By'|trans }} - {{ step.previous.transitionBy|chill_entity_render_box }}, + {{ step.previous.transitionBy|chill_entity_render_box({'at_date': step.previous.transitionAt }) }}, {{ step.previous.transitionAt|format_datetime('short', 'short') }}
{% else %}
{{ 'workflow.Created by'|trans }}
-
{{ step.entityWorkflow.createdBy|chill_entity_render_box }}
+
{{ step.entityWorkflow.createdBy|chill_entity_render_box({'at_date': step.entityWorkflow.createdAt}) }}
{{ 'Le'|trans }}
@@ -110,8 +110,8 @@ {% if entity_workflow.currentStep.destUserByAccessKey|length > 0 %}

{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :

{% endif %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig index acbf97cf7..a3e2e24b9 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_history.html.twig @@ -42,7 +42,7 @@
{% if step.transitionBy is not null %}
- {{ step.transitionBy|chill_entity_render_box }} + {{ step.transitionBy|chill_entity_render_box({'at_date': step.transitionAt}) }}
{% endif %}
@@ -76,7 +76,7 @@

{{ 'workflow.Users allowed to apply transition'|trans }} :

    {% for u in step.destUser %} -
  • {{ u|chill_entity_render_box }}
  • +
  • {{ u|chill_entity_render_box({'at_date': step.previous.transitionAt}) }}
  • {% endfor %}
{% endif %} @@ -85,7 +85,7 @@

{{ 'workflow.Users put in Cc'|trans }} :

    {% for u in step.ccUser %} -
  • {{ u|chill_entity_render_box }}
  • +
  • {{ u|chill_entity_render_box({'at_date': step.previous.transitionAt}) }}
  • {% endfor %}
{% endif %} @@ -103,7 +103,7 @@

{{ 'workflow.Those users are also granted to apply a transition by using an access key'|trans }} :

    {% for u in step.destUserByAccessKey %} -
  • {{ u|chill_entity_render_box }}
  • +
  • {{ u|chill_entity_render_box({'at_date': step.previous.transitionAt}) }}
  • {% endfor %}
{% endif %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig index 2ba893910..71d1efcf1 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/macro_breadcrumb.html.twig @@ -3,7 +3,7 @@ {% if step.previous is not null %}
  • {{ 'By'|trans ~ ' : ' }} - {{ step.previous.transitionBy|chill_entity_render_box }} + {{ step.previous.transitionBy|chill_entity_render_box({'at_date': step.previous.transitionAt }) }}
  • {{ 'Le'|trans ~ ' : ' }} @@ -12,19 +12,19 @@
  • {{ 'workflow.For'|trans ~ ' : ' }} - {% for d in step.destUser %}{{ d|chill_entity_render_string }}{% if not loop.last %}, {% endif %}{% endfor %} + {% for d in step.destUser %}{{ d|chill_entity_render_string({'at_date': step.previous.transitionAt}) }}{% if not loop.last %}, {% endif %}{% endfor %}
  • {{ 'workflow.Cc'|trans ~ ' : ' }} - {% for u in step.ccUser %}{{ u|chill_entity_render_string }}{% if not loop.last %}, {% endif %}{% endfor %} + {% for u in step.ccUser %}{{ u|chill_entity_render_string({'at_date': step.previous.transitionAt }) }}{% if not loop.last %}, {% endif %}{% endfor %}
  • {% else %}
  • {{ 'workflow.Created by'|trans ~ ' : ' }} - {{ step.entityWorkflow.createdBy|chill_entity_render_box }} + {{ step.entityWorkflow.createdBy|chill_entity_render_box({'at_date': step.entityWorkflow.createdAt }) }}
  • {{ 'Le'|trans ~ ' : ' }} diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php index 46dbd00cc..2d924eb4d 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/EntityWorkflowStepNormalizer.php @@ -54,7 +54,7 @@ class EntityWorkflowStepNormalizer implements NormalizerAwareInterface, Normaliz $data['transitionPreviousBy'] = $this->normalizer->normalize( $previous->getTransitionBy(), $format, - $context + [...$context, UserNormalizer::AT_DATE => $previous->getTransitionAt()] ); $data['transitionPreviousAt'] = $this->normalizer->normalize( $previous->getTransitionAt(), diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php index 99314ebdc..5e18fdd31 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/WorkflowNormalizer.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Serializer\Normalizer; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; +use Chill\MainBundle\Serializer\Normalizer\UserNormalizer; use Chill\MainBundle\Workflow\Helper\MetadataExtractor; use Symfony\Component\Serializer\Exception\ExceptionInterface; use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; @@ -48,7 +49,7 @@ class WorkflowNormalizer implements ContextAwareNormalizerInterface, NormalizerA $data['workflow'] = $this->metadataExtractor->buildArrayPresentationForWorkflow($workflow); $data['current_place'] = $this->metadataExtractor->buildArrayPresentationForPlace($object); $data['current_place_at'] = $this->normalizer->normalize($object->getCurrentStepCreatedAt(), 'json', ['groups' => ['read']]); - $data['current_place_by'] = $this->normalizer->normalize($object->getCurrentStepCreatedBy(), 'json', ['groups' => ['read']]); + $data['current_place_by'] = $this->normalizer->normalize($object->getCurrentStepCreatedBy(), 'json', ['groups' => ['read'], UserNormalizer::AT_DATE => $object->getCurrentStepCreatedAt()]); return $data; }