[Rt-commit] rt branch, 4.6/configurable-linked-queue-portlets, repushed
Maureen Mirville
maureen at bestpractical.com
Wed Oct 24 10:21:07 EDT 2018
The branch 4.6/configurable-linked-queue-portlets was deleted and repushed:
was 6355550a4fe5596be7052dd5f2250ad380261e7b
now 7729d80634e841d17d6d07c05287b681e9cfd443
1: 77d8f0fc2 ! 1: 8e8463aac Add a configurable queue portlet to ticket display
@@ -7,6 +7,37 @@
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
@@ -85,16 +116,24 @@
+
+<%INIT>
+my $linked_tickets = RT::Tickets->new( $session{'CurrentUser'} );
-+my $link_types = $LinkTypes;
+my $ticket_id = $TicketObj->id;
+
-+my $query = "Queue = '" . $QueueName . "' AND ". $Status;
-+my @link_relations;
-+my $link_query;
-+
-+ at link_relations = map { $RT::Link::TYPEMAP{$_}{'Type'} . " = $ticket_id" } @$LinkTypes;
-+$link_query = join ( ' OR ', @link_relations ) if scalar @link_relations;
-+
++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;
++}
++@$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 );
+
@@ -112,7 +151,7 @@
+$ShowHeader => 0
+$AllowSorting => undef
+$PassArguments => undef
-+$Status
++$ExtraQuery
+$LinkTypes
+$QueueName
+$TicketObj
@@ -188,7 +227,7 @@
+ LinkTypes => $link_types,
+ QueueName => $queue_name,
+ Rows => $Rows,
-+ Status => "Status = '__Active__'",
++ ExtraQuery => "Status = '__Active__'",
+ NoTicketsCaption => loc('No active [_1] tickets', loc( $queue_name )),
+ FullList => "/Ticket/ModifyLinks.html?id=" . $TicketObj->id . "&Queue=" . $queue->id,
+&>
@@ -197,16 +236,16 @@
+ LinkTypes => $link_types,
+ QueueName => $queue_name,
+ Rows => $Rows,
-+ Status => "Status = '__Inactive__'",
++ ExtraQuery => "Status = '__Inactive__'",
+ NoTicketsCaption => loc('No inactive [_1] tickets', loc( $queue_name )),
+&>
+</&>
+%}
+%}
+<%INIT>
-+my $portlet_config = RT->Config->Get( 'LinkedQueuePortlets' ) || {};
++my $portlet_config = RT->Config->Get( 'LinkedQueuePortlets' );
+return unless $portlet_config;
-+my @portlet_queues = keys %$portlet_config;
++my @portlet_queues = sort keys %$portlet_config;
+</%INIT>
+
+
@@ -224,12 +263,9 @@
% my (@extra);
% push @extra, titleright_raw => '<a href="'. RT->Config->Get('WebPath'). '/Ticket/Graphs/index.html?id='.$Ticket->id.'">'.loc('Graph').'</a>' unless RT->Config->Get('DisableGraphViz');
+
-+% my $portlet_queues = RT->Config->Get( 'LinkedQueuePortlets' ) || {};
-+% if ( scalar keys %$portlet_queues ) {
+<& /Ticket/Elements/ShowLinkedQueues,
+ TicketObj => $Ticket,
+&>
-+% }
+
<& /Ticket/Elements/ShowAssets, Ticket => $Ticket &>
% $m->callback( %ARGS, CallbackName => 'LinksExtra', extra => \@extra );
2: 6355550a4 < -: ------- Add docs for the new %LinkedQueuePortlets config
-: ------- > 2: 7729d8063 Add docs for the new Linked Queue Portlets configs
More information about the rt-commit
mailing list