mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-15 09:49:41 +00:00
Only show active workflow on the page "my tracked workflow
This commit is contained in:
6
.changes/unreleased/Feature-20251015-113430.yaml
Normal file
6
.changes/unreleased/Feature-20251015-113430.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
kind: Feature
|
||||
body: Only show active workflow on the page "my tracked workflow"
|
||||
time: 2025-10-15T11:34:30.857052581+02:00
|
||||
custom:
|
||||
Issue: "394"
|
||||
SchemaChange: No schema change
|
@@ -264,11 +264,12 @@ class WorkflowController extends AbstractController
|
||||
{
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
|
||||
|
||||
$total = $this->entityWorkflowRepository->countBySubscriber($this->security->getUser());
|
||||
$total = $this->entityWorkflowRepository->countBySubscriber($this->security->getUser(), false);
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
|
||||
$workflows = $this->entityWorkflowRepository->findBySubscriber(
|
||||
$this->security->getUser(),
|
||||
false,
|
||||
['createdAt' => 'DESC'],
|
||||
$paginator->getItemsPerPage(),
|
||||
$paginator->getCurrentPageFirstItemNumber()
|
||||
|
@@ -57,9 +57,15 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countBySubscriber(User $user): int
|
||||
/**
|
||||
* @param bool|null $isFinal true to get only the entityWorkflow which is finalized, false to get the workflows that are not finalized, and null to ignore
|
||||
*
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
public function countBySubscriber(User $user, ?bool $isFinal = null): int
|
||||
{
|
||||
$qb = $this->buildQueryBySubscriber($user)->select('count(ew)');
|
||||
$qb = $this->buildQueryBySubscriber($user, $isFinal)->select('count(ew)');
|
||||
|
||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
@@ -182,9 +188,12 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findBySubscriber(User $user, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
/**
|
||||
* @param bool|null $isFinal true to get only the entityWorkflow which is finalized, false to get the workflows that are not finalized, and null to ignore
|
||||
*/
|
||||
public function findBySubscriber(User $user, ?bool $isFinal = null, ?array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryBySubscriber($user)->select('ew');
|
||||
$qb = $this->buildQueryBySubscriber($user, $isFinal)->select('ew');
|
||||
|
||||
foreach ($orderBy as $key => $sort) {
|
||||
$qb->addOrderBy('ew.'.$key, $sort);
|
||||
@@ -312,7 +321,7 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
return $qb;
|
||||
}
|
||||
|
||||
private function buildQueryBySubscriber(User $user): QueryBuilder
|
||||
private function buildQueryBySubscriber(User $user, ?bool $isFinal): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('ew');
|
||||
|
||||
@@ -325,6 +334,14 @@ class EntityWorkflowRepository implements ObjectRepository
|
||||
|
||||
$qb->setParameter('user', $user);
|
||||
|
||||
if (null !== $isFinal) {
|
||||
if ($isFinal) {
|
||||
$qb->andWhere(sprintf('EXISTS (SELECT 1 FROM %s step WHERE step.isFinal = true AND ew = step.entityWorkflow)', EntityWorkflowStep::class));
|
||||
} else {
|
||||
$qb->andWhere(sprintf('NOT EXISTS (SELECT 1 FROM %s step WHERE step.isFinal = true AND ew = step.entityWorkflow)', EntityWorkflowStep::class));
|
||||
}
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user