user navigation overview: Add sort control

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-18 08:53:05 +02:00
parent 996224f54a
commit 2cf52df0a8
3 changed files with 25 additions and 7 deletions

View File

@ -7,6 +7,7 @@ use Exception;
use Icinga\Application\Config;
use Icinga\Application\Icinga;
use Icinga\Exception\NotFoundError;
use Icinga\Data\DataArray\ArrayDatasource;
use Icinga\Forms\ConfirmRemovalForm;
use Icinga\Forms\Navigation\NavigationConfigForm;
use Icinga\Web\Controller;
@ -63,14 +64,16 @@ class NavigationController extends Controller
public function indexAction()
{
$user = $this->Auth()->getUser();
$userConfig = $user->loadNavigationConfig();
$sharedConfig = Config::app('navigation');
$ds = new ArrayDatasource(array_merge(
Config::app('navigation')->select()->where('owner', $user->getUsername())->fetchAll(),
iterator_to_array($user->loadNavigationConfig())
));
$ds->setKeyColumn('name');
$query = $ds->select();
$this->view->types = $this->listItemTypes();
$this->view->items = array_merge(
$sharedConfig->select()->where('owner', $user->getUsername())->fetchAll(),
iterator_to_array($userConfig)
);
$this->view->items = $query;
$this->getTabs()->add(
'navigation',
@ -80,6 +83,13 @@ class NavigationController extends Controller
'url' => 'navigation'
)
)->activate('navigation');
$this->setupSortControl(
array(
'name' => $this->translate('Shared Navigation'),
'type' => $this->translate('Type')
),
$query
);
}
/**

View File

@ -1,12 +1,19 @@
<?php if (! $this->compact): ?>
<div class="controls">
<?= $this->tabs; ?>
<?= $this->sortBox; ?>
<?= $this->limiter; ?>
<?= $this->paginator; ?>
<?= $this->filterEditor; ?>
</div>
<?php endif ?>
<div class="content" data-base-target="_next">
<a href="<?= $this->href('navigation/add'); ?>">
<?= $this->icon('plus'); ?> <?= $this->translate('Create A New Navigation Item'); ?>
</a>
<?php if (count($items) === 0): ?>
<p><?= $this->translate('You did not create any navigation item yet'); ?></p>
<?php else: ?>
<table class="action alternating">
<thead>
<th><?= $this->translate('Navigation'); ?></th>
@ -40,4 +47,5 @@
<?php endforeach ?>
</tbody>
</table>
<?php endif ?>
</div>

View File

@ -9,7 +9,7 @@
<?php endif ?>
<div class="content" data-base-target="_next">
<?php if (count($items) === 0): ?>
<?= $this->translate('There are currently no navigation items being shared'); ?>
<p><?= $this->translate('There are currently no navigation items being shared'); ?></p>
<?php else: ?>
<table class="action alternating">
<thead>