diff --git a/include/class.i18n.php b/include/class.i18n.php index 9d8575c1379a14fe823dfe5780d2ff443d1b7f04..5d411a086d26642b3e075cbd037fd7d02360f7a4 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -506,6 +506,7 @@ class Internationalization { static function sortKeyedList($list, $case=false) { global $cfg; + // XXX: Use current language if ($cfg && function_exists('collator_create')) { $coll = Collator::create($cfg->getPrimaryLanguage()); if (!$case) diff --git a/include/class.queue.php b/include/class.queue.php index 2f1aa3f20dfbe46539a11d9f41f017f4dfdee88f..3ad133f9116c75ab4d81e0c8c6bc12d84c07ed14 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -346,6 +346,30 @@ extends QueueColumnAnnotation { } } +class ThreadCollaboratorCount +extends QueueColumnAnnotation { + static $icon = 'group'; + static $qname = '_collabs'; + static $desc = /* @trans */ 'Collaborator Count'; + + function annotate($query) { + return $query->annotate(array( + static::$qname => TicketThread::objects() + ->filter(array('ticket__ticket_id' => new SqlField('ticket_id', 1))) + ->aggregate(array('count' => SqlAggregate::COUNT('collaborators__id'))) + )); + } + + function getDecoration($row, $text) { + $count = $row[static::$qname]; + if ($count) { + return sprintf( + '<span class="pull-right faded-more" data-toggle="tooltip" title="%d"><i class="icon-group"></i></span>', + $count); + } + } +} + class OverdueFlagDecoration extends QueueColumnAnnotation { static $icon = 'exclamation'; @@ -443,7 +467,7 @@ class QueueColumnCondition { function getField($name=null) { // FIXME - #$root = $this->getColumn()->getQueue()->getRoot(); + #$root = $this->getColumn()->getRoot(); $root = 'Ticket'; $searchable = SavedSearch::getSearchableFields($root); @@ -645,6 +669,7 @@ extends VerySimpleModel { static $meta = array( 'table' => COLUMN_TABLE, 'pk' => array('id'), + 'ordering' => array('name'), ); var $_annotations; @@ -694,12 +719,11 @@ extends VerySimpleModel { $text = $this->renderBasicValue($row); // Truncate - if ($text = $this->applyTruncate($text)) { - } + $text = $this->applyTruncate($text); // Filter if ($filter = $this->getFilter()) { - $text = $filter->filter($text, $row); + $text = $filter->filter($text, $row) ?: $text; } // annotations and conditions @@ -1001,8 +1025,8 @@ extends QueueColumnFilter { static $desc = /* @trans */ "Ticket Link"; function filter($text, $row) { - $link = $this->getLink($row); - return sprintf('<a href="%s">%s</a>', $link, $text); + if ($link = $this->getLink($row)) + return sprintf('<a href="%s">%s</a>', $link, $text); } function mangleQuery($query, $column) { @@ -1040,7 +1064,7 @@ extends TicketLinkFilter { static $desc = /* @trans */ "Organization Link"; function getLink($row) { - return Organization::getLink($row['org_id']); + return Organization::getLink($row['user__org_id']); } } QueueColumnFilter::register('TicketLinkFilter'); diff --git a/include/i18n/en_US/queue_column.yaml b/include/i18n/en_US/queue_column.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1777af85728fdab1f140c49ee00ea1999906837a --- /dev/null +++ b/include/i18n/en_US/queue_column.yaml @@ -0,0 +1,124 @@ +# Columns are not necessary and a default list is used if no columns are +# specified. +# +# Fields: +# id: +# flags: (unused) +# name: Display name of the column +# primary: Data source for the field +# secondary: Backup data source / default text +# filter: What the field should link to +# 'link:ticket': Ticket +# 'link:user': User +# 'link:org': Organization +# 'link:ticketP': Ticket with hover preview +# truncate: +# 'wrap': Fold words on multiple lines +# annotations: +# c: Annotation class name +# p: Placement +# 'a': After column text +# 'b': Before column text +# '<': Float to start (left) +# '>': Float to end (right) +# conditions: +# crit: Criteria for the condiditon, in the form of [field, method, value] +# prop: Array of CSS properties to apply to the field +# 'font-weight': +# 'font-style': +# ... +# extra: (future use and for plugins) +--- +- id: 1 + name: "Ticket #" + primary: "number" + filter: "link:ticketP" + truncate: "wrap" + annotations: '[{"c":"TicketSourceDecoration","p":"b"}]' + conditions: '[{"crit":["isanswered","nset",null],"prop":{"font-weight":"bold"}}]' + +- id: 2 + name: "Date Created" + primary: "created" + secondary: null + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 3 + name: "Subject" + primary: "cdata__subject" + filter: "link:ticket" + truncate: "ellipsis" + annotations: '[{"c":"TicketThreadCount","p":">"},{"c":"ThreadAttachmentCount","p":"a"},{"c":"OverdueFlagDecoration","p":"<"},{"c":"LockDecoration","p":"<"}]' + conditions: '[{"crit":["isanswered","nset",null],"prop":{"font-weight":"bold"}}]' + +- id: 4 + name: "User Name" + primary: "user__name" + truncate: "wrap" + annotations: '[{"c":"ThreadCollaboratorCount","p":">"}]' + conditions: "[]" + +- id: 5 + name: "Priority" + primary: "cdata__priority" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 6 + name: "Status Name" + primary: "status__name" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 7 + name: "Close Date" + primary: "closed" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 8 + name: "Assignee" + primary: "assignee" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 9 + name: "Due Date" + primary: "est_duedate" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 10 + name: "Last Updated" + primary: "lastupdate" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 11 + name: "Department" + primary: "dept" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 12 + name: "Last Message" + primary: "thread__lastmessage" + truncate: "wrap" + annotations: "[]" + conditions: "[]" + +- id: 12 + name: "Last Response" + primary: "thread__lastresponse" + truncate: "wrap" + annotations: "[]" + conditions: "[]" diff --git a/include/staff/templates/queue-column.tmpl.php b/include/staff/templates/queue-column.tmpl.php index 65867c95ff82a4e0eb2d1668bf30aa30bf4ae62c..3b93d0e83c512c366a56f50f54bd13766b450722 100644 --- a/include/staff/templates/queue-column.tmpl.php +++ b/include/staff/templates/queue-column.tmpl.php @@ -56,9 +56,13 @@ $data_form = $data_form ?: $column->getDataConfigForm($_POST); <i class="icon-plus-sign"></i> <select class="add-annotation"> <option>— <?php echo __("Add a annotation"); ?> —</option> -<?php foreach (QueueColumnAnnotation::getAnnotations('Ticket') as $class) { +<?php +$annotations = array(); +foreach (QueueColumnAnnotation::getAnnotations('Ticket') as $class) + $annotations[$class] = $class::getDescription(); +foreach (Internationalization::sortKeyedList($annotations) as $class=>$desc) { echo sprintf('<option data-icon="%s" value="%s">%s</option>', - $class::$icon, $class, $class::getDescription()); + $class::$icon, $class, $desc); } ?> </select> </div>