Skip to content

Commit

Permalink
Contactgroup: Implement missing search-suggestion and search-editor
Browse files Browse the repository at this point in the history
Model: Add search columns
  • Loading branch information
sukhwinder33445 committed Jun 12, 2024
1 parent 5c3e0e0 commit f4378e1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
25 changes: 25 additions & 0 deletions application/controllers/ContactGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions library/Notifications/Model/Contactgroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ 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)
Expand Down

0 comments on commit f4378e1

Please sign in to comment.