Skip to content
Snippets Groups Projects
Commit ac93d168 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge pull request #817 from protich/feature/user-preview


user preview tool tip

Reviewed-By: default avatarJared Hancock <jared@osticket.com>
parents dbb011a1 d6555add
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,29 @@ class UsersAjaxAPI extends AjaxController {
}
function preview($id) {
global $thisstaff;
if(!$thisstaff)
Http::response(403, 'Login Required');
elseif(!($user = User::lookup($id)))
Http::response(404, 'Unknown user');
$info = array('title' => '');
ob_start();
echo sprintf('<div style="width:650px; padding: 2px 2px 0 5px;"
id="u%d">', $user->getId());
include(STAFFINC_DIR . 'templates/user.tmpl.php');
echo '</div>';
$resp = ob_get_contents();
ob_end_clean();
return $resp;
}
function editUser($id) {
global $thisstaff;
......@@ -210,17 +233,19 @@ class UsersAjaxAPI extends AjaxController {
return self::_lookupform(null, $info);
}
function lookup() {
return self::addUser();
}
function addUser() {
$info = array();
$info['title'] = 'Add New User';
$info['lookup'] = 'remote';
if (!AuthenticationBackend::getSearchDirectories())
$info['lookup'] = false;
$info['lookup'] = 'local';
if ($_POST) {
$info['title'] = 'Add New User';
$form = UserForm::getUserForm()->getForm($_POST);
if (($user = User::fromForm($form)))
Http::response(201, $user->to_json());
......@@ -274,10 +299,6 @@ class UsersAjaxAPI extends AjaxController {
include STAFFINC_DIR . 'templates/user-import.tmpl.php';
}
function getLookupForm() {
return self::_lookupform();
}
function selectUser($id) {
if ($id)
......@@ -296,7 +317,7 @@ class UsersAjaxAPI extends AjaxController {
static function _lookupform($form=null, $info=array()) {
if (!$info or !$info['title'])
$info += array('title' => 'Select or Create a Client');
$info += array('title' => 'Lookup or create a user');
ob_start();
include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php');
......
......@@ -26,7 +26,8 @@ if(is_object($thisstaff) && $thisstaff->isStaff()) { ?>
if ($.support.pjax) {
$(document).on('click', 'a', function(event) {
if (!$(this).hasClass('no-pjax')
&& !$(this).closest('.no-pjax').length)
&& !$(this).closest('.no-pjax').length
&& $(this).attr('href')[0] != '#')
$.pjax.click(event, {container: $('#pjax-container'), timeout: 2000});
})
}
......
......@@ -95,7 +95,7 @@ echo sprintf(
'
<tr>
<th>From:</th>
<td>%s <span class="faded">%s</span></td>
<td><a href="users.php?id=%d" class="no-pjax">%s</a> <span class="faded">%s</span></td>
</tr>
<tr>
<th width="100">Department:</th>
......@@ -105,6 +105,7 @@ echo sprintf(
<th>Help Topic:</th>
<td>%s</td>
</tr>',
$ticket->getUserId(),
Format::htmlchars($ticket->getName()),
$ticket->getEmail(),
Format::htmlchars($ticket->getDeptName()),
......@@ -118,14 +119,16 @@ echo '</div>'; // ticket preview content.
<table border="0" cellspacing="" cellpadding="1">
<colgroup><col style="min-width: 250px;"></col></colgroup>
<?php
if (($users=$ticket->getCollaborators())) {?>
if (($collabs=$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());
foreach($collabs as $collab) {
echo sprintf('<tr><td %s><i class="icon-%s"></i>
<a href="users.php?id=%d" class="no-pjax">%s</a> <em>&lt;%s&gt;</em></td></tr>',
($collab->isActive()? '' : 'class="faded"'),
($collab->isActive()? 'comments' : 'comment-alt'),
$collab->getUserId(),
$collab->getName(),
$collab->getEmail());
}
} else {
echo "Ticket doesn't have collaborators.";
......
<?php
if (!$info['title'])
if (!isset($info['title']))
$info['title'] = Format::htmlchars($user->getName());
?>
if ($info['title']) { ?>
<h3><?php echo $info['title']; ?></h3>
<b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b>
<hr/>
<hr>
<?php
} else {
echo '<div class="clear"></div>';
}
if ($info['error']) {
echo sprintf('<p id="msg_error">%s</p>', $info['error']);
} elseif ($info['msg']) {
......@@ -49,7 +53,7 @@ if ($info['error']) {
<a href="users.php?id=<?php echo $user->getId(); ?>" title="Manage User"
class="action"><i class="icon-share"></i></a>
</div>
<table class="custom-info">
<table class="custom-info" width="100%">
<?php foreach ($user->getDynamicData() as $entry) {
?>
<tr><th colspan="2"><strong><?php
......
......@@ -91,7 +91,7 @@ if ($num) { ?>
?>
<tr id="<?php echo $row['id']; ?>">
<td>&nbsp;
<a href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a>
<a class="userPreview" href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a>
&nbsp;
<?php
if ($row['tickets'])
......
......@@ -84,9 +84,8 @@ $org = $user->getOrganization();
<span id="user-<?php echo $user->getId(); ?>-org">
<?php
if ($org)
echo sprintf('<a href="#users/%d/org"
class="user-action">%s</a>',
$user->getId(), $org->getName());
echo sprintf('<a href="orgs.php?id=%d">%s</a>',
$org->getId(), $org->getName());
else
echo sprintf('<a href="#users/%d/org"
class="user-action">Add Organization</a>',
......
......@@ -139,7 +139,7 @@ else
?>
<tr id="<?php echo $row['id']; ?>">
<td>&nbsp;
<a href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a>
<a class="userPreview" href="users.php?id=<?php echo $row['id']; ?>"><?php echo $name; ?></a>
&nbsp;
<?php
if ($row['tickets'])
......
......@@ -73,9 +73,10 @@ $dispatcher = patterns('',
url_get('^/remote$', 'search', array('remote')),
url_get('^/(?P<id>\d+)$', 'getUser'),
url_post('^/(?P<id>\d+)$', 'updateUser'),
url_get('^/(?P<id>\d+)/preview$', 'preview'),
url_get('^/(?P<id>\d+)/edit$', 'editUser'),
url('^/lookup$', 'getUser'),
url_get('^/lookup/form$', 'getLookupForm'),
url_get('^/lookup/form$', 'lookup'),
url_post('^/lookup/form$', 'addUser'),
url_get('^/add$', 'addUser'),
url('^/import$', 'importUsers'),
......
......@@ -8,10 +8,25 @@ body {
}
a {
color:#E65524;
color:#184E81;
text-decoration:none;
}
a:hover {
text-decoration: underline;
}
#nav a:hover,
#sub_nav a:hover,
a:hover i[class^="icon-"],
.tabs a {
text-decoration: none;
}
div#header a {
color:#E65524;
}
.form_table a:hover {
text-decoration: underline;
}
......@@ -1444,11 +1459,14 @@ time {
}
/* Dynamic forms in dialogs */
.dialog th, .tip_box th {
text-align: left;
}
.dialog th {
background-color: #eee;
border: 1px dotted #bbb;
padding: 0.3em;
text-align: left;
padding-left: 0.3em;
}
......
......@@ -673,7 +673,7 @@ $('.quicknote .action.edit-note').live('click.note', function() {
var note = $(this).closest('.quicknote'),
body = note.find('.body'),
T = $('<textarea>').text(body.html());
if (note.closest('.dialog').length)
if (note.closest('.dialog, .tip_box').length)
T.addClass('no-bar small');
body.replaceWith(T);
$.redact(T);
......@@ -745,7 +745,7 @@ $('#new-note').live('click', function() {
'html'
);
});
if (note.closest('.dialog').length)
if (note.closest('.dialog, .tip_box').length)
T.addClass('no-bar small');
note.replaceWith(T);
$('<p>').addClass('submit').css('text-align', 'center')
......
......@@ -214,6 +214,32 @@ jQuery(function() {
clearTimeout($(this).data('timer'));
});
//User preview
$('.userPreview').live('mouseover', function(e) {
e.preventDefault();
var elem = $(this);
var vars = elem.attr('href').split('=');
var url = 'ajax.php/users/'+vars[1]+'/preview';
var id='u'+vars[1];
var xoffset = 80;
elem.data('timer', 0);
if(!elem.data('id')) {
elem.data('id', id);
if(e.type=='mouseover') {
/* wait about 1 sec - before showing the tip - mouseout kills the timeout*/
elem.data('timer',setTimeout(function() { showtip(url,elem,xoffset);},750))
}else{
clearTimeout(elem.data('timer'));
showtip(url, elem, xoffset);
}
}
}).live('mouseout', function(e) {
$(this).data('id', 0);
clearTimeout($(this).data('timer'));
});
$('body')
.delegate('.tip_close', 'click', 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