[Rt-commit] rt branch, 4.0/queue-summary-link-callbacks, created. rt-4.0.10-59-g5c0efc3
Thomas Sibley
trs at bestpractical.com
Tue Feb 26 22:50:04 EST 2013
The branch, 4.0/queue-summary-link-callbacks has been created
at 5c0efc3773eaba35d9853fa45691d8c7b506d8b2 (commit)
- Log -----------------------------------------------------------------
commit 292dd3bf6fb7371593a8a978868308a1f1cc75d1
Author: Thomas Sibley <trs at bestpractical.com>
Date: Tue Feb 26 18:57:04 2013 -0800
Use a tiny comment to fix vim's syntax highlighting
diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index 01514f1..6e5e0cb 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -67,7 +67,7 @@ for my $queue (@queues) {
$i++;
my $name = $queue->{Name};
- $name =~ s/(['\\])/\\$1/g;
+ $name =~ s/(['\\])/\\$1/g; #'
my $queue_cond = "Queue = '$name' AND ";
my $all_q = $queue_cond . '(' . join( " OR ", map "Status = '$_'", @cur_statuses ) . ')';
</%PERL>
diff --git a/share/html/Elements/QueueSummaryByStatus b/share/html/Elements/QueueSummaryByStatus
index b843bba..082a5dc 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummaryByStatus
@@ -59,7 +59,7 @@ my $i = 0;
for my $queue (@queues) {
$i++;
my $name = $queue->{Name};
- $name =~ s/(['\\])/\\$1/g;
+ $name =~ s/(['\\])/\\$1/g; #'
my $queue_cond = "Queue = '$name' AND ";
my $lifecycle = $lifecycle{ lc $queue->{'Lifecycle'} };
my $all_q = $queue_cond . '(' . join( " OR ", map "Status = '$_'", grep $lifecycle->IsValid($_), @statuses ) . ')';
commit 5c0efc3773eaba35d9853fa45691d8c7b506d8b2
Author: Thomas Sibley <trs at bestpractical.com>
Date: Tue Feb 26 19:29:10 2013 -0800
Callbacks for changing the link destinations in the queue summaries
While likely to be used only rarely, these callbacks are very useful for
extensions which provide a richer "queue dashboard" than the vanilla
search results normally linked to by the queue summary portlets.
Without the callbacks, such extensions are forced to overlay the entire
files just to change some URLs.
The duplication between the two types of queue summaries is unfortunate,
but large scale refactoring is out of scope for the simple goal of this
commit. A future refactoring isn't hampered any by the additional
duplication.
diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index 6e5e0cb..44d6b5a 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -66,20 +66,16 @@ for my $queue (@queues) {
next if lc($queue->{Lifecycle} || '') ne lc $lifecycle->Name;
$i++;
- my $name = $queue->{Name};
- $name =~ s/(['\\])/\\$1/g; #'
- my $queue_cond = "Queue = '$name' AND ";
- my $all_q = $queue_cond . '(' . join( " OR ", map "Status = '$_'", @cur_statuses ) . ')';
</%PERL>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td>
- <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
+ <a href="<% $link_all->($queue, \@cur_statuses) %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
</td>
% for my $status (@cur_statuses) {
<td align="right">
- <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = '$status'" |u,n %>"><% $data->{$queue->{id}}->{$status } || '-' %></a>
+ <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->{id}}->{$status } || '-' %></a>
</td>
% }
</tr>
@@ -87,6 +83,31 @@ for my $queue (@queues) {
</table>
% }
<%INIT>
+my $build_search_link = sub {
+ my ($queue_name, $extra_query) = @_;
+ $queue_name =~ s/(['\\])/\\$1/g; #'
+
+ return RT->Config->Get('WebPath')
+ . "/Search/Results.html?Query="
+ . $m->interp->apply_escapes("Queue = '$queue_name' AND $extra_query", 'u');
+};
+
+my $link_all = sub {
+ my ($queue, $all_statuses) = @_;
+ return $build_search_link->($queue->{Name}, "(".join(" OR ", map "Status = '$_'", @$all_statuses).")");
+};
+
+my $link_status = sub {
+ my ($queue, $status) = @_;
+ return $build_search_link->($queue->{Name}, "Status = '$status'");
+};
+
+$m->callback(
+ CallbackName => 'LinkBuilders',
+ build_search_link => \$build_search_link,
+ link_all => \$link_all,
+ link_status => \$link_status,
+);
my $Queues = RT::Queues->new( $session{'CurrentUser'} );
$Queues->UnLimit();
diff --git a/share/html/Elements/QueueSummaryByStatus b/share/html/Elements/QueueSummaryByStatus
index 082a5dc..2a8dc53 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummaryByStatus
@@ -58,16 +58,13 @@
my $i = 0;
for my $queue (@queues) {
$i++;
- my $name = $queue->{Name};
- $name =~ s/(['\\])/\\$1/g; #'
- my $queue_cond = "Queue = '$name' AND ";
my $lifecycle = $lifecycle{ lc $queue->{'Lifecycle'} };
- my $all_q = $queue_cond . '(' . join( " OR ", map "Status = '$_'", grep $lifecycle->IsValid($_), @statuses ) . ')';
+ my @queue_statuses = grep { $lifecycle->IsValid($_) } @statuses;
</%PERL>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td>
- <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
+ <a href="<% $link_all->($queue, \@queue_statuses) %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
</td>
<%perl>
@@ -75,7 +72,7 @@ for my $queue (@queues) {
if ( $lifecycle->IsValid( $status ) ) {
</%perl>
<td align="right">
- <a href="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = '$status'" |u,n %>"><% $data->{$queue->{id}}->{$status } || '-' %></a>
+ <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->{id}}->{$status } || '-' %></a>
</td>
% } else {
<td align="right">-</td>
@@ -85,6 +82,31 @@ for my $queue (@queues) {
% }
</table>
<%INIT>
+my $build_search_link = sub {
+ my ($queue_name, $extra_query) = @_;
+ $queue_name =~ s/(['\\])/\\$1/g; #'
+
+ return RT->Config->Get('WebPath')
+ . "/Search/Results.html?Query="
+ . $m->interp->apply_escapes("Queue = '$queue_name' AND $extra_query", 'u');
+};
+
+my $link_all = sub {
+ my ($queue, $all_statuses) = @_;
+ return $build_search_link->($queue->{Name}, "(".join(" OR ", map "Status = '$_'", @$all_statuses).")");
+};
+
+my $link_status = sub {
+ my ($queue, $status) = @_;
+ return $build_search_link->($queue->{Name}, "Status = '$status'");
+};
+
+$m->callback(
+ CallbackName => 'LinkBuilders',
+ build_search_link => \$build_search_link,
+ link_all => \$link_all,
+ link_status => \$link_status,
+);
my $Queues = RT::Queues->new( $session{'CurrentUser'} );
$Queues->UnLimit();
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list