able to see the workflow if the evaluation document has been deleted

This commit is contained in:
Julien Fastré 2022-04-07 15:54:53 +02:00
parent d9bb18e042
commit a1baf99294
4 changed files with 145 additions and 122 deletions

View File

@ -59,7 +59,13 @@ class EntityWorkflowVoter extends Voter
return true; return true;
} }
return $this->security->isGranted($entityAttribute, $handler->getRelatedEntity($subject)); $relatedEntity = $handler->getRelatedEntity($subject);
if (null === $relatedEntity) {
return true;
}
return $this->security->isGranted($entityAttribute, $relatedEntity);
case self::DELETE: case self::DELETE:
return $subject->getStep() === 'initial'; return $subject->getStep() === 'initial';

View File

@ -1,6 +1,11 @@
{%- import "@ChillDocStore/Macro/macro.html.twig" as m -%} {%- import "@ChillDocStore/Macro/macro.html.twig" as m -%}
<div class="flex-table accompanying_course_work-list"> {% if doc is null %}
<div class="alert alert-warning">
{{ 'workflow.doc for evaluation deleted'|trans }}
</div>
{% else %}
<div class="flex-table accompanying_course_work-list">
<div class="item-bloc evaluation-item bg-chill-llight-gray"> <div class="item-bloc evaluation-item bg-chill-llight-gray">
<div class="item-row mb-2"> <div class="item-row mb-2">
<h1>{{ doc.title }}</h1> <h1>{{ doc.title }}</h1>
@ -112,9 +117,9 @@
{{ macro.updatedBy(evaluation) }} {{ macro.updatedBy(evaluation) }}
</div> </div>
</div> </div>
</div> </div>
{% if display_action is defined and display_action == true %} {% if display_action is defined and display_action == true %}
{% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork) %} {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork) %}
<ul class="record_actions"> <ul class="record_actions">
<li>{{ m.download_button(doc.storedObject, doc.title) }}</li> <li>{{ m.download_button(doc.storedObject, doc.title) }}</li>
@ -130,4 +135,5 @@
</li> </li>
</ul> </ul>
{% endif %} {% endif %}
{% endif %}
{% endif %} {% endif %}

View File

@ -48,6 +48,12 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
{ {
$doc = $this->getRelatedEntity($entityWorkflow); $doc = $this->getRelatedEntity($entityWorkflow);
if (null === $doc) {
return [
'persons' => [],
];
}
return [ return [
'persons' => $doc->getAccompanyingPeriodWorkEvaluation() 'persons' => $doc->getAccompanyingPeriodWorkEvaluation()
->getAccompanyingPeriodWork()->getPersons(), ->getAccompanyingPeriodWork()->getPersons(),
@ -58,6 +64,10 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
{ {
$doc = $this->getRelatedEntity($entityWorkflow); $doc = $this->getRelatedEntity($entityWorkflow);
if (null === $doc) {
return $this->translator->trans('workflow.doc for evaluation deleted');
}
return $this->translator->trans( return $this->translator->trans(
'workflow.Doc for evaluation (n°%eval%)', 'workflow.Doc for evaluation (n°%eval%)',
['%eval%' => $entityWorkflow->getRelatedEntityId()] ['%eval%' => $entityWorkflow->getRelatedEntityId()]
@ -98,7 +108,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
return [ return [
'entity_workflow' => $entityWorkflow, 'entity_workflow' => $entityWorkflow,
'evaluation' => $doc->getAccompanyingPeriodWorkEvaluation(), 'evaluation' => null !== $doc ? $doc->getAccompanyingPeriodWorkEvaluation() : $doc,
'doc' => $doc, 'doc' => $doc,
]; ];
} }

View File

@ -581,6 +581,7 @@ My accompanying periods in draft: Mes parcours brouillons
workflow: workflow:
Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval% Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval%
doc for evaluation deleted: Document supprimé dans une évaluation
period_by_user_list: period_by_user_list:
Period by user: Parcours d'accompagnement par utilisateur Period by user: Parcours d'accompagnement par utilisateur