[Rt-commit] rt branch, 4.6/configurable-linked-queue-portlets, repushed

Maureen Mirville maureen at bestpractical.com
Fri Nov 2 11:45:33 EDT 2018


The branch 4.6/configurable-linked-queue-portlets was deleted and repushed:
       was 7729d80634e841d17d6d07c05287b681e9cfd443
       now 4293902e364448d543678e7da989869457464568

1: 8e8463aac ! 1: 0c9134a7c Add a configurable queue portlet to ticket display page
    @@ -1,43 +1,12 @@
     Author: Maureen E. Mirville <maureen at bestpractical.com>
     
    -    Add a configurable queue portlet to ticket display
    +    Add a configurable queue portlet to ticket display page
         
         RTIR Incident page displays links portlets by queue. Isolating
         these portlets allows a user to view linked tickets based on the
         queue and their relation (supports: Depends on, Depended on by,
         Parents, Children, Refers to, Referred to by, All) on any ticket
         display page.
    -
    -diff --git a/lib/RT/Link.pm b/lib/RT/Link.pm
    ---- a/lib/RT/Link.pm
    -+++ b/lib/RT/Link.pm
    -@@
    -   values %DISPLAY_AS
    - }
    - 
    -+=head2 LinkTypeConversion
    -+
    -+Returns a hash of the standard link types from %DIRMAP with each Base and Target as a key
    -+value pair. This is useful in cases where the link type should be interpreted in reverse.
    -+For example, when querying for all the 'RefersTo' links on a ticket, if the query is in reference
    -+to the linked ticket, this function is not needed. But, if the query is in reference to the
    -+ticket itself, then the link type will need to be reversed and 'ReferredToBy' will need to be
    -+used instead.
    -+
    -+=cut
    -+
    -+sub LinkTypeConversion {
    -+    my %links;
    -+    foreach my $link ( keys %DIRMAP ) {
    -+        $links{ $DIRMAP{ $link }->{ 'Base' } } = $DIRMAP{ $link }->{ 'Target' };
    -+        $links{ $DIRMAP{ $link }->{ 'Target' } } = $DIRMAP{ $link }->{ 'Base' };
    -+    }
    -+    return %links;
    -+}
    -+
    - =head1 METHODS
    - 
    - =head2 Create PARAMHASH
     
     diff --git a/share/html/Elements/ShowLinksCollectionList b/share/html/Elements/ShowLinksCollectionList
     new file mode 100644
    @@ -110,7 +79,7 @@
     +% }
     +<br />
     +
    -+% if( $FullList && $Rows > 0 && $linked_tickets->CountAll >= $Rows ) {
    ++% if( $FullList && $Rows > 0 && $linked_tickets->CountAll > $Rows ) {
     +<a href="<% $FullList %>"><i><% loc("More... ([_1] total)", $linked_tickets->CountAll) %></i></a><br />
     +% }
     +
    @@ -120,22 +89,14 @@
     +
     +my $query = "Queue = '" . $QueueName . "' AND ". $ExtraQuery;
     +
    -+# As the query below used to find all the linked tickets is in reference to the
    -+# ticket itself, rather than the actual linked ticket, the link type in the query
    -+# will need to be reversed to the correct reference (ie ReferTo becomes ReferredToBy)
    -+
    -+my %converted_links = RT::Link->new( $session{'CurrentUser'} )->LinkTypeConversion;
    -+delete $converted_links{ 'MergedInto' };
    -+
    -+if ( grep /All/, @$LinkTypes ) {
    -+    @$LinkTypes = keys %converted_links;
    ++if ( grep /All/, @LinkTypes ) {
    ++    $linked_tickets->FromSQL( "$query AND ( LinkedTo = $ticket_id OR LinkedFrom = $ticket_id )" );
    ++} else {
    ++    my @link_relations = map { $_ . " = $ticket_id" } @LinkTypes;
    ++    my $link_query = join ( ' OR ', @link_relations );
    ++    $query = $query . ' AND ( ' . $link_query . ' )' if $link_query;
    ++    $linked_tickets->FromSQL( $query );
     +}
    -+@$LinkTypes = map { $converted_links{$_} } @$LinkTypes;
    -+my @link_relations = map { $_ . " = $ticket_id" } @$LinkTypes;
    -+
    -+my $link_query = join ( ' OR ', @link_relations ); #if scalar @link_relations;
    -+$query = $query . ' AND ( ' . $link_query . ' )' if $link_query;
    -+$linked_tickets->FromSQL( $query );
     +
     +$Format = RT->Config->Get( 'LinkedQueuesPortletFormat' );
     +
    @@ -152,7 +113,7 @@
     +$AllowSorting => undef
     +$PassArguments => undef
     +$ExtraQuery
    -+$LinkTypes
    ++ at LinkTypes
     +$QueueName
     +$TicketObj
     +</%ARGS>
    @@ -210,13 +171,15 @@
     +%#
     +%# END BPS TAGGED BLOCK }}}
     +<%PERL>
    -+foreach my $queue_name ( @portlet_queues ) {
    -+    my $queue = RT::Queue->new($session{CurrentUser});
    -+    $queue->Load( $queue_name );
    -+    if ( !$queue->id ) {
    -+        RT->Logger->error( "Unable to load queue: $queue_name" );
    -+    } else {
    -+        my $link_types = $portlet_config->{ $queue_name };
    ++foreach my $on_queue ( @show_portlet_on_queues ) {
    ++    if ( $on_queue eq $TicketObj->QueueObj->Name ) {
    ++        my %queues = %{ $portlet_config{ $on_queue } };
    ++        foreach my $queue_name ( keys %queues ) {
    ++            my $queue_obj = RT::Queue->new( $session{ CurrentUser } );
    ++            my ( $ret, $msg ) = $queue_obj->Load( $queue_name );
    ++            RT::Logger->error( $msg ) unless $ret;
    ++            next unless $ret;
    ++            my @link_types = @{ $queues{ $queue_name } };
     +</%PERL>
     +
     +<&| /Widgets/TitleBox,
    @@ -224,35 +187,36 @@
     +&>
     +<& /Elements/ShowLinksCollectionList, %ARGS,
     +    TicketObj        => $TicketObj,
    -+    LinkTypes        => $link_types,
    ++    LinkTypes        => @link_types,
     +    QueueName        => $queue_name,
     +    Rows             => $Rows,
     +    ExtraQuery       => "Status = '__Active__'",
     +    NoTicketsCaption => loc('No active [_1] tickets', loc( $queue_name )),
    -+    FullList         => "/Ticket/ModifyLinks.html?id=" . $TicketObj->id . "&Queue=" . $queue->id,
    ++    FullList         => "/Ticket/ModifyLinks.html?id=" . $TicketObj->id . "&Queue=" . $queue_obj->id,
     +&>
     +<& /Elements/ShowLinksCollectionList,
     +    TicketObj        => $TicketObj,
    -+    LinkTypes        => $link_types,
    ++    LinkTypes        => @link_types,
     +    QueueName        => $queue_name,
     +    Rows             => $Rows,
     +    ExtraQuery       => "Status = '__Inactive__'",
     +    NoTicketsCaption => loc('No inactive [_1] tickets', loc( $queue_name )),
     +&>
     +</&>
    -+%}
    ++%       }
    ++%   }
     +%}
     +<%INIT>
    -+my $portlet_config = RT->Config->Get( 'LinkedQueuePortlets' );
    -+return unless $portlet_config;
    -+my @portlet_queues = sort keys %$portlet_config;
    ++my %portlet_config = RT->Config->Get( 'LinkedQueuePortlets' );
    ++return unless %portlet_config;
    ++my @show_portlet_on_queues = sort keys %portlet_config;
     +</%INIT>
     +
     +
     +<%ARGS>
     +$TicketObj
     +$OrderBy => 'Due'
    -+$Rows  => 8
    ++$Rows => 8
     +</%ARGS>
     
     diff --git a/share/html/Ticket/Elements/ShowSummary b/share/html/Ticket/Elements/ShowSummary
2: 7729d8063 ! 2: 4293902e3 Add docs for the new Linked Queue Portlets configs
    @@ -11,16 +11,22 @@
      
     +=item C<%LinkedQueuePortlets>
     +
    -+If %LinkedQueuePortlets is set, new portlets will display on tickets.
    -+Each portlet lists all the linked tickets grouped by queue, and based
    -+on the indicated link type. Acceptable link types include, 'DependsOn',
    -+'DependedOnBy', 'HasMember' (children), 'MemberOf' (parents), 'RefersTo',
    -+and 'ReferredToBy'. Additionally, the type, 'All', which lists all
    -+linked tickets by queue, is accepted. See example below:
    ++If %LinkedQueuePortlets is set, new portlets will display on the ticket
    ++display page of each specified queue. Each portlet lists all the linked
    ++tickets grouped by queue name, and based on the indicated link type.
    ++Acceptable link types include, 'DependsOn', 'DependedOnBy', 'HasMember'
    ++(children), 'MemberOf' (parents), 'RefersTo', and 'ReferredToBy'.
    ++Additionally, the type, 'All', which lists all linked tickets by queue,
    ++is accepted. See example below:
     +
     +Set( %LinkedQueuePortlets, (
    -+    General => [ 'HasMember', 'MemberOf', 'RefersTo' ],
    -+    TestQueue => [ 'All' ],
    ++    General     => {
    ++        General     => [ 'All' ],
    ++        TestQueue   => [ 'HasMember', 'MemberOf', 'RefersTo' ],
    ++    },
    ++    TestQueue   => {
    ++        General => [ 'All' ],
    ++    },
     +));
     +
     +=cut
    @@ -29,8 +35,9 @@
     +
     +=item C<$LinkedQueuesPortletFormat>
     +
    -+$LinkedQueuesPortletFormat is the default format for displaying tickets
    -+in Linked queue portlets ( LinkedQueuePortlets must be enabled ).
    ++$LinkedQueuesPortletFormat is the default format for displaying the
    ++list of tickets in each linked queue portlet ( %LinkedQueuePortlets
    ++must be enabled ).
     +
     +=cut
     +



More information about the rt-commit mailing list