mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Improved sorting possibilities for Project info BOM view
This commit is contained in:
parent
02134dc959
commit
86f77fde1a
1 changed files with 10 additions and 1 deletions
|
@ -78,6 +78,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
->add('quantity', TextColumn::class, [
|
->add('quantity', TextColumn::class, [
|
||||||
'label' => $this->translator->trans('project.bom.quantity'),
|
'label' => $this->translator->trans('project.bom.quantity'),
|
||||||
'className' => 'text-center',
|
'className' => 'text-center',
|
||||||
|
'orderField' => 'bom_entry.quantity',
|
||||||
'render' => function ($value, ProjectBOMEntry $context) {
|
'render' => function ($value, ProjectBOMEntry $context) {
|
||||||
//If we have a non-part entry, only show the rounded quantity
|
//If we have a non-part entry, only show the rounded quantity
|
||||||
if ($context->getPart() === null) {
|
if ($context->getPart() === null) {
|
||||||
|
@ -90,7 +91,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
->add('name', TextColumn::class, [
|
->add('name', TextColumn::class, [
|
||||||
'label' => $this->translator->trans('part.table.name'),
|
'label' => $this->translator->trans('part.table.name'),
|
||||||
'orderable' => false,
|
'orderField' => 'part.name',
|
||||||
'render' => function ($value, ProjectBOMEntry $context) {
|
'render' => function ($value, ProjectBOMEntry $context) {
|
||||||
if($context->getPart() === null) {
|
if($context->getPart() === null) {
|
||||||
return htmlspecialchars($context->getName());
|
return htmlspecialchars($context->getName());
|
||||||
|
@ -121,15 +122,18 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
->add('category', EntityColumn::class, [
|
->add('category', EntityColumn::class, [
|
||||||
'label' => $this->translator->trans('part.table.category'),
|
'label' => $this->translator->trans('part.table.category'),
|
||||||
'property' => 'part.category',
|
'property' => 'part.category',
|
||||||
|
'orderField' => 'category.name',
|
||||||
])
|
])
|
||||||
->add('footprint', EntityColumn::class, [
|
->add('footprint', EntityColumn::class, [
|
||||||
'property' => 'part.footprint',
|
'property' => 'part.footprint',
|
||||||
'label' => $this->translator->trans('part.table.footprint'),
|
'label' => $this->translator->trans('part.table.footprint'),
|
||||||
|
'orderField' => 'footprint.name',
|
||||||
])
|
])
|
||||||
|
|
||||||
->add('manufacturer', EntityColumn::class, [
|
->add('manufacturer', EntityColumn::class, [
|
||||||
'property' => 'part.manufacturer',
|
'property' => 'part.manufacturer',
|
||||||
'label' => $this->translator->trans('part.table.manufacturer'),
|
'label' => $this->translator->trans('part.table.manufacturer'),
|
||||||
|
'orderField' => 'manufacturer.name',
|
||||||
])
|
])
|
||||||
|
|
||||||
->add('mountnames', TextColumn::class, [
|
->add('mountnames', TextColumn::class, [
|
||||||
|
@ -155,6 +159,8 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$dataTable->addOrderBy('name', DataTable::SORT_ASCENDING);
|
||||||
|
|
||||||
$dataTable->createAdapter(ORMAdapter::class, [
|
$dataTable->createAdapter(ORMAdapter::class, [
|
||||||
'entity' => Attachment::class,
|
'entity' => Attachment::class,
|
||||||
'query' => function (QueryBuilder $builder) use ($options): void {
|
'query' => function (QueryBuilder $builder) use ($options): void {
|
||||||
|
@ -175,6 +181,9 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
|
||||||
->addSelect('part')
|
->addSelect('part')
|
||||||
->from(ProjectBOMEntry::class, 'bom_entry')
|
->from(ProjectBOMEntry::class, 'bom_entry')
|
||||||
->leftJoin('bom_entry.part', 'part')
|
->leftJoin('bom_entry.part', 'part')
|
||||||
|
->leftJoin('part.category', 'category')
|
||||||
|
->leftJoin('part.footprint', 'footprint')
|
||||||
|
->leftJoin('part.manufacturer', 'manufacturer')
|
||||||
->where('bom_entry.project = :project')
|
->where('bom_entry.project = :project')
|
||||||
->setParameter('project', $options['project'])
|
->setParameter('project', $options['project'])
|
||||||
;
|
;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue