Skip to content

Commit 68f7fd1

Browse files
committed
Fix active list item handling
1 parent ba627b4 commit 68f7fd1

13 files changed

+82
-10
lines changed

library/Notifications/Common/Links.php

+30-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
*/
1212
abstract class Links
1313
{
14-
public static function event(int $id): Url
14+
public static function event(?int $id = null): Url
1515
{
16+
if ($id === null) {
17+
return Url::fromPath('notifications/event');
18+
}
19+
1620
return Url::fromPath('notifications/event', ['id' => $id]);
1721
}
1822

@@ -26,8 +30,12 @@ public static function incidents(): Url
2630
return Url::fromPath('notifications/incidents');
2731
}
2832

29-
public static function incident(int $id): Url
33+
public static function incident(?int $id = null): Url
3034
{
35+
if ($id === null) {
36+
return Url::fromPath('notifications/incident');
37+
}
38+
3139
return Url::fromPath('notifications/incident', ['id' => $id]);
3240
}
3341

@@ -36,8 +44,12 @@ public static function contacts(): Url
3644
return Url::fromPath('notifications/contacts');
3745
}
3846

39-
public static function contact(int $id): Url
47+
public static function contact(?int $id = null): Url
4048
{
49+
if ($id === null) {
50+
return Url::fromPath('notifications/contact');
51+
}
52+
4153
return Url::fromPath('notifications/contact', ['id' => $id]);
4254
}
4355

@@ -46,8 +58,12 @@ public static function eventRules(): Url
4658
return Url::fromPath('notifications/event-rules');
4759
}
4860

49-
public static function eventRule(int $id): Url
61+
public static function eventRule(?int $id = null): Url
5062
{
63+
if ($id === null) {
64+
return Url::fromPath('notifications/event-rule');
65+
}
66+
5167
return Url::fromPath('notifications/event-rule', ['id' => $id]);
5268
}
5369

@@ -56,8 +72,12 @@ public static function schedules(): Url
5672
return Url::fromPath('notifications/schedules');
5773
}
5874

59-
public static function schedule(int $id): Url
75+
public static function schedule(?int $id = null): Url
6076
{
77+
if ($id === null) {
78+
return Url::fromPath('notifications/schedule');
79+
}
80+
6181
return Url::fromPath('notifications/schedule', ['id' => $id]);
6282
}
6383

@@ -86,8 +106,12 @@ public static function contactGroupsSuggestMember(): Url
86106
return Url::fromPath('notifications/contact-groups/suggest-member');
87107
}
88108

89-
public static function contactGroup(int $id): Url
109+
public static function contactGroup(?int $id = null): Url
90110
{
111+
if ($id === null) {
112+
return Url::fromPath('notifications/contact-group');
113+
}
114+
91115
return Url::fromPath('notifications/contact-group', ['id' => $id]);
92116
}
93117

library/Notifications/Widget/ItemList/ContactGroupList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use ipl\Web\Common\BaseItemList;
89

910
class ContactGroupList extends BaseItemList
@@ -14,4 +15,10 @@ protected function getItemClass(): string
1415
{
1516
return ContactGroupListItem::class;
1617
}
18+
19+
protected function init(): void
20+
{
21+
$this->getAttributes()
22+
->set('data-icinga-detail-url', (string) Links::contactGroup());
23+
}
1724
}

library/Notifications/Widget/ItemList/ContactGroupListItem.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class ContactGroupListItem extends BaseListItem
2323

2424
protected function init(): void
2525
{
26-
$this->getAttributes()->set('data-action-item', true);
26+
$this->getAttributes()
27+
->set('data-action-item', true)
28+
->set('data-icinga-detail-filter', Links::contactGroup($this->item->id)->getQueryString());
2729
}
2830

2931
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/ContactList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use ipl\Web\Common\BaseItemList;
89

910
class ContactList extends BaseItemList
@@ -14,4 +15,10 @@ protected function getItemClass(): string
1415
{
1516
return ContactListItem::class;
1617
}
18+
19+
protected function init(): void
20+
{
21+
$this->getAttributes()
22+
->set('data-icinga-detail-url', (string) Links::contact());
23+
}
1724
}

library/Notifications/Widget/ItemList/ContactListItem.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use Icinga\Module\Notifications\Model\Contact;
89
use ipl\Html\Attributes;
910
use ipl\Html\BaseHtmlElement;
@@ -28,7 +29,8 @@ class ContactListItem extends BaseListItem
2829
protected function init(): void
2930
{
3031
$this->getAttributes()
31-
->set('data-action-item', true);
32+
->set('data-action-item', true)
33+
->set('data-icinga-detail-filter', Links::contactGroup($this->item->id)->getQueryString());
3234
}
3335

3436
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/EventList.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use Icinga\Module\Notifications\Common\LoadMore;
89
use Icinga\Module\Notifications\Common\NoSubjectLink;
910
use Icinga\Module\Notifications\Hook\ObjectsRendererHook;
@@ -37,6 +38,9 @@ protected function init(): void
3738
$this->on(self::ON_ASSEMBLED, function () {
3839
ObjectsRendererHook::load();
3940
});
41+
42+
$this->getAttributes()
43+
->set('data-icinga-detail-url', (string) Links::event());
4044
}
4145

4246
protected function getItemClass(): string

library/Notifications/Widget/ItemList/EventListItem.php

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ protected function init(): void
4747
$this->getAttributes()
4848
->set('data-action-item', true);
4949
}
50+
51+
$this->getAttributes()
52+
->set('data-icinga-detail-filter', Links::event($this->item->id)->getQueryString());
5053
}
5154

5255
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/EventRuleList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use Icinga\Module\Notifications\Common\LoadMore;
89
use ipl\Web\Common\BaseItemList;
910

@@ -17,4 +18,10 @@ protected function getItemClass(): string
1718
{
1819
return EventRuleListItem::class;
1920
}
21+
22+
protected function init(): void
23+
{
24+
$this->getAttributes()
25+
->set('data-icinga-detail-url', (string) Links::eventRule());
26+
}
2027
}

library/Notifications/Widget/ItemList/EventRuleListItem.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class EventRuleListItem extends BaseListItem
2828
protected function init(): void
2929
{
3030
$this->getAttributes()
31-
->set('data-action-item', true);
31+
->set('data-action-item', true)
32+
->set('data-icinga-detail-filter', Links::eventRule($this->item->id)->getQueryString());
3233
}
3334

3435
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/IncidentList.php

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use Icinga\Module\Notifications\Hook\ObjectsRendererHook;
89
use Icinga\Module\Notifications\Model\Incident;
910
use ipl\Web\Common\BaseItemList;
@@ -24,6 +25,9 @@ protected function init(): void
2425
$this->on(self::ON_ASSEMBLED, function () {
2526
ObjectsRendererHook::load();
2627
});
28+
29+
$this->getAttributes()
30+
->set('data-icinga-detail-url', (string) Links::incident());
2731
}
2832

2933
protected function getItemClass(): string

library/Notifications/Widget/ItemList/IncidentListItem.php

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ protected function init(): void
4141
$this->getAttributes()
4242
->set('data-action-item', true);
4343
}
44+
45+
$this->getAttributes()
46+
->set('data-icinga-detail-filter', Links::incident($this->item->id)->getQueryString());
4447
}
4548

4649
protected function assembleVisual(BaseHtmlElement $visual): void

library/Notifications/Widget/ItemList/ScheduleList.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Icinga\Module\Notifications\Widget\ItemList;
66

7+
use Icinga\Module\Notifications\Common\Links;
78
use ipl\Web\Common\BaseItemList;
89

910
class ScheduleList extends BaseItemList
@@ -14,4 +15,10 @@ protected function getItemClass(): string
1415
{
1516
return ScheduleListItem::class;
1617
}
18+
19+
protected function init(): void
20+
{
21+
$this->getAttributes()
22+
->set('data-icinga-detail-url', (string) Links::schedule());
23+
}
1724
}

library/Notifications/Widget/ItemList/ScheduleListItem.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class ScheduleListItem extends BaseListItem
2424
protected function init(): void
2525
{
2626
$this->getAttributes()
27-
->set('data-action-item', true);
27+
->set('data-action-item', true)
28+
->set('data-icinga-detail-filter', Links::schedule($this->item->id)->getQueryString());
2829
}
2930

3031
protected function assembleTitle(BaseHtmlElement $title): void

0 commit comments

Comments
 (0)