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

Add ability to preview the list of collaborators

parent 98a54326
Branches
Tags
No related merge requests found
......@@ -568,7 +568,23 @@ class TicketsAjaxAPI extends AjaxController {
return self::_addcollaborator($ticket);
}
function previewCollaborators($tid) {
global $thisstaff;
if (!($ticket=Ticket::lookup($tid))
|| !$ticket->checkStaffAccess($thisstaff))
Http::response(404, 'No such ticket');
if (!$ticket->getCollaborators())
Http::response(404, 'No such ticket');
ob_start();
include STAFFINC_DIR . 'templates/collaborators-preview.tmpl.php';
$resp = ob_get_contents();
ob_end_clean();
return $resp;
}
function _addcollaborator($ticket, $user=null, $form=null, $info=array()) {
......@@ -590,7 +606,9 @@ class TicketsAjaxAPI extends AjaxController {
$errors = $info = array();
if ($ticket->updateCollaborators($_POST, $errors))
Http::response(201, sprintf('Recipients (%d)', $ticket->getNumActiveCollaborators()));
Http::response(201, sprintf('Recipients (%d of %d)',
$ticket->getNumActiveCollaborators(),
$ticket->getNumCollaborators()));
if($errors && $errors['err'])
$info +=array('error' => $errors['err']);
......
<div>
<table border="0" cellspacing="" cellpadding="1">
<colgroup><col style="min-width: 250px;"></col></colgroup>
<?php
if (($users=$ticket->getCollaborators())) {?>
<?php
foreach($users as $user) {
echo sprintf('<tr><td %s><i class="icon-%s"></i> %s <em>&lt;%s&gt;</em></td></tr>',
($user->isActive()? 'class="faded"' : ''),
($user->isActive()? 'comments' : 'comment-alt'),
$user->getName(),
$user->getEmail());
}
} else {
echo "Bro, not sure how you got here!";
}?>
</table>
<?php
$options = array();
//TODO: Add options to manage collaborators
if ($options) {
echo '<ul class="tip_menu">';
foreach($options as $option)
echo sprintf('<li><a href="%s">%s</a></li>', $option['url'], $option['action']);
echo '</ul>';
}
?>
</div>
......@@ -453,10 +453,12 @@ $tcount+= $ticket->getNumNotes();
<?php
$recipients = 'Add Recipients';
if ($ticket->getNumCollaborators())
$recipients = sprintf('Recipients (%d)', $ticket->getNumActiveCollaborators());
$recipients = sprintf('Recipients (%d of %d)',
$ticket->getNumActiveCollaborators(),
$ticket->getNumCollaborators());
echo sprintf('<span><a class="collaborators"
href="#tickets/%d/collaborators/manage"><span id="recipients">%s</span></a></span>',
echo sprintf('<span><a class="collaborators" id="manageCollab"
href="#tickets/%d/collaborators"><span id="recipients">%s</span></a></span>',
$ticket->getId(),
$recipients);
?>
......
......@@ -79,7 +79,8 @@ $dispatcher = patterns('',
url_post('^(?P<tid>\d+)/lock$', 'acquireLock'),
url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/renew', 'renewLock'),
url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/release', 'releaseLock'),
url_get('^(?P<tid>\d+)/collaborators/manage$', 'showCollaborators'),
url_get('^(?P<tid>\d+)/collaborators/preview$', 'previewCollaborators'),
url_get('^(?P<tid>\d+)/collaborators$', 'showCollaborators'),
url_post('^(?P<tid>\d+)/collaborators$', 'updateCollaborators'),
url_get('^(?P<tid>\d+)/add-collaborator/(?P<uid>\d+)$', 'addCollaborator'),
url_get('^(?P<tid>\d+)/add-collaborator/auth:(?P<bk>\w+):(?P<id>.+)$', 'addRemoteCollaborator'),
......
......@@ -160,6 +160,28 @@ jQuery(function() {
clearTimeout($(this).data('timer'));
});
$('a#manageCollab').live('mouseover', function(e) {
e.preventDefault();
var elem = $(this);
var url = 'ajax.php/'+elem.attr('href').substr(1)+'/preview';
var xoffset = 100;
elem.data('timer', 0);
if (e.type=='mouseover') {
elem.data('timer',setTimeout(function() { showtip(url, elem, xoffset);},750))
} else {
showtip(url,elem,xoffset);
}
}).live('mouseout', function(e) {
clearTimeout($(this).data('timer'));
}).live('click', function(e) {
clearTimeout($(this).data('timer'));
$('.tip_box').remove();
});
//Ticket preview
$('.ticketPreview').live('mouseover', function(e) {
e.preventDefault();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment