Fix SortBox not usable w/o SortRules
The SortBox assumes the first avaiable sort column as default column if the given Sortable does not implement the SortRules interface. When changing the direction of the default sort column, the sort box did not pass the column to Sortable::sort(). Thus the Sortable did not know by which column to sort. Now the SortBox passes the sort column even if the direction of the default column is changed. refs #9333
This commit is contained in:
parent
f2f1e12b8e
commit
1492218962
|
@ -118,12 +118,12 @@ class SortBox extends AbstractWidget
|
|||
if ($request === null) {
|
||||
$request = Icinga::app()->getRequest();
|
||||
}
|
||||
|
||||
if (($sort = $request->getParam('sort'))) {
|
||||
$this->query->order($sort, $request->getParam('dir'));
|
||||
} elseif (($dir = $request->getParam('dir'))) {
|
||||
$this->query->order(null, $dir);
|
||||
if (null === $sort = $request->getParam('sort')) {
|
||||
list($sort, $dir) = $this->getSortDefaults();
|
||||
} else {
|
||||
list($_, $dir) = $this->getSortDefaults($sort);
|
||||
}
|
||||
$this->query->order($sort, $request->getParam('dir', $dir));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -148,8 +148,10 @@ class SortBox extends AbstractWidget
|
|||
if ($column !== null && isset($sortRules[$column]['order'])) {
|
||||
$direction = strtoupper($sortRules[$column]['order']) === Sortable::SORT_DESC ? 'desc' : 'asc';
|
||||
}
|
||||
} elseif ($column === null) {
|
||||
reset($this->sortFields);
|
||||
$column = key($this->sortFields);
|
||||
}
|
||||
|
||||
return array($column, $direction);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue