Skip to content

Commit 817e282

Browse files
Contactgroup: Implement missing search-suggestion and search-editor (#205)
2 parents 5c3e0e0 + 5f5d03e commit 817e282

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

application/controllers/ContactGroupsController.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Icinga\Module\Notifications\Common\Links;
99
use Icinga\Module\Notifications\Forms\ContactGroupForm;
1010
use Icinga\Module\Notifications\Model\Contactgroup;
11+
use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
1112
use Icinga\Module\Notifications\Widget\ItemList\ContactGroupList;
1213
use Icinga\Module\Notifications\Widget\MemberSuggestions;
1314
use Icinga\Web\Notification;
@@ -18,6 +19,8 @@
1819
use ipl\Web\Common\BaseItemList;
1920
use ipl\Web\Compat\CompatController;
2021
use ipl\Web\Compat\SearchControls;
22+
use ipl\Web\Control\LimitControl;
23+
use ipl\Web\Control\SortControl;
2124
use ipl\Web\Filter\QueryString;
2225
use ipl\Web\Widget\ButtonLink;
2326
use ipl\Web\Widget\Tabs;
@@ -122,6 +125,28 @@ public function addAction(): void
122125
$this->setTitle(t('Add Contact Group'));
123126
}
124127

128+
public function completeAction(): void
129+
{
130+
$suggestions = new ObjectSuggestions();
131+
$suggestions->setModel(Contactgroup::class);
132+
$suggestions->forRequest($this->getServerRequest());
133+
$this->getDocument()->add($suggestions);
134+
}
135+
136+
public function searchEditorAction(): void
137+
{
138+
$editor = $this->createSearchEditor(
139+
Contactgroup::on(Database::get()),
140+
[
141+
LimitControl::DEFAULT_LIMIT_PARAM,
142+
SortControl::DEFAULT_SORT_PARAM,
143+
]
144+
);
145+
146+
$this->getDocument()->add($editor);
147+
$this->setTitle($this->translate('Adjust Filter'));
148+
}
149+
125150
public function suggestMemberAction(): void
126151
{
127152
$members = new MemberSuggestions();

library/Notifications/Model/Contactgroup.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ public function getColumns(): array
3939
];
4040
}
4141

42+
public function getColumnDefinitions(): array
43+
{
44+
return ['name' => t('Name')];
45+
}
46+
47+
public function getSearchColumns(): array
48+
{
49+
return ['name'];
50+
}
51+
4252
public function createRelations(Relations $relations): void
4353
{
4454
$relations->hasMany('rule_escalation_recipient', RuleEscalationRecipient::class)

0 commit comments

Comments
 (0)