3636use App \Form \Filters \PartFilterType ;
3737use App \Services \Parts \PartsTableActionHandler ;
3838use App \Services \Trees \NodesListBuilder ;
39+ use App \Settings \BehaviorSettings \SidebarSettings ;
3940use App \Settings \BehaviorSettings \TableSettings ;
4041use Doctrine \DBAL \Exception \DriverException ;
4142use Doctrine \ORM \EntityManagerInterface ;
@@ -56,11 +57,21 @@ public function __construct(private readonly EntityManagerInterface $entityManag
5657 private readonly NodesListBuilder $ nodesListBuilder ,
5758 private readonly DataTableFactory $ dataTableFactory ,
5859 private readonly TranslatorInterface $ translator ,
59- private readonly TableSettings $ tableSettings
60+ private readonly TableSettings $ tableSettings ,
61+ private readonly SidebarSettings $ sidebarSettings ,
6062 )
6163 {
6264 }
6365
66+ /**
67+ * Gets the filter operator to use by default (INCLUDING_CHILDREN or =)
68+ * @return string
69+ */
70+ private function getFilterOperator (): string
71+ {
72+ return $ this ->sidebarSettings ->dataStructureNodesTableIncludeChildren ? 'INCLUDING_CHILDREN ' : '= ' ;
73+ }
74+
6475 #[Route(path: '/table/action ' , name: 'table_action ' , methods: ['POST ' ])]
6576 public function tableAction (Request $ request , PartsTableActionHandler $ actionHandler ): Response
6677 {
@@ -203,7 +214,7 @@ public function showCategory(Category $category, Request $request): Response
203214 return $ this ->showListWithFilter ($ request ,
204215 'parts/lists/category_list.html.twig ' ,
205216 function (PartFilter $ filter ) use ($ category ) {
206- $ filter ->category ->setOperator (' INCLUDING_CHILDREN ' )->setValue ($ category );
217+ $ filter ->category ->setOperator ($ this -> getFilterOperator () )->setValue ($ category );
207218 }, function (FormInterface $ filterForm ) {
208219 $ this ->disableFormFieldAfterCreation ($ filterForm ->get ('category ' )->get ('value ' ));
209220 }, [
@@ -221,7 +232,7 @@ public function showFootprint(Footprint $footprint, Request $request): Response
221232 return $ this ->showListWithFilter ($ request ,
222233 'parts/lists/footprint_list.html.twig ' ,
223234 function (PartFilter $ filter ) use ($ footprint ) {
224- $ filter ->footprint ->setOperator (' INCLUDING_CHILDREN ' )->setValue ($ footprint );
235+ $ filter ->footprint ->setOperator ($ this -> getFilterOperator () )->setValue ($ footprint );
225236 }, function (FormInterface $ filterForm ) {
226237 $ this ->disableFormFieldAfterCreation ($ filterForm ->get ('footprint ' )->get ('value ' ));
227238 }, [
@@ -239,7 +250,7 @@ public function showManufacturer(Manufacturer $manufacturer, Request $request):
239250 return $ this ->showListWithFilter ($ request ,
240251 'parts/lists/manufacturer_list.html.twig ' ,
241252 function (PartFilter $ filter ) use ($ manufacturer ) {
242- $ filter ->manufacturer ->setOperator (' INCLUDING_CHILDREN ' )->setValue ($ manufacturer );
253+ $ filter ->manufacturer ->setOperator ($ this -> getFilterOperator () )->setValue ($ manufacturer );
243254 }, function (FormInterface $ filterForm ) {
244255 $ this ->disableFormFieldAfterCreation ($ filterForm ->get ('manufacturer ' )->get ('value ' ));
245256 }, [
@@ -257,7 +268,7 @@ public function showStorelocation(StorageLocation $storelocation, Request $reque
257268 return $ this ->showListWithFilter ($ request ,
258269 'parts/lists/store_location_list.html.twig ' ,
259270 function (PartFilter $ filter ) use ($ storelocation ) {
260- $ filter ->storelocation ->setOperator (' INCLUDING_CHILDREN ' )->setValue ($ storelocation );
271+ $ filter ->storelocation ->setOperator ($ this -> getFilterOperator () )->setValue ($ storelocation );
261272 }, function (FormInterface $ filterForm ) {
262273 $ this ->disableFormFieldAfterCreation ($ filterForm ->get ('storelocation ' )->get ('value ' ));
263274 }, [
@@ -275,7 +286,7 @@ public function showSupplier(Supplier $supplier, Request $request): Response
275286 return $ this ->showListWithFilter ($ request ,
276287 'parts/lists/supplier_list.html.twig ' ,
277288 function (PartFilter $ filter ) use ($ supplier ) {
278- $ filter ->supplier ->setOperator (' INCLUDING_CHILDREN ' )->setValue ($ supplier );
289+ $ filter ->supplier ->setOperator ($ this -> getFilterOperator () )->setValue ($ supplier );
279290 }, function (FormInterface $ filterForm ) {
280291 $ this ->disableFormFieldAfterCreation ($ filterForm ->get ('supplier ' )->get ('value ' ));
281292 }, [
0 commit comments