From 07a8c092910043d27969836512fe22a9eadb7c36 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Wed, 28 May 2014 16:48:27 +0000 Subject: [PATCH] Allow user edit via a dialog when in preview mode The user preview tool tip and edit dialog use the same user template. Editing on preview mode resulted in partially hidden edit form. This fix adds ability to popup a dialog modal on edit while on preview mode. --- include/ajax.users.php | 6 ++++-- include/staff/templates/user.tmpl.php | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/ajax.users.php b/include/ajax.users.php index b17d742a4..81d53af17 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -87,8 +87,10 @@ class UsersAjaxAPI extends AjaxController { elseif(!($user = User::lookup($id))) Http::response(404, 'Unknown user'); - $info = array('title' => ''); - + $info = array( + 'title' => '', + 'useredit' => sprintf('#users/%d/edit', $user->getId()), + ); ob_start(); echo sprintf('<div style="width:650px; padding: 2px 2px 0 5px;" id="u%d">', $user->getId()); diff --git a/include/staff/templates/user.tmpl.php b/include/staff/templates/user.tmpl.php index 4776bf4a3..52f5f9fc7 100644 --- a/include/staff/templates/user.tmpl.php +++ b/include/staff/templates/user.tmpl.php @@ -48,7 +48,7 @@ if ($info['error']) { <div class="tab_content" id="info-tab"> <div class="floating-options"> - <a href="#" id="edituser" class="action" title="Edit"><i class="icon-edit"></i></a> + <a href="<?php echo $info['useredit'] ?: '#'; ?>" id="edituser" class="action" title="Edit"><i class="icon-edit"></i></a> <a href="users.php?id=<?php echo $user->getId(); ?>" title="Manage User" class="action"><i class="icon-share"></i></a> </div> @@ -141,8 +141,18 @@ if ($ticket && $ticket->getOwnerId() == $user->getId()) $(function() { $('a#edituser').click( function(e) { e.preventDefault(); - $('div#user-profile').hide(); - $('div#user-form').fadeIn(); + if ($(this).attr('href').length > 1) { + var url = 'ajax.php/'+$(this).attr('href').substr(1); + $.dialog(url, [201, 204], function (xhr) { + window.location.href = window.location.href; + }, { + onshow: function() { $('#user-search').focus(); } + }); + } else { + $('div#user-profile').hide(); + $('div#user-form').fadeIn(); + } + return false; }); -- GitLab