From 5f5d03eb479adfd32afd92515b467e5496882c61 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 12 Jun 2024 14:00:10 +0200 Subject: [PATCH] Contactgroup: Implement missing search-suggestion and search-editor Model: Add search columns --- .../controllers/ContactGroupsController.php | 25 +++++++++++++++++++ library/Notifications/Model/Contactgroup.php | 10 ++++++++ 2 files changed, 35 insertions(+) diff --git a/application/controllers/ContactGroupsController.php b/application/controllers/ContactGroupsController.php index 70f80502..d37e7e29 100644 --- a/application/controllers/ContactGroupsController.php +++ b/application/controllers/ContactGroupsController.php @@ -8,6 +8,7 @@ use Icinga\Module\Notifications\Common\Links; use Icinga\Module\Notifications\Forms\ContactGroupForm; use Icinga\Module\Notifications\Model\Contactgroup; +use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions; use Icinga\Module\Notifications\Widget\ItemList\ContactGroupList; use Icinga\Module\Notifications\Widget\MemberSuggestions; use Icinga\Web\Notification; @@ -18,6 +19,8 @@ use ipl\Web\Common\BaseItemList; use ipl\Web\Compat\CompatController; use ipl\Web\Compat\SearchControls; +use ipl\Web\Control\LimitControl; +use ipl\Web\Control\SortControl; use ipl\Web\Filter\QueryString; use ipl\Web\Widget\ButtonLink; use ipl\Web\Widget\Tabs; @@ -122,6 +125,28 @@ public function addAction(): void $this->setTitle(t('Add Contact Group')); } + public function completeAction(): void + { + $suggestions = new ObjectSuggestions(); + $suggestions->setModel(Contactgroup::class); + $suggestions->forRequest($this->getServerRequest()); + $this->getDocument()->add($suggestions); + } + + public function searchEditorAction(): void + { + $editor = $this->createSearchEditor( + Contactgroup::on(Database::get()), + [ + LimitControl::DEFAULT_LIMIT_PARAM, + SortControl::DEFAULT_SORT_PARAM, + ] + ); + + $this->getDocument()->add($editor); + $this->setTitle($this->translate('Adjust Filter')); + } + public function suggestMemberAction(): void { $members = new MemberSuggestions(); diff --git a/library/Notifications/Model/Contactgroup.php b/library/Notifications/Model/Contactgroup.php index f4e487b7..1f755af8 100644 --- a/library/Notifications/Model/Contactgroup.php +++ b/library/Notifications/Model/Contactgroup.php @@ -39,6 +39,16 @@ public function getColumns(): array ]; } + public function getColumnDefinitions(): array + { + return ['name' => t('Name')]; + } + + public function getSearchColumns(): array + { + return ['name']; + } + public function createRelations(Relations $relations): void { $relations->hasMany('rule_escalation_recipient', RuleEscalationRecipient::class)