mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 00:04:04 +02:00
parent
4ab457a062
commit
4d9aa54814
@ -37,13 +37,13 @@ class Controller extends ModuleActionController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($sort = $request->getPost('sort'))) {
|
if (($sort = $request->getPost('sort')) || ($direction = $request->getPost('dir'))) {
|
||||||
$url = Url::fromRequest();
|
$url = Url::fromRequest();
|
||||||
$url->setParam('sort', $sort);
|
if ($sort) {
|
||||||
if (($dir = $request->getPost('dir'))) {
|
$url->setParam('sort', $sort);
|
||||||
$url->setParam('dir', $dir);
|
$url->remove('dir');
|
||||||
} else {
|
} else {
|
||||||
$url->removeParam('dir');
|
$url->setParam('dir', $direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->redirectNow($url);
|
$this->redirectNow($url);
|
||||||
|
@ -127,43 +127,56 @@ class SortBox extends AbstractWidget
|
|||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$form = new Form();
|
$columnForm = new Form();
|
||||||
$form->setTokenDisabled();
|
$columnForm->setTokenDisabled();
|
||||||
$form->setName($this->name);
|
$columnForm->setName($this->name . '-column');
|
||||||
$form->setAttrib('class', 'sort-control inline');
|
$columnForm->setAttrib('class', 'inline');
|
||||||
|
$columnForm->addElement(
|
||||||
$form->addElement(
|
|
||||||
'select',
|
'select',
|
||||||
'sort',
|
'sort',
|
||||||
array(
|
array(
|
||||||
'autosubmit' => true,
|
'autosubmit' => true,
|
||||||
'label' => $this->view()->translate('Sort by'),
|
'label' => $this->view()->translate('Sort by'),
|
||||||
'multiOptions' => $this->sortFields
|
'multiOptions' => $this->sortFields,
|
||||||
|
'decorators' => array(
|
||||||
|
array('ViewHelper'),
|
||||||
|
array('Label')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$form->getElement('sort')->setDecorators(array(
|
|
||||||
array('ViewHelper'),
|
$orderForm = new Form();
|
||||||
array('Label')
|
$orderForm->setTokenDisabled();
|
||||||
));
|
$orderForm->setName($this->name . '-order');
|
||||||
$form->addElement(
|
$orderForm->setAttrib('class', 'inline');
|
||||||
|
$orderForm->addElement(
|
||||||
'select',
|
'select',
|
||||||
'dir',
|
'dir',
|
||||||
array(
|
array(
|
||||||
'autosubmit' => true,
|
'autosubmit' => true,
|
||||||
|
'label' => $this->view()->translate('Direction', 'sort direction'),
|
||||||
'multiOptions' => array(
|
'multiOptions' => array(
|
||||||
'asc' => 'Asc',
|
'asc' => $this->view()->translate('Ascending', 'sort direction'),
|
||||||
'desc' => 'Desc',
|
'desc' => $this->view()->translate('Descending', 'sort direction')
|
||||||
),
|
),
|
||||||
'decorators' => array(
|
'decorators' => array(
|
||||||
array('ViewHelper')
|
array('ViewHelper'),
|
||||||
|
array('Label', array('class' => 'no-js'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->request) {
|
if ($this->request) {
|
||||||
$form->populate($this->request->getParams());
|
$url = $this->request->getUrl();
|
||||||
|
if ($url->hasParam('sort')) {
|
||||||
|
$columnForm->populate(array('sort' => $url->getParam('sort')));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($url->hasParam('dir')) {
|
||||||
|
$orderForm->populate(array('dir' => $url->getParam('dir')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $form;
|
return '<div class="sort-control">' . $columnForm . $orderForm . '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
form.sort-control {
|
div.sort-control {
|
||||||
.dontprint;
|
.dontprint;
|
||||||
float: right;
|
float: right;
|
||||||
|
|
||||||
@ -15,7 +15,13 @@ form.sort-control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
select[name=dir] {
|
select[name=dir] {
|
||||||
width: 5em;
|
width: 8em;
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html.no-js div.sort-control form {
|
||||||
|
display: table;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-top: 0.25em;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user