Skip to content
Snippets Groups Projects
Commit 5ec10981 authored by Jared Hancock's avatar Jared Hancock Committed by Peter Rotich
Browse files

queue: Fix sorting on hierarchical queues

parent 4f0e8bf3
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ require_once INCLUDE_DIR . 'class.search.php';
class CustomQueue extends SavedSearch {
static $meta = array(
'select_related' => array('parent'),
'ordering' => array('title', 'path'),
'joins' => array(
'columns' => array(
'reverse' => 'QueueColumn.queue',
......@@ -143,6 +144,28 @@ class CustomQueue extends SavedSearch {
));
}
function getPath() {
return $this->path ?: $this->buildPath();
}
function buildPath() {
if (!$this->id)
return;
$path = $this->id;
if ($this->parent) {
$path = sprintf('%s/%d', $this->parent->getPath(), $path);
}
return $path;
}
function getFullName() {
$base = $this->getName();
if ($this->parent)
$base = sprintf("%s / %s", $this->parent->getFullName(), $base);
return $base;
}
function getHref() {
// TODO: Get base page from getRoot();
$root = $this->getRoot();
......@@ -225,6 +248,7 @@ class CustomQueue extends SavedSearch {
$this->title = $vars['name'];
$this->parent_id = $vars['parent_id'];
$this->filter = $vars['filter'];
$this->path = $this->buildPath();
$this->setFlag(self::FLAG_INHERIT_CRITERIA, isset($vars['inherit']));
// Update queue columns (but without save)
......@@ -246,9 +270,14 @@ class CustomQueue extends SavedSearch {
}
function save($refetch=false) {
$wasnew = !isset($this->id);
if (!($rv = parent::save($refetch)))
return $rv;
if ($wasnew) {
$this->path = $this->buildPath();
$this->save();
}
return $this->columns->saveAll();
}
......
......@@ -53,7 +53,7 @@ require_once INCLUDE_DIR . 'class.queue.php';
<tr>
<td><input type="checkbox" class="checkbox" name="ckb[]"></td>
<td><a href="queues.php?id=<?php echo $q->getId(); ?>"><?php
echo Format::htmlchars($q->getName()); ?></a></td>
echo Format::htmlchars($q->getFullName()); ?></a></td>
<td><?php echo Format::htmlchars($q->staff->getName()); ?></td>
<td><?php echo Format::htmlchars($q->getStatus()); ?></td>
<td><?php echo Format::date($q->created); ?></td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment