From d9fe25c3725f71c318f4904dcbc3e555ecba9833 Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Wed, 8 Aug 2018 15:15:25 -0500 Subject: [PATCH] issue: Multiple File Display This addresses an issue where FileUploadFields on the ticket header is not displaying all attachments in the field. --- include/class.forms.php | 2 +- include/staff/ticket-view.inc.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index 1915257b7..fc279282a 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -3426,7 +3426,7 @@ class FileUploadField extends FormField { function display($value) { $links = array(); foreach ($this->getAttachments() as $a) { - $links[] = sprintf('<a class="no-pjax" href="%s">%s</a>', + $links[] = sprintf('<a class="no-pjax" href="%s"><i class="icon-paperclip icon-flip-horizontal"></i> %s</a>', Format::htmlchars($a->file->getDownloadUrl()), Format::htmlchars($a->getFilename())); } diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index c1747a63f..a9752bd74 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -598,7 +598,7 @@ foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) { ))); $displayed = array(); foreach($answers as $a) { - $displayed[] = array($a->getLocal('label'), $a->display() ?: '<span class="faded">—' . __('Empty') . '— </span>', $a->getLocal('id')); + $displayed[] = array($a->getLocal('label'), $a->display() ?: '<span class="faded">—' . __('Empty') . '— </span>', $a->getLocal('id'), ($a->getField() instanceof FileUploadField)); } if (count($displayed) == 0) continue; @@ -610,17 +610,22 @@ foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) { <tbody> <?php foreach ($displayed as $stuff) { - list($label, $v, $id) = $stuff; + list($label, $v, $id, $isFile) = $stuff; ?> <tr> <td width="200"><?php echo Format::htmlchars($label); ?>:</td> <td> - <?php if ($role->hasPerm(Ticket::PERM_EDIT)) {?> + <?php if ($role->hasPerm(Ticket::PERM_EDIT)) { + $isEmpty = strpos($v, '—'); + if ($isFile && !$isEmpty) + echo $v.'<br>'; ?> <a class="ticket-action" id="inline-update" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Update'); ?>" data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>" href="#tickets/<?php echo $ticket->getId(); ?>/field/<?php echo $id; ?>/edit"> <?php - if (strlen($v) > 200) { + if (is_string($v) && $isFile && !$isEmpty) { + echo "<i class=\"icon-edit\"></i>"; + } elseif (strlen($v) > 200) { echo Format::truncate($v, 200); echo "<br><i class=\"icon-edit\"></i>"; } -- GitLab