mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-06 11:09:29 +00:00
Added an settings option to change the default behavior of including child categories or not
Fixes issue #1077
This commit is contained in:
parent
5dbe4ba00b
commit
1c8ca6c0a2
3 changed files with 37 additions and 7 deletions
|
|
@ -36,6 +36,7 @@ use App\Exceptions\InvalidRegexException;
|
||||||
use App\Form\Filters\PartFilterType;
|
use App\Form\Filters\PartFilterType;
|
||||||
use App\Services\Parts\PartsTableActionHandler;
|
use App\Services\Parts\PartsTableActionHandler;
|
||||||
use App\Services\Trees\NodesListBuilder;
|
use App\Services\Trees\NodesListBuilder;
|
||||||
|
use App\Settings\BehaviorSettings\SidebarSettings;
|
||||||
use App\Settings\BehaviorSettings\TableSettings;
|
use App\Settings\BehaviorSettings\TableSettings;
|
||||||
use Doctrine\DBAL\Exception\DriverException;
|
use Doctrine\DBAL\Exception\DriverException;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
@ -56,11 +57,21 @@ class PartListsController extends AbstractController
|
||||||
private readonly NodesListBuilder $nodesListBuilder,
|
private readonly NodesListBuilder $nodesListBuilder,
|
||||||
private readonly DataTableFactory $dataTableFactory,
|
private readonly DataTableFactory $dataTableFactory,
|
||||||
private readonly TranslatorInterface $translator,
|
private readonly TranslatorInterface $translator,
|
||||||
private readonly TableSettings $tableSettings
|
private readonly TableSettings $tableSettings,
|
||||||
|
private readonly SidebarSettings $sidebarSettings,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the filter operator to use by default (INCLUDING_CHILDREN or =)
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getFilterOperator(): string
|
||||||
|
{
|
||||||
|
return $this->sidebarSettings->dataStructureNodesTableIncludeChildren ? 'INCLUDING_CHILDREN' : '=';
|
||||||
|
}
|
||||||
|
|
||||||
#[Route(path: '/table/action', name: 'table_action', methods: ['POST'])]
|
#[Route(path: '/table/action', name: 'table_action', methods: ['POST'])]
|
||||||
public function tableAction(Request $request, PartsTableActionHandler $actionHandler): Response
|
public function tableAction(Request $request, PartsTableActionHandler $actionHandler): Response
|
||||||
{
|
{
|
||||||
|
|
@ -203,7 +214,7 @@ class PartListsController extends AbstractController
|
||||||
return $this->showListWithFilter($request,
|
return $this->showListWithFilter($request,
|
||||||
'parts/lists/category_list.html.twig',
|
'parts/lists/category_list.html.twig',
|
||||||
function (PartFilter $filter) use ($category) {
|
function (PartFilter $filter) use ($category) {
|
||||||
$filter->category->setOperator('INCLUDING_CHILDREN')->setValue($category);
|
$filter->category->setOperator($this->getFilterOperator())->setValue($category);
|
||||||
}, function (FormInterface $filterForm) {
|
}, function (FormInterface $filterForm) {
|
||||||
$this->disableFormFieldAfterCreation($filterForm->get('category')->get('value'));
|
$this->disableFormFieldAfterCreation($filterForm->get('category')->get('value'));
|
||||||
}, [
|
}, [
|
||||||
|
|
@ -221,7 +232,7 @@ class PartListsController extends AbstractController
|
||||||
return $this->showListWithFilter($request,
|
return $this->showListWithFilter($request,
|
||||||
'parts/lists/footprint_list.html.twig',
|
'parts/lists/footprint_list.html.twig',
|
||||||
function (PartFilter $filter) use ($footprint) {
|
function (PartFilter $filter) use ($footprint) {
|
||||||
$filter->footprint->setOperator('INCLUDING_CHILDREN')->setValue($footprint);
|
$filter->footprint->setOperator($this->getFilterOperator())->setValue($footprint);
|
||||||
}, function (FormInterface $filterForm) {
|
}, function (FormInterface $filterForm) {
|
||||||
$this->disableFormFieldAfterCreation($filterForm->get('footprint')->get('value'));
|
$this->disableFormFieldAfterCreation($filterForm->get('footprint')->get('value'));
|
||||||
}, [
|
}, [
|
||||||
|
|
@ -239,7 +250,7 @@ class PartListsController extends AbstractController
|
||||||
return $this->showListWithFilter($request,
|
return $this->showListWithFilter($request,
|
||||||
'parts/lists/manufacturer_list.html.twig',
|
'parts/lists/manufacturer_list.html.twig',
|
||||||
function (PartFilter $filter) use ($manufacturer) {
|
function (PartFilter $filter) use ($manufacturer) {
|
||||||
$filter->manufacturer->setOperator('INCLUDING_CHILDREN')->setValue($manufacturer);
|
$filter->manufacturer->setOperator($this->getFilterOperator())->setValue($manufacturer);
|
||||||
}, function (FormInterface $filterForm) {
|
}, function (FormInterface $filterForm) {
|
||||||
$this->disableFormFieldAfterCreation($filterForm->get('manufacturer')->get('value'));
|
$this->disableFormFieldAfterCreation($filterForm->get('manufacturer')->get('value'));
|
||||||
}, [
|
}, [
|
||||||
|
|
@ -257,7 +268,7 @@ class PartListsController extends AbstractController
|
||||||
return $this->showListWithFilter($request,
|
return $this->showListWithFilter($request,
|
||||||
'parts/lists/store_location_list.html.twig',
|
'parts/lists/store_location_list.html.twig',
|
||||||
function (PartFilter $filter) use ($storelocation) {
|
function (PartFilter $filter) use ($storelocation) {
|
||||||
$filter->storelocation->setOperator('INCLUDING_CHILDREN')->setValue($storelocation);
|
$filter->storelocation->setOperator($this->getFilterOperator())->setValue($storelocation);
|
||||||
}, function (FormInterface $filterForm) {
|
}, function (FormInterface $filterForm) {
|
||||||
$this->disableFormFieldAfterCreation($filterForm->get('storelocation')->get('value'));
|
$this->disableFormFieldAfterCreation($filterForm->get('storelocation')->get('value'));
|
||||||
}, [
|
}, [
|
||||||
|
|
@ -275,7 +286,7 @@ class PartListsController extends AbstractController
|
||||||
return $this->showListWithFilter($request,
|
return $this->showListWithFilter($request,
|
||||||
'parts/lists/supplier_list.html.twig',
|
'parts/lists/supplier_list.html.twig',
|
||||||
function (PartFilter $filter) use ($supplier) {
|
function (PartFilter $filter) use ($supplier) {
|
||||||
$filter->supplier->setOperator('INCLUDING_CHILDREN')->setValue($supplier);
|
$filter->supplier->setOperator($this->getFilterOperator())->setValue($supplier);
|
||||||
}, function (FormInterface $filterForm) {
|
}, function (FormInterface $filterForm) {
|
||||||
$this->disableFormFieldAfterCreation($filterForm->get('supplier')->get('value'));
|
$this->disableFormFieldAfterCreation($filterForm->get('supplier')->get('value'));
|
||||||
}, [
|
}, [
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,11 @@ class SidebarSettings
|
||||||
*/
|
*/
|
||||||
#[SettingsParameter(label: new TM("settings.behavior.sidebar.rootNodeRedirectsToNewEntity"))]
|
#[SettingsParameter(label: new TM("settings.behavior.sidebar.rootNodeRedirectsToNewEntity"))]
|
||||||
public bool $rootNodeRedirectsToNewEntity = false;
|
public bool $rootNodeRedirectsToNewEntity = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Whether to include child nodes in the data structure nodes table, or only show the selected node's parts.
|
||||||
|
*/
|
||||||
|
#[SettingsParameter(label: new TM("settings.behavior.sidebar.data_structure_nodes_table_include_children"),
|
||||||
|
description: new TM("settings.behavior.sidebar.data_structure_nodes_table_include_children.help"))]
|
||||||
|
public bool $dataStructureNodesTableIncludeChildren = true;
|
||||||
}
|
}
|
||||||
|
|
@ -14232,5 +14232,17 @@ Please note, that you can not impersonate a disabled user. If you try you will g
|
||||||
<target>Project has no BOM entries</target>
|
<target>Project has no BOM entries</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="pCKgjIr" name="settings.behavior.sidebar.data_structure_nodes_table_include_children">
|
||||||
|
<segment>
|
||||||
|
<source>settings.behavior.sidebar.data_structure_nodes_table_include_children</source>
|
||||||
|
<target>Tables should include children nodes by default</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="KJQHfwV" name="settings.behavior.sidebar.data_structure_nodes_table_include_children.help">
|
||||||
|
<segment>
|
||||||
|
<source>settings.behavior.sidebar.data_structure_nodes_table_include_children.help</source>
|
||||||
|
<target>If checked, the part tables for categories, footprints, etc. should include all parts of child categories. If not checked, only parts that strictly belong to the clicked node are shown.</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue