mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
list workflow on index pages
This commit is contained in:
parent
1479e2ae9a
commit
b7d6d69101
@ -10,12 +10,14 @@
|
|||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
{{ encore_entry_script_tags('mod_async_upload') }}
|
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||||
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
{{ encore_entry_script_tags('mod_docgen_picktemplate') }}
|
||||||
|
{{ encore_entry_script_tags('mod_entity_workflow_pick') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||||
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
{{ encore_entry_link_tags('mod_docgen_picktemplate') }}
|
||||||
|
{{ encore_entry_link_tags('mod_entity_workflow_pick') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
@ -48,6 +48,9 @@
|
|||||||
<div>
|
<div>
|
||||||
{% if document.course is defined %}
|
{% if document.course is defined %}
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
{{ chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) }}
|
||||||
|
</li>
|
||||||
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
|
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
|
||||||
<li>
|
<li>
|
||||||
{{ m.download_button(document.object, document.title) }}
|
{{ m.download_button(document.object, document.title) }}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="item-row col">
|
<div class="item-row col">
|
||||||
<h2>Workflow</h2>
|
<h2>{{ w.title }} - ({{ w.workflow.text }})</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 }}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<div data-list-workflows="1"
|
<div data-list-workflows="1"
|
||||||
data-workflows="{{ entity_workflows_json|json_encode|e('html_attr') }}"
|
data-workflows="{{ entity_workflows_json|json_encode|e('html_attr') }}"
|
||||||
data-allow-create="{{ acl }}"
|
data-allow-create="{{ acl }}"
|
||||||
data-related-entity-class="{{ blank_workflow.relatedEntityClass }}"
|
data-related-entity-class="{{ relatedEntityClass }}"
|
||||||
data-related-entity-id="{{ blank_workflow.relatedEntityId }}"
|
data-related-entity-id="{{ relatedEntityId }}"
|
||||||
data-workflows-availables="{{ workflows_availables|json_encode()|e('html_attr') }}"
|
data-workflows-availables="{{ workflows_available|json_encode()|e('html_attr') }}"
|
||||||
></div>
|
></div>
|
||||||
|
@ -61,7 +61,46 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listWorkflows(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string
|
/**
|
||||||
|
* @param Environment $environment
|
||||||
|
* @param string $relatedEntityClass
|
||||||
|
* @param int $relatedEntityId
|
||||||
|
* @param array $options
|
||||||
|
* @param array{relatedEntityClass: string, relatedEntityId: int} $supplementaryRelated
|
||||||
|
* @return string
|
||||||
|
* @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
|
||||||
|
* @throws \Twig\Error\LoaderError
|
||||||
|
* @throws \Twig\Error\RuntimeError
|
||||||
|
* @throws \Twig\Error\SyntaxError
|
||||||
|
*/
|
||||||
|
public function listWorkflows(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = [], array $supplementaryRelated = []): string
|
||||||
|
{
|
||||||
|
list($blankEntityWorkflow, $workflowsAvailable, $entityWorkflows) = $this->getWorkflowsForRelated($relatedEntityClass, $relatedEntityId);
|
||||||
|
|
||||||
|
dump($supplementaryRelated);
|
||||||
|
foreach ($supplementaryRelated as $supplementary) {
|
||||||
|
dump($supplementary);
|
||||||
|
list($supplementaryBlankEntityWorkflow, $supplementaryWorkflowsAvailable, $supplementaryEntityWorkflows)
|
||||||
|
= $this->getWorkflowsForRelated($supplementary['relatedEntityClass'], $supplementary['relatedEntityId']);
|
||||||
|
|
||||||
|
$entityWorkflows = array_merge($entityWorkflows, $supplementaryEntityWorkflows);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $environment->render('@ChillMain/Workflow/_extension_list_workflow_for.html.twig', [
|
||||||
|
'entity_workflows_json' => $this->normalizer->normalize($entityWorkflows, 'json', ['groups' => 'read']),
|
||||||
|
'blank_workflow' => $blankEntityWorkflow,
|
||||||
|
'workflows_available' => $workflowsAvailable,
|
||||||
|
'relatedEntityClass' => $relatedEntityClass,
|
||||||
|
'relatedEntityId' => $relatedEntityId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $relatedEntityClass
|
||||||
|
* @param int $relatedEntityId
|
||||||
|
* @return array where keys are: {0: blankWorkflow, 1: entityWorkflows, 2: workflowList}
|
||||||
|
*/
|
||||||
|
private function getWorkflowsForRelated(string $relatedEntityClass, int $relatedEntityId): array
|
||||||
{
|
{
|
||||||
$blankEntityWorkflow = new EntityWorkflow();
|
$blankEntityWorkflow = new EntityWorkflow();
|
||||||
$blankEntityWorkflow
|
$blankEntityWorkflow
|
||||||
@ -70,25 +109,12 @@ class WorkflowTwigExtensionRuntime implements RuntimeExtensionInterface
|
|||||||
|
|
||||||
$workflowsList = $this->metadataExtractor->availableWorkflowFor($relatedEntityClass, $relatedEntityId);
|
$workflowsList = $this->metadataExtractor->availableWorkflowFor($relatedEntityClass, $relatedEntityId);
|
||||||
|
|
||||||
// get the related entity already created
|
return
|
||||||
$entityWorkflows = [];
|
[
|
||||||
|
$blankEntityWorkflow,
|
||||||
foreach ($entityWorkflowsNaked = $this->repository->findBy(
|
$workflowsList,
|
||||||
['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId]
|
$this->repository->findBy(
|
||||||
) as $entityWorkflow) {
|
['relatedEntityClass' => $relatedEntityClass, 'relatedEntityId' => $relatedEntityId]),
|
||||||
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
|
|
||||||
$entityWorkflows[] = [
|
|
||||||
'entity_workflow' => $entityWorkflow,
|
|
||||||
'workflow' => $this->metadataExtractor->buildArrayPresentationForWorkflow($workflow),
|
|
||||||
'handler' => $this->entityWorkflowManager->getHandler($entityWorkflow),
|
|
||||||
];
|
];
|
||||||
}
|
|
||||||
|
|
||||||
return $environment->render('@ChillMain/Workflow/_extension_list_workflow_for.html.twig', [
|
|
||||||
'entity_workflows_json' => $this->normalizer->normalize($entityWorkflowsNaked, 'json', ['groups' => 'read']),
|
|
||||||
'entity_workflows' => $entityWorkflows,
|
|
||||||
'blank_workflow' => $blankEntityWorkflow,
|
|
||||||
'workflows_availables' => $workflowsList,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,17 @@
|
|||||||
{% if displayAction is defined and displayAction == true %}
|
{% if displayAction is defined and displayAction == true %}
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
|
{% set suppEvaluations = [] %}
|
||||||
|
{% for e in w.accompanyingPeriodWorkEvaluations %}
|
||||||
|
{% set suppEvaluations = suppEvaluations|merge([
|
||||||
|
{'relatedEntityClass': 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation', 'relatedEntityId': e.id }
|
||||||
|
]) %}
|
||||||
|
{% endfor %}
|
||||||
|
<li>
|
||||||
|
{{ chill_entity_workflow_list(
|
||||||
|
'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork',
|
||||||
|
w.id, [], suppEvaluations) }}
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="btn btn-edit" title="{{ 'Edit'|trans }}"
|
<a class="btn btn-edit" title="{{ 'Edit'|trans }}"
|
||||||
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}"
|
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}"
|
||||||
|
@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
{% block title 'accompanying_course_work.List accompanying course work'|trans %}
|
{% block title 'accompanying_course_work.List accompanying course work'|trans %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_script_tags('mod_entity_workflow_pick') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('mod_entity_workflow_pick') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="accompanying_course_work">
|
<div class="accompanying_course_work">
|
||||||
|
|
||||||
|
@ -62,10 +62,14 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
|
{% if evaluation.createdBy is not null %}
|
||||||
<span class="item-key">créé par</span>
|
<span class="item-key">créé par</span>
|
||||||
<b>{{ evaluation.createdBy.username }}</b>
|
<b>{{ evaluation.createdBy.username }}</b>
|
||||||
|
{% endif %}
|
||||||
|
{% if evaluation.createdAt is not null %}
|
||||||
<span class="item-key">{{ 'le'|trans }}</span>
|
<span class="item-key">{{ 'le'|trans }}</span>
|
||||||
<b>{{ evaluation.createdAt|format_date('short') }}</b>
|
<b>{{ evaluation.createdAt|format_date('short') }}</b>
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% if evaluation.comment %}
|
{% if evaluation.comment %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user