Skip to content
Snippets Groups Projects
Commit 762d1869 authored by Peter Rotich's avatar Peter Rotich
Browse files

queues: Make columns sortable by default

parent 7d4fa442
No related branches found
No related tags found
No related merge requests found
...@@ -526,40 +526,52 @@ class CustomQueue extends VerySimpleModel { ...@@ -526,40 +526,52 @@ class CustomQueue extends VerySimpleModel {
// Last resort — use standard columns // Last resort — use standard columns
foreach (array( foreach (array(
QueueColumn::placeholder(array( QueueColumn::placeholder(array(
"id" => 1,
"heading" => "Number", "heading" => "Number",
"primary" => 'number', "primary" => 'number',
"width" => 85, "width" => 85,
"bits" => QueueColumn::FLAG_SORTABLE,
"filter" => "link:ticketP", "filter" => "link:ticketP",
"annotations" => '[{"c":"TicketSourceDecoration","p":"b"}]', "annotations" => '[{"c":"TicketSourceDecoration","p":"b"}]',
"conditions" => '[{"crit":["isanswered","set",null],"prop":{"font-weight":"bold"}}]', "conditions" => '[{"crit":["isanswered","set",null],"prop":{"font-weight":"bold"}}]',
)), )),
QueueColumn::placeholder(array( QueueColumn::placeholder(array(
"id" => 2,
"heading" => "Created", "heading" => "Created",
"primary" => 'created', "primary" => 'created',
"width" => 100, "width" => 100,
"bits" => QueueColumn::FLAG_SORTABLE,
)), )),
QueueColumn::placeholder(array( QueueColumn::placeholder(array(
"id" => 3,
"heading" => "Subject", "heading" => "Subject",
"primary" => 'cdata__subject', "primary" => 'cdata__subject',
"width" => 250, "width" => 250,
"bits" => QueueColumn::FLAG_SORTABLE,
"filter" => "link:ticket", "filter" => "link:ticket",
"annotations" => '[{"c":"TicketThreadCount","p":">"},{"c":"ThreadAttachmentCount","p":"a"},{"c":"OverdueFlagDecoration","p":"<"}]', "annotations" => '[{"c":"TicketThreadCount","p":">"},{"c":"ThreadAttachmentCount","p":"a"},{"c":"OverdueFlagDecoration","p":"<"}]',
"truncate" => 'ellipsis', "truncate" => 'ellipsis',
)), )),
QueueColumn::placeholder(array( QueueColumn::placeholder(array(
"id" => 4,
"heading" => "From", "heading" => "From",
"primary" => 'user__name', "primary" => 'user__name',
"width" => 150, "width" => 150,
"bits" => QueueColumn::FLAG_SORTABLE,
)), )),
QueueColumn::placeholder(array( QueueColumn::placeholder(array(
"id" => 5,
"heading" => "Priority", "heading" => "Priority",
"primary" => 'cdata__priority', "primary" => 'cdata__priority',
"width" => 120, "width" => 120,
"bits" => QueueColumn::FLAG_SORTABLE,
)), )),
QueueColumn::placeholder(array( QueueColumn::placeholder(array(
"id" => 6,
"heading" => "Assignee", "heading" => "Assignee",
"primary" => 'assignee', "primary" => 'assignee',
"width" => 100, "width" => 100,
"bits" => QueueColumn::FLAG_SORTABLE,
)), )),
) as $col) ) as $col)
$this->addColumn($col); $this->addColumn($col);
...@@ -1814,7 +1826,8 @@ extends VerySimpleModel { ...@@ -1814,7 +1826,8 @@ extends VerySimpleModel {
} }
function applySort($query, $reverse=false) { function applySort($query, $reverse=false) {
$fields = CustomQueue::getSearchableFields($this->getQueue()->getRoot()); $root = ($q = $this->getQueue()) ? $q->getRoot() : 'Ticket';
$fields = CustomQueue::getSearchableFields($root);
if ($primary = $fields[$this->primary]) { if ($primary = $fields[$this->primary]) {
list(,$field) = $primary; list(,$field) = $primary;
$query = $field->applyOrderBy($query, $reverse, $query = $field->applyOrderBy($query, $reverse,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment