From 5cabd368c25c907ee2e2991e1c7cb5058404b9be Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 2 Nov 2020 14:33:08 +0100 Subject: [PATCH] usergroups/: Show search bar control --- .../controllers/UsergroupsController.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/application/controllers/UsergroupsController.php b/application/controllers/UsergroupsController.php index ce1502d2..2a6bc01e 100644 --- a/application/controllers/UsergroupsController.php +++ b/application/controllers/UsergroupsController.php @@ -4,7 +4,9 @@ namespace Icinga\Module\Icingadb\Controllers; +use GuzzleHttp\Psr7\ServerRequest; use Icinga\Module\Icingadb\Model\Usergroup; +use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList; use Icinga\Security\SecurityException; @@ -28,6 +30,8 @@ class UsergroupsController extends Controller $usergroups = Usergroup::on($db)->with('user'); + $this->handleSearchRequest($usergroups); + $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($usergroups); $sortControl = $this->createSortControl( @@ -36,19 +40,34 @@ class UsergroupsController extends Controller 'usergroup.display_name' => t('Name') ] ); - $filterControl = $this->createFilterControl($usergroups); + $searchBar = $this->createSearchBar($usergroups, [ + $limitControl->getLimitParam(), + $sortControl->getSortParam() + ]); - $this->filter($usergroups); + $this->filter($usergroups, $searchBar->getFilter()); yield $this->export($usergroups); $this->addControl($paginationControl); $this->addControl($sortControl); $this->addControl($limitControl); - $this->addControl($filterControl); + $this->addControl($searchBar); $this->addContent(new UsergroupList($usergroups)); + if ($searchBar->hasBeenSent()) { + $this->sendMultipartUpdate(); + } + $this->setAutorefreshInterval(10); } + + public function completeAction() + { + $suggestions = new ObjectSuggestions(); + $suggestions->setModel(Usergroup::class); + $suggestions->forRequest(ServerRequest::fromGlobals()); + $this->getDocument()->add($suggestions); + } }