Skip to content

Commit 34fe027

Browse files
IncidentsController: Add ipl\Web\Control\ViewModeSwitcher
- Remove obsolete `view-mode-switcher.less`
1 parent ecd13e9 commit 34fe027

2 files changed

Lines changed: 17 additions & 51 deletions

File tree

application/controllers/IncidentsController.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@
1111
use Icinga\Module\Notifications\View\IncidentRenderer;
1212
use Icinga\Module\Notifications\Web\Control\SearchBar\ObjectSuggestions;
1313
use Icinga\Module\Notifications\Widget\ItemList\ObjectList;
14+
use ipl\Web\Common\Controls;
1415
use ipl\Web\Compat\CompatController;
1516
use ipl\Web\Compat\SearchControls;
1617
use ipl\Web\Control\LimitControl;
1718
use ipl\Web\Control\SortControl;
1819
use ipl\Web\Filter\QueryString;
20+
use ipl\Web\Layout\DetailedItemLayout;
21+
use ipl\Web\Layout\ItemLayout;
1922
use ipl\Web\Layout\MinimalItemLayout;
2023

2124
class IncidentsController extends CompatController
2225
{
2326
use Auth;
2427
use SearchControls;
28+
use Controls;
2529

2630
public function indexAction(): void
2731
{
@@ -42,11 +46,15 @@ public function indexAction(): void
4246
);
4347

4448
$paginationControl = $this->createPaginationControl($incidents);
49+
$viewModeSwitcher = $this->createViewModeSwitcher($this->params);
4550
$searchBar = $this->createSearchBar($incidents, [
4651
$limitControl->getLimitParam(),
4752
$sortControl->getSortParam(),
4853
]);
4954

55+
$this->applyViewModeLimit($limitControl, $paginationControl);
56+
$this->handleControls($this->getServerRequest());
57+
5058
if ($searchBar->hasBeenSent() && ! $searchBar->isValid()) {
5159
if ($searchBar->hasBeenSubmitted()) {
5260
$filter = QueryString::parse((string) $this->params);
@@ -65,12 +73,17 @@ public function indexAction(): void
6573
$this->addControl($paginationControl);
6674
$this->addControl($sortControl);
6775
$this->addControl($limitControl);
76+
$this->addControl($viewModeSwitcher);
6877
$this->addControl($searchBar);
6978

70-
$incidentList = (new ObjectList($incidents, new IncidentRenderer()))
71-
->setItemLayoutClass(MinimalItemLayout::class);
72-
73-
$this->addContent($incidentList);
79+
$this->addContent(
80+
(new ObjectList($incidents, new IncidentRenderer()))
81+
->setItemLayoutClass(match ($viewModeSwitcher->getViewMode()) {
82+
'minimal' => MinimalItemLayout::class,
83+
'detailed' => DetailedItemLayout::class,
84+
'common' => ItemLayout::class
85+
})
86+
);
7487

7588
if (! $searchBar->hasBeenSubmitted() && $searchBar->hasBeenSent()) {
7689
$this->sendMultipartUpdate();

public/css/view-mode-switcher.less

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)