usergroups/: Show search bar control

This commit is contained in:
Johannes Meyer 2020-11-02 14:33:08 +01:00
parent 07f78b507d
commit 5cabd368c2

View file

@ -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);
}
}