Skip to content

PoC for predefined filters in the tools sidebar menu #945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Controller/PartListsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,35 @@
{
return $this->showListWithFilter($request,'parts/lists/all_list.html.twig');
}

#[Route(path: '/parts/filter/less_than_desired', name: 'parts_filter_less_than_desired')]

Check warning on line 345 in src/Controller/PartListsController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/PartListsController.php#L345

Added line #L345 was not covered by tests
public function showLessThanDesiredFilter(Request $request): Response
{
return $this->showListWithFilter($request,
'parts/lists/all_list.html.twig',
function (PartFilter $filter) {
$filter->lessThanDesired->setValue(true);
},
function (FormInterface $filterForm) {
$this->disableFormFieldAfterCreation($filterForm->get('lessThanDesired')->get('value'));
}
);

Check warning on line 356 in src/Controller/PartListsController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/PartListsController.php#L348-L356

Added lines #L348 - L356 were not covered by tests
}

#[Route(path: '/parts/filter/custom', name: 'parts_filter_custom')]

Check warning on line 359 in src/Controller/PartListsController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/PartListsController.php#L359

Added line #L359 was not covered by tests
public function showCustomFilter(Request $request): Response
{
// TODO custom filters will need custom access permission checks!
return $this->showListWithFilter($request,
'parts/lists/all_list.html.twig',
function (PartFilter $filter) {
;
},
function (FormInterface $filterForm) {
;
}
);

Check warning on line 371 in src/Controller/PartListsController.php

View check run for this annotation

Codecov / codecov/patch

src/Controller/PartListsController.php#L363-L371

Added lines #L363 - L371 were not covered by tests
}


}
28 changes: 28 additions & 0 deletions src/Services/Trees/ToolsTreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,38 @@ public function getTree(): array
});
}

protected function getFilterNode(): array
{
$nodes = [];

if ($this->security->isGranted('@parts.read')) {
$nodes[] = (new TreeViewNode(
$this->translator->trans('filter.less_than_desired'),
$this->urlGenerator->generate('parts_filter_less_than_desired')
))->setIcon("fa-treeview fa-fw fa-solid fa-circle-exclamation");
}

if ($this->security->isGranted('@parts.read')) {
$nodes[] = (new TreeViewNode(
$this->translator->trans('filter.custom'),
$this->urlGenerator->generate('parts_filter_custom')
))->setIcon("fa-treeview fa-fw fa-solid fa-code");
}
return $nodes;
}

protected function getToolsNode(): array
{
$nodes = [];

if ($this->security->isGranted('@parts.read')) {
$nodes[] = (new TreeViewNode(
$this->translator->trans('filter.title'),
null,
$this->getFilterNode()
))->setIcon("fa-fw fa-treeview fa-solid fa-filter");
}

if ($this->security->isGranted('@labels.create_labels')) {
$nodes[] = (new TreeViewNode(
$this->translator->trans('tree.tools.tools.label_dialog'),
Expand Down
Loading