Skip to content

Commit

Permalink
(EventRule|Schedule)ListItem: Respect new deleted flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jul 8, 2024
1 parent 854ea3b commit 38a7e06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 6 additions & 4 deletions library/Notifications/Widget/ItemList/EventRuleListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Icinga\Module\Notifications\Widget\RuleEscalationRecipientBadge;
use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;
use ipl\Stdlib\Filter;
use ipl\Web\Common\BaseListItem;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\Link;
Expand Down Expand Up @@ -38,7 +39,7 @@ protected function assembleFooter(BaseHtmlElement $footer): void
$meta->add(Html::tag('span', new Icon('filter')));
}

$escalationCount = $this->item->rule_escalation->count();
$escalationCount = $this->item->rule_escalation->filter(Filter::equal('deleted', 'n'))->count();
if ($escalationCount > 1) {
$meta->add(Html::tag('span', [new Icon('code-branch'), $escalationCount]));
}
Expand All @@ -55,12 +56,13 @@ protected function assembleHeader(BaseHtmlElement $header): void
{
$header->add($this->createTitle());
//TODO(sd): need fixes?
$rs = $this->item->rule_escalation->first();
$rs = $this->item->rule_escalation->filter(Filter::equal('deleted', 'n'))->first();
if ($rs) {
$recipientCount = $rs->rule_escalation_recipient->count();
$recipients = $rs->rule_escalation_recipient->filter(Filter::equal('deleted', 'n'));
$recipientCount = $recipients->count();
if ($recipientCount) {
$header->add(new RuleEscalationRecipientBadge(
$rs->rule_escalation_recipient->first(),
$recipients->first(),
$recipientCount - 1
));
}
Expand Down
9 changes: 8 additions & 1 deletion library/Notifications/Widget/ItemList/ScheduleListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Icinga\Module\Notifications\Widget\Timeline\Rotation;
use Icinga\Util\Csp;
use ipl\Html\BaseHtmlElement;
use ipl\Stdlib\Filter;
use ipl\Web\Common\BaseListItem;
use ipl\Web\Style;
use ipl\Web\Widget\Link;
Expand Down Expand Up @@ -58,7 +59,13 @@ protected function assembleCaption(BaseHtmlElement $caption): void
->setModule('notifications')
);

foreach ($this->item->rotation->with('timeperiod')->orderBy('first_handoff', SORT_DESC) as $rotation) {
$rotations = $this->item
->rotation
->with('timeperiod')
->filter(Filter::equal('deleted', 'n'))
->orderBy('first_handoff', SORT_DESC);

foreach ($rotations as $rotation) {
$timeline->addRotation(new Rotation($rotation));
}

Expand Down

0 comments on commit 38a7e06

Please sign in to comment.