mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch '296-signature-menu-tab' into 'signature-app-master'
Add person menu entry for signature list See merge request Chill-Projet/chill-bundles!719
This commit is contained in:
commit
2dd275a074
@ -38,6 +38,11 @@
|
||||
|
||||
{% if display_action is defined and display_action == true %}
|
||||
<ul class="record_actions">
|
||||
{% for dam in display_action_more|default([]) %}
|
||||
<li>
|
||||
{{ dam|raw }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% if document.course != null and is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', document.course) %}
|
||||
<li>
|
||||
<a href="{{ path('chill_person_accompanying_course_index', {'accompanying_period_id': document.course.id}) }}" class="btn btn-show change-icon">
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Repository\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
|
||||
interface EntityWorkflowSignatureACLAwareRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return array<EntityWorkflowStepSignature>
|
||||
*/
|
||||
public function findByPersonAndPendingState(Person $person): array;
|
||||
}
|
@ -18,9 +18,9 @@ use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
class EntityWorkflowStepRepository implements ObjectRepository
|
||||
readonly class EntityWorkflowStepRepository implements ObjectRepository
|
||||
{
|
||||
private readonly EntityRepository $repository;
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Repository\Workflow;
|
||||
|
||||
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class EntityWorkflowStepSignatureACLAwareRepository implements EntityWorkflowSignatureACLAwareRepositoryInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityWorkflowStepSignatureRepository $repository,
|
||||
private readonly EntityWorkflowManager $entityWorkflowManager,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
public function findByPersonAndPendingState(Person $person): array
|
||||
{
|
||||
$signatures = $this->repository->findByPerson($person);
|
||||
|
||||
$filteredSignatures = [];
|
||||
|
||||
foreach ($signatures as $signature) {
|
||||
if (EntityWorkflowSignatureStateEnum::SIGNED === $signature->getState() || EntityWorkflowSignatureStateEnum::CANCELED === $signature->getState() || EntityWorkflowSignatureStateEnum::REJECTED === $signature->getState()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$workflow = $signature->getStep()->getEntityWorkflow();
|
||||
|
||||
$storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($workflow);
|
||||
|
||||
if (null === $storedObject) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)) {
|
||||
$filteredSignatures[] = $signature;
|
||||
}
|
||||
}
|
||||
|
||||
return $filteredSignatures;
|
||||
}
|
||||
}
|
@ -12,43 +12,28 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Repository\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @template-implements ObjectRepository<EntityWorkflowStepSignature>
|
||||
* @template-extends ServiceEntityRepository<EntityWorkflowStepSignature>
|
||||
*/
|
||||
class EntityWorkflowStepSignatureRepository implements ObjectRepository
|
||||
class EntityWorkflowStepSignatureRepository extends ServiceEntityRepository
|
||||
{
|
||||
private readonly \Doctrine\ORM\EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(EntityWorkflowStepSignature::class);
|
||||
parent::__construct($registry, EntityWorkflowStepSignature::class);
|
||||
}
|
||||
|
||||
public function find($id): ?EntityWorkflowStepSignature
|
||||
public function findByPerson(Person $person): array
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
$qb = $this->createQueryBuilder('ewss');
|
||||
$qb->select('ewss');
|
||||
$qb->where($qb->expr()->eq('ewss.personSigner', ':person'));
|
||||
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
$qb->setParameter('person', $person);
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
return $this->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?EntityWorkflowStepSignature
|
||||
{
|
||||
return $this->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return EntityWorkflowStepSignature::class;
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepSignatureACLAwareRepository;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class PersonSignatureController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityWorkflowStepSignatureACLAwareRepository $signatureRepository,
|
||||
private readonly EntityWorkflowManager $entityWorkflowManager,
|
||||
) {}
|
||||
|
||||
#[Route(path: '/{_locale}/signatures/by-person/{id}', name: 'chill_person_signature_list')]
|
||||
public function listSignatures(Person $person): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||
|
||||
$signatures = $this->signatureRepository->findByPersonAndPendingState($person);
|
||||
$signatureData = [];
|
||||
|
||||
foreach ($signatures as $signature) {
|
||||
$entityWorkflow = $signature->getStep()->getEntityWorkflow();
|
||||
$handler = $this->entityWorkflowManager->getHandler($entityWorkflow);
|
||||
|
||||
$workflow = [
|
||||
'handler_template' => $handler->getTemplate($entityWorkflow),
|
||||
'handler_template_data' => $handler->getTemplateData($entityWorkflow),
|
||||
'entity_workflow' => $entityWorkflow,
|
||||
];
|
||||
|
||||
$storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow);
|
||||
$signatureData[] = [
|
||||
'signature' => $signature,
|
||||
'document' => $storedObject,
|
||||
'workflow' => $workflow,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/Person/signature_list.html.twig', [
|
||||
'signatures' => $signatureData,
|
||||
'person' => $person,
|
||||
]);
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Menu;
|
||||
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepSignatureACLAwareRepository;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
@ -43,6 +44,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
private readonly Security $security,
|
||||
protected TranslatorInterface $translator,
|
||||
private readonly ResidentialAddressRepository $residentialAddressRepo,
|
||||
private readonly EntityWorkflowStepSignatureACLAwareRepository $entityWorkflowStepSignatureRepository,
|
||||
) {
|
||||
$this->showAccompanyingPeriod = $parameterBag->get('chill_person.accompanying_period');
|
||||
}
|
||||
@ -125,6 +127,21 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
? $nbAccompanyingPeriod : null,
|
||||
]);
|
||||
}
|
||||
|
||||
$nbSignatures = count($this->entityWorkflowStepSignatureRepository->findByPersonAndPendingState($parameters['person']));
|
||||
|
||||
if ($nbSignatures > 0) {
|
||||
$menu->addChild($this->translator->trans('workflow.signature_list.menu'), [
|
||||
'route' => 'chill_person_signature_list',
|
||||
'routeParameters' => [
|
||||
'id' => $parameters['person']->getId(),
|
||||
],
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 110,
|
||||
'counter' => $nbSignatures,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
|
@ -0,0 +1,44 @@
|
||||
{% extends "@ChillPerson/Person/layout.html.twig" %}
|
||||
{% set activeRouteKey = 'chill_person_signature_list' %}
|
||||
|
||||
{% block title %}{{ 'Person signatures'|trans ~ ' ' ~ person|chill_entity_render_string }}{% endblock %}
|
||||
|
||||
{% block dam %}
|
||||
<a class="btn btn-misc" href="{{ chill_path_add_return_path('chill_main_workflow_signature_metadata', { 'signature_id': s.signature.id}) }}"><i class="fa fa-pencil-square-o"></i> {{ 'workflow.signature_zone.button_sign'|trans }}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>{{ 'workflow.signature_list.title'|trans }}</h1>
|
||||
|
||||
<div class="container">
|
||||
<div class="row align-items-center">
|
||||
{% for s in signatures %}
|
||||
{% set signature = s.signature %}
|
||||
{% set workflow = s.workflow %}
|
||||
{% set document = s.document %}
|
||||
|
||||
<div class="item-bloc">
|
||||
<div class="item-row">
|
||||
<div class="item-col flex-grow-1">
|
||||
{% include workflow.handler_template with workflow.handler_template_data|merge({'display_action': true, 'display_action_more': [block('dam')|raw] }) %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_link_tags('mod_async_upload') }}
|
||||
{{ encore_entry_script_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock css %}
|
||||
|
||||
{% block js %}
|
||||
{{ parent() }}
|
||||
{{ encore_entry_script_tags('mod_async_upload') }}
|
||||
{{ encore_entry_link_tags('mod_document_action_buttons_group') }}
|
||||
{% endblock js %}
|
@ -13,6 +13,11 @@
|
||||
</div>
|
||||
{% if display_action is defined and display_action == true %}
|
||||
<ul class="record_actions">
|
||||
{% for dam in display_action_more|default([]) %}
|
||||
<li>
|
||||
{{ dam|raw }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li>
|
||||
<a class="btn btn-update"
|
||||
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': work.id }) }}">
|
||||
|
@ -94,6 +94,11 @@
|
||||
{% if display_action is defined and display_action == true %}
|
||||
{# TODO add acl #}
|
||||
<ul class="record_actions">
|
||||
{% for dam in display_action_more|default([]) %}
|
||||
<li>
|
||||
{{ dam|raw }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li>
|
||||
<a class="btn btn-show" href="{{ path('chill_person_accompanying_period_work_edit', {'id': evaluation.accompanyingPeriodWork.id}) }}">
|
||||
{{ 'Show'|trans }}
|
||||
|
@ -121,6 +121,11 @@
|
||||
|
||||
{% if display_action is defined and display_action == true %}
|
||||
<ul class="record_actions">
|
||||
{% for dam in display_action_more|default([]) %}
|
||||
<li>
|
||||
{{ dam|raw }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li>{{ doc.storedObject|chill_document_button_group(doc.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', evaluation.accompanyingPeriodWork)) }}</li>
|
||||
<li>
|
||||
<a class="btn btn-show" href="{{ path('chill_person_accompanying_period_work_edit', {'id': evaluation.accompanyingPeriodWork.id, 'doc_id': doc.id}) }}">
|
||||
|
@ -68,3 +68,6 @@ services:
|
||||
autowire: true
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
Chill\PersonBundle\Controller\PersonSignatureController:
|
||||
tags: [ 'controller.service_arguments' ]
|
||||
|
||||
|
@ -957,6 +957,10 @@ workflow:
|
||||
Doc for evaluation (n°%eval%): Document de l'évaluation n°%eval%
|
||||
doc for evaluation deleted: Document supprimé dans une évaluation
|
||||
SocialAction deleted: Action sociale supprimée
|
||||
signature_list:
|
||||
title: Signature en attente
|
||||
menu: Signature en attente
|
||||
no_signatures: Aucune signature demandée
|
||||
|
||||
period_by_user_list:
|
||||
Period by user: Parcours d'accompagnement par utilisateur
|
||||
|
Loading…
x
Reference in New Issue
Block a user