From ec9c0ee438700253e77b3fe0e3e2e3cc9fa24cfa Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 6 Jun 2016 19:44:23 +0000 Subject: [PATCH] Add ticket status preview This is important to show custom statuses with properties. --- include/class.list.php | 25 +++++++++++++++++++ .../templates/list-item-preview.tmpl.php | 1 + include/staff/ticket-view.inc.php | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/class.list.php b/include/class.list.php index d578b73c2..69106502b 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -68,6 +68,9 @@ interface CustomListItem { function getAbbrev(); function getSortOrder(); + function getList(); + function getListId(); + function getConfiguration(); function hasProperties(); @@ -673,6 +676,10 @@ class DynamicListItem extends VerySimpleModel implements CustomListItem { return $this->get('id'); } + function getList() { + return $this->list; + } + function getListId() { return $this->get('list_id'); } @@ -1272,6 +1279,11 @@ implements CustomListItem, TemplateVariable { return $this->_list; } + function getListId() { + if (($list = $this->getList())) + return $list->getId(); + } + function getConfigurationForm($source=null) { if (!$this->_form) { $config = $this->getConfiguration(); @@ -1301,6 +1313,10 @@ implements CustomListItem, TemplateVariable { return $this->_form; } + function getFields() { + return $this->getConfigurationForm()->getFields(); + } + function getConfiguration() { if (!$this->_settings) { @@ -1385,6 +1401,15 @@ implements CustomListItem, TemplateVariable { return count($errors) === 0; } + function display() { + return sprintf('<a class="preview" href="#" + data-preview="#list/%d/items/%d/preview">%s</a>', + $this->getListId(), + $this->getId(), + $this->getLocalName() + ); + } + function update($vars, &$errors) { $fields = array('name', 'sort'); foreach($fields as $k) { diff --git a/include/staff/templates/list-item-preview.tmpl.php b/include/staff/templates/list-item-preview.tmpl.php index db9b87f8c..3ffcd1998 100644 --- a/include/staff/templates/list-item-preview.tmpl.php +++ b/include/staff/templates/list-item-preview.tmpl.php @@ -13,6 +13,7 @@ if ($item->hasProperties()) { ?> <table class="custom-info" width="100%"> <?php foreach ($item->getFields() as $f) { + if (!$f->isVisible()) continue; ?> <tr><td style="width:30%;"><?php echo Format::htmlchars($f->get('label')); ?>:</td> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 36c1d34ef..202a2b274 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -239,7 +239,7 @@ if($ticket->isOverdue()) <table border="0" cellspacing="" cellpadding="4" width="100%"> <tr> <th width="100"><?php echo __('Status');?>:</th> - <td><?php echo ($S = $ticket->getStatus()) ? $S->getLocalName() : ''; ?></td> + <td><?php echo ($S = $ticket->getStatus()) ? $S->display() : ''; ?></td> </tr> <tr> <th><?php echo __('Priority');?>:</th> -- GitLab