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) {
|
if ($request === null) {
|
||||||
$request = Icinga::app()->getRequest();
|
$request = Icinga::app()->getRequest();
|
||||||
}
|
}
|
||||||
|
if (null === $sort = $request->getParam('sort')) {
|
||||||
if (($sort = $request->getParam('sort'))) {
|
list($sort, $dir) = $this->getSortDefaults();
|
||||||
$this->query->order($sort, $request->getParam('dir'));
|
} else {
|
||||||
} elseif (($dir = $request->getParam('dir'))) {
|
list($_, $dir) = $this->getSortDefaults($sort);
|
||||||
$this->query->order(null, $dir);
|
|
||||||
}
|
}
|
||||||
|
$this->query->order($sort, $request->getParam('dir', $dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -148,8 +148,10 @@ class SortBox extends AbstractWidget
|
||||||
if ($column !== null && isset($sortRules[$column]['order'])) {
|
if ($column !== null && isset($sortRules[$column]['order'])) {
|
||||||
$direction = strtoupper($sortRules[$column]['order']) === Sortable::SORT_DESC ? 'desc' : 'asc';
|
$direction = strtoupper($sortRules[$column]['order']) === Sortable::SORT_DESC ? 'desc' : 'asc';
|
||||||
}
|
}
|
||||||
|
} elseif ($column === null) {
|
||||||
|
reset($this->sortFields);
|
||||||
|
$column = key($this->sortFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($column, $direction);
|
return array($column, $direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue