Make ascending sort by host or service severity initiatable

fixes #9059
This commit is contained in:
Alexander A. Klimov 2015-05-13 17:48:34 +02:00
parent 149e893ecd
commit 386d4db851
1 changed files with 7 additions and 4 deletions

View File

@ -238,11 +238,11 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable
};
}
$order = $order === null ? (isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC) : $order;
$order = (strtoupper($order) === static::SORT_ASC) ? 'ASC' : 'DESC';
$globalDefaultOrder = isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC;
$globalDefaultOrder = (strtoupper($globalDefaultOrder) === static::SORT_ASC) ? 'ASC' : 'DESC';
foreach ($sortColumns['columns'] as $column) {
list($column, $direction) = $this->query->splitOrder($column);
list($column, $specificDefaultOrder) = $this->query->splitOrder($column);
if (! $this->isValidFilterTarget($column)) {
throw new QueryException(
mt('monitoring', 'The sort column "%s" is not allowed in "%s".'),
@ -250,7 +250,10 @@ abstract class DataView implements Browsable, Countable, Filterable, Sortable
get_class($this)
);
}
$this->query->order($column, $direction !== null ? $direction : $order);
$this->query->order(
$column,
$order === null && $specificDefaultOrder !== null ? $specificDefaultOrder : $globalDefaultOrder
);
}
$this->isSorted = true;
return $this;