Unverified Commit 0fda6e21 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:sparkles: feat(management) Add a method to set sort column

issue #6046
Showing with 17 additions and 7 deletions
+17 -7
...@@ -262,13 +262,7 @@ class managementListing ...@@ -262,13 +262,7 @@ class managementListing
if (isset($_GET['act'])) { if (isset($_GET['act'])) {
$key = validate($_GET['act']); $key = validate($_GET['act']);
if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) { if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
// Switch to new column or invert search order? $this->setSortColumn($match[1]);
$column = $match[1];
if ($this->sortColumn != $column) {
$this->sortColumn = $column;
} else {
$this->sortDirection[$column] = !$this->sortDirection[$column];
}
// Allow header to update itself according to the new sort settings // Allow header to update itself according to the new sort settings
$this->renderHeader(); $this->renderHeader();
...@@ -594,6 +588,22 @@ class managementListing ...@@ -594,6 +588,22 @@ class managementListing
return NULL; return NULL;
} }
/*!
* \brief Set sort column
*
* \param int $column Index of column to sort by
* \param bool $direction Whether to sort up or down
*/
public function setSortColumn (int $column, bool $direction = NULL)
{
if ($direction === NULL) {
// Switch to new column or invert search order?
$direction = (($this->sortColumn == $column) && !$this->sortDirection[$column]);
}
$this->sortColumn = $column;
$this->sortDirection[$column] = $direction;
}
function fillSearchedAttributes (string $type, array &$attrs) function fillSearchedAttributes (string $type, array &$attrs)
{ {
global $ui; global $ui;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment