From 85f424220b44548abda5872383f9309ed3110586 Mon Sep 17 00:00:00 2001 From: aydreeihn <adriane@enhancesoft.com> Date: Thu, 3 Jan 2019 16:47:10 -0600 Subject: [PATCH] Issue: Tasks Within Tickets This commit addresses issues we had with viewing Task(s) within a Ticket: 1. When viewing the table of all Tasks on a Ticket, the Options dropdown should only allow the Agent to Reopen or Close the Tasks based on the status of the Tasks. Ex: If there is only 1 Open Task, you should only see the 'Close' Option If there are 2 Closed Tasks, you should only see the 'Reopen' Option If there are multiple Tasks in which some are Open and some are Closed, you should see both the 'Reopen' and 'Close' options 2. When viewing an individual Task within a Ticket, the status options were the opposite of what they should have been. Now, if the Task is Open, the Agent will see the option to 'Close' the Task. If the Task is Closded, the Agent will see the option to 'Reopen' the Task. --- include/staff/templates/task-view.tmpl.php | 2 +- .../staff/templates/tasks-actions.tmpl.php | 66 +++++-------------- include/staff/ticket-tasks.inc.php | 7 +- 3 files changed, 23 insertions(+), 52 deletions(-) diff --git a/include/staff/templates/task-view.tmpl.php b/include/staff/templates/task-view.tmpl.php index 5b03857f0..3decb024c 100644 --- a/include/staff/templates/task-view.tmpl.php +++ b/include/staff/templates/task-view.tmpl.php @@ -146,7 +146,7 @@ if ($task->isOverdue()) <ul> <?php - if ($task->isOpen()) { ?> + if (!$task->isOpen()) { ?> <li> <a class="no-pjax task-action" href="#tasks/<?php echo $task->getId(); ?>/reopen"><i diff --git a/include/staff/templates/tasks-actions.tmpl.php b/include/staff/templates/tasks-actions.tmpl.php index dc59eae4f..e323e3060 100644 --- a/include/staff/templates/tasks-actions.tmpl.php +++ b/include/staff/templates/tasks-actions.tmpl.php @@ -7,57 +7,23 @@ if ($agent->hasPerm(Task::PERM_CLOSE, false)) { if (isset($options['status'])) { $status = $options['status']; - ?> - <span - class="action-button" - data-dropdown="#action-dropdown-tasks-status"> - <i class="icon-caret-down pull-right"></i> - <a class="tasks-status-action" - href="#statuses" - data-placement="bottom" - data-toggle="tooltip" - title="<?php echo __('Change Status'); ?>"><i - class="icon-flag"></i></a> - </span> - <div id="action-dropdown-tasks-status" - class="action-dropdown anchor-right"> - <ul> - <?php - if (!$status || !strcasecmp($status, 'closed')) { ?> - <li> - <a class="no-pjax tasks-action" - href="#tasks/mass/reopen"><i - class="icon-fixed-width icon-undo"></i> <?php - echo __('Reopen');?> </a> - </li> - <?php - } - if (!$status || !strcasecmp($status, 'open')) { - ?> - <li> - <a class="no-pjax tasks-action" - href="#tasks/mass/close"><i - class="icon-fixed-width icon-ok-circle"></i> <?php - echo __('Close');?> </a> - </li> - <?php - } ?> - </ul> - </div> -<?php - } else { - $actions += array( - 'reopen' => array( - 'icon' => 'icon-undo', - 'action' => __('Reopen') - )); + if (strpos($status, 'closed') !== false) { + $actions += array( + 'reopen' => array( + 'icon' => 'icon-undo', + 'action' => __('Reopen') + )); + } - $actions += array( - 'close' => array( - 'icon' => 'icon-ok-circle', - 'action' => __('Close') - )); + + if (strpos($status, 'open') !== false) { + $actions += array( + 'close' => array( + 'icon' => 'icon-ok-circle', + 'action' => __('Close') + )); + } } } @@ -95,7 +61,7 @@ if ($agent->hasPerm(Task::PERM_DELETE, false)) { 'action' => __('Delete') )); } -if ($actions && !isset($options['status'])) { +if ($actions && isset($options['status'])) { $more = $options['morelabel'] ?: __('More'); ?> <span diff --git a/include/staff/ticket-tasks.inc.php b/include/staff/ticket-tasks.inc.php index 01bc6e284..373844b46 100644 --- a/include/staff/ticket-tasks.inc.php +++ b/include/staff/ticket-tasks.inc.php @@ -40,12 +40,17 @@ $showing = $pageNav->showing().' '._N('task', 'tasks', $count); print __('Add New Task'); ?></a> <?php } + foreach ($tasks as $task) + $taskStatus .= $task->isOpen() ? 'open' : 'closed'; + if ($count) Task::getAgentActions($thisstaff, array( 'container' => '#tasks_content', 'callback_url' => sprintf('ajax.php/tickets/%d/tasks', $ticket->getId()), - 'morelabel' => __('Options'))); + 'morelabel' => __('Options'), + 'status' => $taskStatus ? $taskStatus : '') + ); ?> </div> <div class="clear"></div> -- GitLab