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,133 +1,139 @@
{%- 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="item-bloc evaluation-item bg-chill-llight-gray"> <div class="alert alert-warning">
<div class="item-row mb-2"> {{ 'workflow.doc for evaluation deleted'|trans }}
<h1>{{ doc.title }}</h1> </div>
</div> {% else %}
<div class="item-row mb-2"> <div class="flex-table accompanying_course_work-list">
<h2 class="badge-title"> <div class="item-bloc evaluation-item bg-chill-llight-gray">
<span class="title_label"></span> <div class="item-row mb-2">
<span class="title_action"> <h1>{{ doc.title }}</h1>
{{ evaluation.accompanyingPeriodWork.socialAction|chill_entity_render_string }} </div>
<ul class="small_in_title columns mt-1"> <div class="item-row mb-2">
<li> <h2 class="badge-title">
<span class="item-key">{{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}</span> <span class="title_label"></span>
<b>{{ evaluation.accompanyingPeriodWork.startDate|format_date('short') }}</b> <span class="title_action">
</li> {{ evaluation.accompanyingPeriodWork.socialAction|chill_entity_render_string }}
{% if evaluation.accompanyingPeriodWork.endDate %} <ul class="small_in_title columns mt-1">
<li> <li>
<span class="item-key">{{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}</span> <span class="item-key">{{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}</span>
<b>{{ evaluation.accompanyingPeriodWork.endDate|format_date('short') }}</b> <b>{{ evaluation.accompanyingPeriodWork.startDate|format_date('short') }}</b>
</li> </li>
{% endif %} {% if evaluation.accompanyingPeriodWork.endDate %}
</ul> <li>
</span> <span class="item-key">{{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}</span>
</h2> <b>{{ evaluation.accompanyingPeriodWork.endDate|format_date('short') }}</b>
</div>
<div class="item-row mb-2">
<div class="item-col" style="width: 17%;">
<h4 class="title_label">
{{ 'Participants'|trans }}
</h4>
</div>
<div class="item-col list">
{% for p in evaluation.accompanyingPeriodWork.persons %}
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'person', id: p.id },
action: 'show',
displayBadge: true,
buttonText: p|chill_entity_render_string,
isDead: p.deathdate is not null
} %}
{% endfor %}
</div>
</div>
<div class="item-row column">
<table class="obj-res-eval my-3" style="font-size: 110% !important;">
<thead>
<tr>
<th class="eval">
<h4 class="title_label">
{{ 'Évaluation'|trans }}
</h4>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="eval">
<ul class="eval_title">
<li class="my-2">
{{ evaluation.evaluation.title|localize_translatable_string }}
<ul class="columns pt-2">
<li>
<span class="item-key">{{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}</span>
<b>{{ evaluation.startDate|format_date('short') }}</b>
</li>
{% if evaluation.endDate %}
<li>
<span class="item-key">{{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}</span>
<b>{{ evaluation.endDate|format_date('short') }}</b>
</li>
{% endif %}
{% if evaluation.maxDate %}
<li>
<span class="item-key">{{ 'accompanying_course_work.max_date'|trans ~ ' : ' }}</span>
<b>{{ evaluation.maxDate|format_date('short') }}</b>
</li>
{% endif %}
{% if evaluation.warningInterval and evaluation.warningInterval.d > 0 %}
<li>
{% set days = (evaluation.warningInterval.d + evaluation.warningInterval.m * 30) %}
<span class="item-key">{{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }}</span>
{{ 'accompanying_course_work.%days% days before max_date'|trans({'%days%': days }) }}
</li>
{% endif %}
<li>
{% if evaluation.createdBy is not null %}
<span class="item-key">créé par</span>
<b>{{ evaluation.createdBy.username }}</b>
{% endif %}
{% if evaluation.createdAt is not null %}
<span class="item-key">{{ 'le'|trans }}</span>
<b>{{ evaluation.createdAt|format_date('short') }}</b>
{% endif %}
</li>
</ul>
{% if evaluation.comment %}
<blockquote class="chill-user-quote" style="margin-left: 0;">
{{ evaluation.comment }}
</blockquote>
{% endif %}
</li> </li>
</ul> {% endif %}
</td> </ul>
</tr> </span>
</tbody> </h2>
</table> </div>
</div> <div class="item-row mb-2">
<div class="item-row"> <div class="item-col" style="width: 17%;">
{% import '@ChillPerson/Macro/updatedBy.html.twig' as macro %} <h4 class="title_label">
{{ macro.updatedBy(evaluation) }} {{ 'Participants'|trans }}
</h4>
</div>
<div class="item-col list">
{% for p in evaluation.accompanyingPeriodWork.persons %}
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
targetEntity: { name: 'person', id: p.id },
action: 'show',
displayBadge: true,
buttonText: p|chill_entity_render_string,
isDead: p.deathdate is not null
} %}
{% endfor %}
</div>
</div>
<div class="item-row column">
<table class="obj-res-eval my-3" style="font-size: 110% !important;">
<thead>
<tr>
<th class="eval">
<h4 class="title_label">
{{ 'Évaluation'|trans }}
</h4>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="eval">
<ul class="eval_title">
<li class="my-2">
{{ evaluation.evaluation.title|localize_translatable_string }}
<ul class="columns pt-2">
<li>
<span class="item-key">{{ 'accompanying_course_work.start_date'|trans ~ ' : ' }}</span>
<b>{{ evaluation.startDate|format_date('short') }}</b>
</li>
{% if evaluation.endDate %}
<li>
<span class="item-key">{{ 'accompanying_course_work.end_date'|trans ~ ' : ' }}</span>
<b>{{ evaluation.endDate|format_date('short') }}</b>
</li>
{% endif %}
{% if evaluation.maxDate %}
<li>
<span class="item-key">{{ 'accompanying_course_work.max_date'|trans ~ ' : ' }}</span>
<b>{{ evaluation.maxDate|format_date('short') }}</b>
</li>
{% endif %}
{% if evaluation.warningInterval and evaluation.warningInterval.d > 0 %}
<li>
{% set days = (evaluation.warningInterval.d + evaluation.warningInterval.m * 30) %}
<span class="item-key">{{ 'accompanying_course_work.warning_interval'|trans ~ ' : ' }}</span>
{{ 'accompanying_course_work.%days% days before max_date'|trans({'%days%': days }) }}
</li>
{% endif %}
<li>
{% if evaluation.createdBy is not null %}
<span class="item-key">créé par</span>
<b>{{ evaluation.createdBy.username }}</b>
{% endif %}
{% if evaluation.createdAt is not null %}
<span class="item-key">{{ 'le'|trans }}</span>
<b>{{ evaluation.createdAt|format_date('short') }}</b>
{% endif %}
</li>
</ul>
{% if evaluation.comment %}
<blockquote class="chill-user-quote" style="margin-left: 0;">
{{ evaluation.comment }}
</blockquote>
{% endif %}
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
<div class="item-row">
{% import '@ChillPerson/Macro/updatedBy.html.twig' as macro %}
{{ 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>
{% if chill_document_is_editable(doc.storedObject) %} {% if chill_document_is_editable(doc.storedObject) %}
<li>
{{ doc.storedObject|chill_document_edit_button }}
</li>
{% endif %}
<li> <li>
{{ doc.storedObject|chill_document_edit_button }} <a class="btn btn-show" href="{{ path('chill_person_accompanying_period_work_edit', {'id': evaluation.accompanyingPeriodWork.id}) }}">
{{ 'Show'|trans }}
</a>
</li> </li>
</ul>
{% endif %} {% endif %}
<li>
<a class="btn btn-show" href="{{ path('chill_person_accompanying_period_work_edit', {'id': evaluation.accompanyingPeriodWork.id}) }}">
{{ 'Show'|trans }}
</a>
</li>
</ul>
{% 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