mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-23 02:09:03 +02:00
Added a filter to filter for parts which are used in a specific project
Related to issue #516
This commit is contained in:
parent
934acca934
commit
04d1e84596
4 changed files with 35 additions and 0 deletions
|
@ -39,6 +39,7 @@ use App\Entity\Parts\Manufacturer;
|
|||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\StorageLocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Entity\ProjectSystem\Project;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\Trees\NodesListBuilder;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
@ -90,6 +91,8 @@ class PartFilter implements FilterInterface
|
|||
public readonly ArrayCollection $parameters;
|
||||
public readonly IntConstraint $parametersCount;
|
||||
|
||||
public readonly EntityConstraint $project;
|
||||
|
||||
public function __construct(NodesListBuilder $nodesListBuilder)
|
||||
{
|
||||
$this->name = new TextConstraint('part.name');
|
||||
|
@ -140,6 +143,8 @@ class PartFilter implements FilterInterface
|
|||
|
||||
$this->parameters = new ArrayCollection();
|
||||
$this->parametersCount = new IntConstraint('COUNT(_parameters)');
|
||||
|
||||
$this->project = new EntityConstraint($nodesListBuilder, Project::class, '_projectBomEntries.project');
|
||||
}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
|
|
|
@ -383,6 +383,9 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
if (str_contains($dql, '_parameters')) {
|
||||
$builder->leftJoin('part.parameters', '_parameters');
|
||||
}
|
||||
if (str_contains($dql, '_projectBomEntries')) {
|
||||
$builder->leftJoin('part.project_bom_entries', '_projectBomEntries');
|
||||
}
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue