mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Added filter possibility to attachment list
This commit is contained in:
parent
bee057bc4b
commit
017b0f717e
8 changed files with 440 additions and 2 deletions
|
@ -44,12 +44,14 @@ namespace App\DataTables;
|
|||
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
use App\DataTables\Column\PrettyBoolColumn;
|
||||
use App\DataTables\Filters\AttachmentFilter;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
use App\Services\Attachments\AttachmentURLGenerator;
|
||||
use App\Services\ElementTypeNameGenerator;
|
||||
use App\Services\EntityURLGenerator;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider;
|
||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
|
||||
use Omines\DataTablesBundle\Column\TextColumn;
|
||||
use Omines\DataTablesBundle\DataTable;
|
||||
|
@ -213,6 +215,12 @@ final class AttachmentDataTable implements DataTableTypeInterface
|
|||
'query' => function (QueryBuilder $builder): void {
|
||||
$this->getQuery($builder);
|
||||
},
|
||||
'criteria' => [
|
||||
function (QueryBuilder $builder) use ($options): void {
|
||||
$this->buildCriteria($builder, $options);
|
||||
},
|
||||
new SearchCriteriaProvider(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -225,4 +233,18 @@ final class AttachmentDataTable implements DataTableTypeInterface
|
|||
->leftJoin('attachment.attachment_type', 'attachment_type');
|
||||
//->leftJoin('attachment.element', 'element');
|
||||
}
|
||||
|
||||
private function buildCriteria(QueryBuilder $builder, array $options): void
|
||||
{
|
||||
//We do the most stuff here in the filter class
|
||||
if (isset($options['filter'])) {
|
||||
if(!$options['filter'] instanceof AttachmentFilter) {
|
||||
throw new \Exception('filter must be an instance of AttachmentFilter!');
|
||||
}
|
||||
|
||||
$filter = $options['filter'];
|
||||
$filter->apply($builder);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue