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

Add collaborator callback to get fetch user on lookup select.

parent 1ffe6a39
No related branches found
No related tags found
No related merge requests found
......@@ -450,16 +450,19 @@ class TicketsAjaxAPI extends AjaxController {
}
//Collaborators utils
function addCollaborator($tid) {
function addCollaborator($tid, $uid=0) {
global $thisstaff;
if (!($ticket=Ticket::lookup($tid))
|| !$ticket->checkStaffAccess($thisstaff))
Http::response(404, 'No such ticket');
$user = $uid? User::lookup($uid) : null;
//If not a post then assume new collaborator form
if(!$_POST)
return self::_addcollaborator($ticket);
return self::_addcollaborator($ticket, $user);
$user = $form = null;
if (isset($_POST['id']) && $_POST['id']) { //Existing user/
......@@ -540,9 +543,9 @@ class TicketsAjaxAPI extends AjaxController {
$info += array(
'title' => sprintf('Ticket #%s: Add a collaborator', $ticket->getNumber()),
'action' => sprintf('#tickets/%d/add-collaborator', $ticket->getId())
'action' => sprintf('#tickets/%d/add-collaborator', $ticket->getId()),
'onselect' => sprintf('ajax.php/tickets/%d/add-collaborator/', $ticket->getId()),
);
return self::_userlookup($user, $form, $info);
}
......
......@@ -80,7 +80,7 @@ $(function() {
},
onselect: function (obj) {
$('#the-lookup-form').load(
"ajax.php/users/select/"+obj.id
'<?php echo $info['onselect']? $info['onselect']: "ajax.php/users/select/"; ?>'+obj.id
);
},
property: "/bin/true"
......
......@@ -62,7 +62,7 @@ $dispatcher = patterns('',
url_get('^/(?P<id>\d+)$', 'getUser'),
url_post('^/(?P<id>\d+)$', 'updateUser'),
url_get('^/(?P<id>\d+)/edit$', 'editUser'),
url_get('^/lookup$', 'getUser'),
url('^/lookup$', 'getUser'),
url_get('^/lookup/form$', 'getLookupForm'),
url_post('^/lookup/form$', 'addUser'),
url_get('^/select$', 'selectUser'),
......@@ -80,6 +80,7 @@ $dispatcher = patterns('',
url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/release', 'releaseLock'),
url_get('^(?P<tid>\d+)/collaborators/manage$', 'showCollaborators'),
url_post('^(?P<tid>\d+)/collaborators$', 'updateCollaborators'),
url_get('^(?P<tid>\d+)/add-collaborator/(?P<uid>\d+)$', 'addCollaborator'),
url('^(?P<tid>\d+)/add-collaborator$', 'addCollaborator'),
url_get('^lookup', 'lookup'),
url_get('^search', 'search')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment