Difference between revisions of "AutoRequestorTicketSearch"

From Request Tracker Wiki
Jump to navigation Jump to search
m (5 revisions imported)
 
(3 intermediate revisions by one other user not shown)
Line 6: Line 6:
 
  <nowiki><script type="text/javascript">
 
  <nowiki><script type="text/javascript">
 
     jQuery(document).ready(function(){
 
     jQuery(document).ready(function(){
      jQuery('form[name=TicketCreate]').after('<div id="auto-requestor-ticket-search" style="clear:both;"></div>');
+
      jQuery('form[name=TicketCreate]').after('<div id="auto-requestor-ticket-search" style="clear:both;"></div>');
      jQuery('input#Requestors').autocomplete({
+
      jQuery('input#Requestors').autocomplete({
          select:function( event, ui ) {
+
        select:function( event, ui ) {
              jQuery('#auto-requestor-ticket-search').empty().load("/Helpers/AutoRequestorTicketSearch.html?" + jQuery.param({ UserEmail: ui.item.value }));
+
                jQuery('#auto-requestor-ticket-search').empty().load("/Helpers/AutoRequestorTicketSearch.html?" + jQuery.param({ UserEmail: ui.item.value }));
          }
+
        }
      });
+
      });
    });
+
    });
 
   </script></nowiki>
 
   </script></nowiki>
  
 
In '''Helpers/AutoRequestorTicketSearch.html''' :
 
In '''Helpers/AutoRequestorTicketSearch.html''' :
  <nowiki><&|/Widgets/TitleBox, title => "Last 25 tickets for " . $User->RealName &>
+
  <code><&|/Widgets/TitleBox, title => "Last 25 tickets for " . $User->RealName &>
 
  % if ($Collection->CountAll() > 0) {
 
  % if ($Collection->CountAll() > 0) {
 
  <& /Elements/CollectionList,
 
  <& /Elements/CollectionList,
Line 38: Line 38:
 
  % }
 
  % }
 
  % } else {
 
  % } else {
  <p><&|/l&>No tickets found.</&></p>
+
  <nowiki><p><&|/l&>No tickets found.</&></p></nowiki>
 
  % }
 
  % }
 
  </&>
 
  </&>
<%INIT>
+
<%INIT>
 
  my $User = RT::User->new($RT::SystemUser);
 
  my $User = RT::User->new($RT::SystemUser);
 
  $User->LoadByEmail($UserEmail);
 
  $User->LoadByEmail($UserEmail);
Line 61: Line 61:
 
  <%ARGS>
 
  <%ARGS>
 
  $UserEmail
 
  $UserEmail
  </%ARGS></nowiki>
+
  </%ARGS></code>

Latest revision as of 16:03, 6 April 2016

When creating tickets in RT on behalf of a user, it's often useful to look over the list of tickets in which the user is a requestor in order to avoid duplicates. Opening a tab, moving to the search page and building a new search can however be uselessly time-consuming.

With this simple customisation, upon selecting a Requestor through the autocomplete dropdown on the ticket creation page, a panel will appear on the bottom of the page listing this user's most recent tickets.

In Callbacks/AutoRequestorTicketSearch/Ticket/Create.html/AfterRequestors :


<script type="text/javascript">
    jQuery(document).ready(function(){
       jQuery('form[name=TicketCreate]').after('<div id="auto-requestor-ticket-search" style="clear:both;"></div>');
       jQuery('input#Requestors').autocomplete({
         select:function( event, ui ) {
                 jQuery('#auto-requestor-ticket-search').empty().load("/Helpers/AutoRequestorTicketSearch.html?" + jQuery.param({ UserEmail: ui.item.value }));
         }
       });
     });
  </script>


In Helpers/AutoRequestorTicketSearch.html :

<&|/Widgets/TitleBox, title => "Last 25 tickets for " . $User->RealName &>
% if ($Collection->CountAll() > 0) {
<& /Elements/CollectionList,
    AllowSorting => 0,
    Class => 'RT::Tickets',
    Collection => $Collection,
    ShowNavigation => 0,
    ShowEmpty => 1,
    %query_args,
    &>
% if ($Collection->CountAll() > 25) {





<& /Elements/Submit,
    Label => loc('Voir tous'),
    &>

% }

% } else {


<p><&|/l&>No tickets found.</&></p>


% }
</&>
<%INIT>
my $User = RT::User->new($RT::SystemUser);
$User->LoadByEmail($UserEmail);
my $Query = "Requestor.EmailAddress LIKE '${UserEmail}'";
my %query_args = (
    Format  => qq{
        '__id__/TITLE:#',
        '__Subject__/TITLE:Subject',
        'Status',
        'OwnerName',
        '__LastUpdatedRelative__'},
    OrderBy => 'LastUpdated',
    Order   => 'DESC',
    Rows    => 25,
);
my $Collection = RT::Tickets->new( $session{'CurrentUser'} );
$Collection->FromSQL($Query);
</%INIT>
<%ARGS>
$UserEmail
</%ARGS>