[Rt-commit] rt branch, 4.4/queue-summary-refactoring, created. rt-4.2.0-34-gca61ecf
Alex Vandiver
alexmv at bestpractical.com
Fri Oct 11 18:27:56 EDT 2013
The branch, 4.4/queue-summary-refactoring has been created
at ca61ecfb2c4d54ed101fb235e45256769efeb6bf (commit)
- Log -----------------------------------------------------------------
commit 96a6c0f21f0c121af62ce2cb0b959171f759a27e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Feb 1 01:49:35 2011 +0300
rename Prefs/Quicksearch.html as it going to be more generic
diff --git a/share/html/Elements/Quicksearch b/share/html/Elements/Quicksearch
index 77814ed..234516d 100644
--- a/share/html/Elements/Quicksearch
+++ b/share/html/Elements/Quicksearch
@@ -50,7 +50,7 @@
title => loc("Quick search"),
bodyclass => "",
titleright => loc("Edit"),
- titleright_href => RT->Config->Get('WebPath').'/Prefs/Quicksearch.html',
+ titleright_href => RT->Config->Get('WebPath').'/Prefs/QueueSummary.html',
&>
<& $comp,
queue_filter => sub { $_->CurrentUserHasRight('ShowTicket') && !exists $unwanted->{$_->Name} },
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 555edd2..b933568 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -558,7 +558,7 @@ my $build_main_nav = sub {
title => loc('Dashboards in menu'),
path => '/Prefs/DashboardsInMenu.html',
);
- $settings->child( quicksearch => title => loc('Quick search'), path => '/Prefs/Quicksearch.html' );
+ $settings->child( quicksearch => title => loc('Quick search'), path => '/Prefs/QueueSummary.html' );
my $search_menu = $settings->child( 'saved-searches' => title => loc('Saved Searches') );
my $searches = [ $m->comp( "/Search/Elements/SearchesForObject",
diff --git a/share/html/Prefs/Quicksearch.html b/share/html/Prefs/QueueSummary.html
similarity index 98%
rename from share/html/Prefs/Quicksearch.html
rename to share/html/Prefs/QueueSummary.html
index 81757b9..7415680 100644
--- a/share/html/Prefs/Quicksearch.html
+++ b/share/html/Prefs/QueueSummary.html
@@ -50,7 +50,7 @@
&>
<& /Elements/ListActions, actions => \@actions &>
<h1><&|/l&>Select queues to be displayed on the "RT at a glance" page</&></h1>
-<form method="post" action="Quicksearch.html" name="Preferences">
+<form method="post" action="QueueSummary.html" name="Preferences">
<ul>
% for my $queue (@queues) {
<li><input type="checkbox" class="checkbox" id="Want-<%$queue->Name%>" name="Want-<%$queue->Name%>" value="1"
commit 236d18d7bed02f82af2efdb84f1295901b183a50
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Feb 2 00:15:38 2011 +0300
RT::SQL->Quote helper
We could probably use DBI->quote instead, but implementation
depends on DBD (database specific) and in theory a DB may has
incompatible escaping rules.
diff --git a/lib/RT/SQL.pm b/lib/RT/SQL.pm
index 1a469d6..b551527 100644
--- a/lib/RT/SQL.pm
+++ b/lib/RT/SQL.pm
@@ -212,6 +212,19 @@ sub _BitmaskToString {
return join ' or ', @res;
}
+=head2 Quote
+
+Quotes a string for TicketSQL queries. Changes argument in void context.
+
+=cut
+
+sub Quote {
+ my $v = defined(wantarray)? \"$_[1]" : \$_[1];
+ $$v =~ s{(['\\])}{\\$1}g;
+ $$v = "'$$v'";
+ return $$v;
+}
+
RT::Base->_ImportOverlays();
1;
commit 140bfb3727e19569613d24f97da2a5701a7078d2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Feb 2 00:16:45 2011 +0300
merge common code in QueueSummary* into /Elements/QueueSummary
diff --git a/share/html/Elements/QueueSummaryByStatus b/share/html/Elements/QueueSummary
similarity index 57%
copy from share/html/Elements/QueueSummaryByStatus
copy to share/html/Elements/QueueSummary
index b37c523..6e3afc3 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummary
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
%# <sales at bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
@@ -45,90 +45,34 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<table border="0" cellspacing="0" cellpadding="1" width="100%" class="queue-summary">
-
-<tr>
- <th class="collection-as-table"><&|/l&>Queue</&></th>
-% for my $status ( @statuses ) {
- <th class="collection-as-table"><% loc($status) %></th>
-% }
-</tr>
-
-<%PERL>
-my $i = 0;
-for my $queue (@queues) {
- $i++;
- my $lifecycle = $lifecycle{ lc $queue->{'Lifecycle'} };
- my @queue_statuses = grep { $lifecycle->IsValid($_) } @statuses;
-</%PERL>
-<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
-
-<td>
- <a href="<% $link_all->($queue, \@queue_statuses) %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
-</td>
-
-<%perl>
- for my $status (@statuses) {
- if ( $lifecycle->IsValid( $status ) ) {
-</%perl>
-<td align="right">
- <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->{id}}->{lc $status} || '-' %></a>
-</td>
-% } else {
-<td align="right">-</td>
-% }
-% }
-</tr>
-% }
-</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'");
-};
+$queues ||= RT::Queues->new( $session{'CurrentUser'} );
+$queues->UnLimit unless $queues->_isLimited;
-$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();
-$m->callback( CallbackName => 'SQLFilter', Queues => $Queues );
+$m->callback( CallbackName => 'SQLFilter', Queues => $queues );
-my @queues = grep $queue_filter->($_), @{ $Queues->ItemsArrayRef };
+my @queues = $queue_filter
+ ? grep $queue_filter->($_), @{ $queues->ItemsArrayRef }
+ : @{ $queues->ItemsArrayRef }
+;
$m->callback( CallbackName => 'Filter', Queues => \@queues );
- at queues = map {
- { id => $_->Id,
- Name => $_->Name,
- Description => $_->Description || '',
- Lifecycle => $_->Lifecycle,
- }
-} grep $_, @queues;
-
-my %lifecycle;
+$preference = $preference
+ ? $session{'CurrentUser'}->UserObj->Preferences($preference, {})
+ : {}
+;
-for my $queue (@queues) {
- my $cycle = RT::Lifecycle->Load( Name => $queue->{'Lifecycle'} );
- $lifecycle{ lc $cycle->Name } = $cycle;
+my $comp = '/Elements/QueueSummaryByStatus';
+if ( $preference->{'SplitByLifecycle'} ) {
+ $comp = '/Elements/QueueSummaryByLifecycle';
}
+if ( $preference->{'Unwanted'} && keys %{ $preference->{'Unwanted'} } ) {
+ @queues = grep !$preference->{'Unwanted'}{ $_->Name }, @queues;
+}
+
+return $m->comp( $comp ) unless @queues;
+
+my %lifecycle = map { lc $_->Name => $_ } map $_->LifecycleObj, @queues;
unless (@statuses) {
my %seen;
@@ -139,27 +83,72 @@ unless (@statuses) {
}
}
-my $data = {};
-my $statuses = {};
-
use RT::Report::Tickets;
my $report = RT::Report::Tickets->new( RT->SystemUser );
my $query =
- "(".
- join(" OR ", map {s{(['\\])}{\\$1}g; "Status = '$_'"} @statuses) #'
- .") AND (".
- join(' OR ', map "Queue = ".$_->{id}, @queues)
- .")";
-$query = 'id < 0' unless @queues;
+ '('. join(" OR ", map "Status = ". RT::SQL->Quote($_), @statuses) .')'
+ .' AND ('. join(' OR ', map "Queue = ". $_->id, @queues) .')';
$report->SetupGroupings( Query => $query, GroupBy => [qw(Status Queue)] );
+my (%data, %data_has_status);
while ( my $entry = $report->Next ) {
- $data->{ $entry->__Value("Queue") }->{ $entry->__Value("Status") }
- = $entry->__Value('id');
- $statuses->{ $entry->__Value("Status") } = 1;
+ my ($queue, $status, $count) = map $entry->__Value($_), qw(Queue Status id);
+
+ $data{ $queue }{ $status } = $count;
+ $data{ $queue }{''} += $count;
+ $data_has_status{ $status } = 1;
}
+
+unless ( $preference->{'ShowEmptyColumns'} ) {
+ @statuses = grep $data_has_status{$_}, @statuses;
+}
+unless ( $preference->{'ShowEmptyRows'} ) {
+ @queues = grep $data{ $_->id }{''}, @queues;
+}
+
+my $build_search_link = sub {
+ my ($queue_name, $extra_query) = @_;
+
+ return RT->Config->Get('WebPath')
+ . "/Search/Results.html?Query="
+ . $m->interp->apply_escapes("Queue = ". RT::SQL->Quote($queue_name) ." AND $extra_query", 'u');
+};
+
+my $link_all = sub {
+ my ($queue, $all_statuses) = @_;
+ return $build_search_link->(
+ $queue->Name,
+ "(".join(" OR ", map "Status = ". RT::SQL->Quote($_), @$all_statuses).")"
+ );
+};
+
+my $link_status = sub {
+ my ($queue, $status) = @_;
+ return $build_search_link->($queue->Name, "Status = ". RT::SQL->Quote($status));
+};
+
+$m->callback(
+ CallbackName => 'LinkBuilders',
+ build_search_link => \$build_search_link,
+ link_all => \$link_all,
+ link_status => \$link_status,
+);
+
+return $m->comp(
+ $comp,
+ queues => \@queues,
+ statuses => \@statuses,
+ data => \%data,
+ linker => {
+ all => $link_all,
+ status => $link_status,
+ search => $build_search_link,
+ },
+);
</%INIT>
<%ARGS>
+$queues => undef
$queue_filter => undef
+$preference => undef,
@statuses => ()
</%ARGS>
diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index a0f9023..81b0f58 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -45,122 +45,71 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
+<table border="0" cellspacing="0" cellpadding="1" width="100%" class="queue-summary">
+
<%perl>
- foreach my $lifecycle ( map $lifecycle{$_}, sort keys %lifecycle ) {
- my @cur_statuses = grep $lifecycle->IsValid($_), @statuses;
- next unless @cur_statuses;
-</%perl>
+my $i = 0;
-<table border="0" cellspacing="0" cellpadding="1" width="100%" class="queue-summary">
+foreach my $group ( map $groups{$_}, sort keys %groups ) {
+ my @statuses = @{ $group->{'statuses'} };
+</%perl>
<tr>
<th class="collection-as-table"><&|/l&>Queue</&></th>
-% for my $status ( @cur_statuses ) {
+% for my $status ( @statuses ) {
<th class="collection-as-table"><% loc($status) %></th>
% }
+% for ( 1 .. ($max - @statuses) ) {
+ <th class="collection-as-table"> </th>
+% }
</tr>
<%PERL>
-my $i = 0;
-for my $queue (@queues) {
- next if lc($queue->{Lifecycle} || '') ne lc $lifecycle->Name;
-
+for my $queue (@{ $group->{'queues'} }) {
$i++;
</%PERL>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td>
- <a href="<% $link_all->($queue, \@cur_statuses) %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
+ <a href="<% $linker->{'all'}->($queue, $group->{'statuses'}) %>" title="<% $queue->Description %>"><% $queue->Name %></a>
</td>
-% for my $status (@cur_statuses) {
+% for my $status (@statuses) {
<td align="right">
- <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->{id}}->{lc $status} || '-' %></a>
+ <a href="<% $linker->{'status'}->($queue, $status) %>"><% $data->{$queue->id}->{lc $status} || '-' %></a>
</td>
% }
</tr>
% }
-</table>
% }
+</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');
-};
+return unless @queues && @statuses;
-my $link_all = sub {
- my ($queue, $all_statuses) = @_;
- return $build_search_link->($queue->{Name}, "(".join(" OR ", map "Status = '$_'", @$all_statuses).")");
-};
+my $max = 0;
-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();
-$m->callback( CallbackName => 'SQLFilter', Queues => $Queues );
-
-my @queues = grep $queue_filter->($_), @{ $Queues->ItemsArrayRef };
-$m->callback( CallbackName => 'Filter', Queues => \@queues );
-
- at queues = map {
- { id => $_->Id,
- Name => $_->Name,
- Description => $_->Description || '',
- Lifecycle => $_->Lifecycle,
+my %groups;
+foreach my $queue ( @queues ) {
+ my $cycle = $queue->LifecycleObj;
+ my $cycle_name = $cycle->Name;
+ if ( $groups{ $cycle_name } ) {
+ push @{ $groups{ $cycle_name }{'queues'} }, $queue;
+ next;
}
-} grep $_, @queues;
-
-my %lifecycle;
-for my $queue (@queues) {
- my $cycle = RT::Lifecycle->Load( Name => $queue->{'Lifecycle'} );
- $lifecycle{ lc $cycle->Name } = $cycle;
+ $groups{ $cycle_name } = {
+ cycle => $cycle,
+ statuses => [ grep $cycle->IsValid( $_), @statuses ],
+ queues => [$queue],
+ };
+ $max = @{ $groups{ $cycle_name }{'statuses'} }
+ if $max < @{ $groups{ $cycle_name }{'statuses'} };
}
-unless (@statuses) {
- my %seen;
- foreach my $set ( 'initial', 'active' ) {
- foreach my $lifecycle ( map $lifecycle{$_}, sort keys %lifecycle ) {
- push @statuses, grep !$seen{ lc $_ }++, $lifecycle->Valid($set);
- }
- }
-}
-
-my $data = {};
-my $statuses = {};
-
-use RT::Report::Tickets;
-my $report = RT::Report::Tickets->new( RT->SystemUser );
-my $query =
- "(".
- join(" OR ", map {s{(['\\])}{\\$1}g; "Status = '$_'"} @statuses) #'
- .") AND (".
- join(' OR ', map "Queue = ".$_->{id}, @queues)
- .")";
-$query = 'id < 0' unless @queues;
-$report->SetupGroupings( Query => $query, GroupBy => [qw(Status Queue)] );
-
-while ( my $entry = $report->Next ) {
- $data->{ $entry->__Value("Queue") }->{ $entry->__Value("Status") }
- = $entry->__Value('id');
- $statuses->{ $entry->__Value("Status") } = 1;
-}
</%INIT>
<%ARGS>
-$queue_filter => undef
- at statuses => ()
+ at queues => ()
+ at statuses => ()
+$data => {}
+$linker => {}
</%ARGS>
diff --git a/share/html/Elements/QueueSummaryByStatus b/share/html/Elements/QueueSummaryByStatus
index b37c523..bed3367 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummaryByStatus
@@ -58,13 +58,14 @@
my $i = 0;
for my $queue (@queues) {
$i++;
- my $lifecycle = $lifecycle{ lc $queue->{'Lifecycle'} };
+ my $lifecycle = $queue->LifecycleObj;
my @queue_statuses = grep { $lifecycle->IsValid($_) } @statuses;
+
</%PERL>
<tr class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td>
- <a href="<% $link_all->($queue, \@queue_statuses) %>" title="<% $queue->{Description} %>"><% $queue->{Name} %></a>
+ <a href="<% $linker->{'all'}->($queue, \@queue_statuses) %>" title="<% $queue->Description %>"><% $queue->Name %></a>
</td>
<%perl>
@@ -72,7 +73,7 @@ for my $queue (@queues) {
if ( $lifecycle->IsValid( $status ) ) {
</%perl>
<td align="right">
- <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->{id}}->{lc $status} || '-' %></a>
+ <a href="<% $linker->{'status'}->($queue, $status) %>"><% $data->{$queue->id}->{lc $status} || '-' %></a>
</td>
% } else {
<td align="right">-</td>
@@ -82,84 +83,11 @@ 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();
-$m->callback( CallbackName => 'SQLFilter', Queues => $Queues );
-
-my @queues = grep $queue_filter->($_), @{ $Queues->ItemsArrayRef };
-$m->callback( CallbackName => 'Filter', Queues => \@queues );
-
- at queues = map {
- { id => $_->Id,
- Name => $_->Name,
- Description => $_->Description || '',
- Lifecycle => $_->Lifecycle,
- }
-} grep $_, @queues;
-
-my %lifecycle;
-
-for my $queue (@queues) {
- my $cycle = RT::Lifecycle->Load( Name => $queue->{'Lifecycle'} );
- $lifecycle{ lc $cycle->Name } = $cycle;
-}
-
-unless (@statuses) {
- my %seen;
- foreach my $set ( 'initial', 'active' ) {
- foreach my $lifecycle ( map $lifecycle{$_}, sort keys %lifecycle ) {
- push @statuses, grep !$seen{ lc $_ }++, $lifecycle->Valid($set);
- }
- }
-}
-
-my $data = {};
-my $statuses = {};
-
-use RT::Report::Tickets;
-my $report = RT::Report::Tickets->new( RT->SystemUser );
-my $query =
- "(".
- join(" OR ", map {s{(['\\])}{\\$1}g; "Status = '$_'"} @statuses) #'
- .") AND (".
- join(' OR ', map "Queue = ".$_->{id}, @queues)
- .")";
-$query = 'id < 0' unless @queues;
-$report->SetupGroupings( Query => $query, GroupBy => [qw(Status Queue)] );
-
-while ( my $entry = $report->Next ) {
- $data->{ $entry->__Value("Queue") }->{ $entry->__Value("Status") }
- = $entry->__Value('id');
- $statuses->{ $entry->__Value("Status") } = 1;
-}
+return unless @queues && @statuses;
</%INIT>
<%ARGS>
-$queue_filter => undef
- at statuses => ()
+ at queues => ()
+ at statuses => ()
+$data => {}
+$linker => {}
</%ARGS>
commit 9bc7ca2dfd193bececa9c350b81fb3482324ce5a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Feb 2 00:17:34 2011 +0300
use new QueueSummary
diff --git a/share/html/Elements/MyAdminQueues b/share/html/Elements/MyAdminQueues
index 880ef3c..7ff78a3 100644
--- a/share/html/Elements/MyAdminQueues
+++ b/share/html/Elements/MyAdminQueues
@@ -45,8 +45,14 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<&|/Widgets/TitleBox, title => loc("Queues I administer"), bodyclass => "" &>
-<& /Elements/QueueSummaryByStatus,
- queue_filter => sub { $_->CurrentUserHasRight('AdminQueue') },
+<&|/Widgets/TitleBox,
+ title => loc("Queues I administer"),
+ bodyclass => "",
+ titleright => loc("Edit"),
+ titleright_href => RT->Config->Get('WebPath').'/Prefs/QueueSummary.html?Pref=MyAdminQueues',
+&>
+<& /Elements/QueueSummary,
+ preference => 'MyAdminQueues',
+ queue_filter => sub { $_->CurrentUserHasRight('AdminQueue') },
&>
</&>
diff --git a/share/html/Elements/MySupportQueues b/share/html/Elements/MySupportQueues
index 6537ea1..a35453e 100644
--- a/share/html/Elements/MySupportQueues
+++ b/share/html/Elements/MySupportQueues
@@ -45,8 +45,14 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<&|/Widgets/TitleBox, title => loc("Queues I'm an AdminCc for"), bodyclass => "" &>
-<& /Elements/QueueSummaryByStatus,
- queue_filter => sub { $_->IsAdminCc($session{'CurrentUser'}->Id) },
+<&|/Widgets/TitleBox,
+ title => loc("Queues I'm an AdminCc for"),
+ bodyclass => "",
+ titleright => loc("Edit"),
+ titleright_href => RT->Config->Get('WebPath').'/Prefs/QueueSummary.html?Pref=MySupportQueues',
+&>
+<& /Elements/QueueSummary,
+ preference => 'MySupportQueues',
+ queue_filter => sub { $_->IsAdminCc($session{'CurrentUser'}->Id) },
&>
</&>
diff --git a/share/html/Elements/Quicksearch b/share/html/Elements/Quicksearch
index 234516d..f015245 100644
--- a/share/html/Elements/Quicksearch
+++ b/share/html/Elements/Quicksearch
@@ -50,17 +50,11 @@
title => loc("Quick search"),
bodyclass => "",
titleright => loc("Edit"),
- titleright_href => RT->Config->Get('WebPath').'/Prefs/QueueSummary.html',
+ titleright_href => RT->Config->Get('WebPath').'/Prefs/QueueSummary.html?EditUnwanted=1',
&>
-<& $comp,
- queue_filter => sub { $_->CurrentUserHasRight('ShowTicket') && !exists $unwanted->{$_->Name} },
+<& /Elements/QueueSummary,
+ preference => 'QuickSearch',
+ queue_filter => sub { $_->CurrentUserHasRight('ShowTicket') },
&>
</&>
</div>
-<%INIT>
-my $unwanted = $session{'CurrentUser'}->UserObj->Preferences('QuickSearch', {});
-my $comp = $SplitByLifecycle? '/Elements/QueueSummaryByLifecycle' : '/Elements/QueueSummaryByStatus';
-</%INIT>
-<%ARGS>
-$SplitByLifecycle => 1
-</%ARGS>
commit 3a9ce28d5ef1f65531f04506a44c4a4a15584062
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Feb 2 00:18:11 2011 +0300
new preferences UI for all portlets based on QueueSummary
diff --git a/share/html/Prefs/QueueSummary.html b/share/html/Prefs/QueueSummary.html
index 7415680..ba3fb2f 100644
--- a/share/html/Prefs/QueueSummary.html
+++ b/share/html/Prefs/QueueSummary.html
@@ -46,22 +46,48 @@
%#
%# END BPS TAGGED BLOCK }}}
<& /Elements/Header, Title => $title &>
-<& /Elements/Tabs
-&>
+<& /Elements/Tabs &>
+
<& /Elements/ListActions, actions => \@actions &>
-<h1><&|/l&>Select queues to be displayed on the "RT at a glance" page</&></h1>
+
<form method="post" action="QueueSummary.html" name="Preferences">
+<input type="hidden" class="hidden" name="Pref" value="<% $Pref %>" \>
+<input type="hidden" class="hidden" name="EditUnwanted" value="<% $EditUnwanted %>" \>
+
+<h1><&|/l&>Select table preferences</&></h1>
+
+<label><input type="checkbox" class="checkbox" name="ShowEmptyRows" value="1" \
+% if ( $preference->{'ShowEmptyRows'} ) {
+checked="checked" \
+% }
+/><&|/l&>Show rows with all zeros</&></label><br />
+
+<label><input type="checkbox" class="checkbox" name="ShowEmptyColumns" value="1" \
+% if ( $preference->{'ShowEmptyColumns'} ) {
+checked="checked" \
+% }
+/><&|/l&>Show columns with all zeros</&></label><br />
+
+<label><input type="checkbox" class="checkbox" name="SplitByLifecycle" value="1" \
+% if ( $preference->{'SplitByLifecycle'} ) {
+checked="checked" \
+% }
+/><&|/l&>Split into groups with different status sets (lifecycles)</&></label><br />
+
+% if ( $EditUnwanted ) {
+<h1><&|/l&>Select queues to be displayed</&></h1>
<ul>
% for my $queue (@queues) {
-<li><input type="checkbox" class="checkbox" id="Want-<%$queue->Name%>" name="Want-<%$queue->Name%>" value="1"
-% unless ($unwanted->{$queue->Name}) {
-checked="checked"
+<li><input type="checkbox" class="checkbox" id="Want-<%$queue->Name%>" name="Want" value="<%$queue->Name%>"
+% unless ($preference->{'Unwanted'}{ $queue->Name }) {
+checked="checked" \
% }
/>
<label for="Want-<%$queue->Name%>"><%$queue->Name%><% $queue->Description ? ': '.$queue->Description : '' %></label>
</li>
% }
</ul>
+% }
<& /Elements/Submit,
Caption => loc("Save Changes"),
Label => loc('Save'),
@@ -69,41 +95,56 @@ checked="checked"
Reset => 1,
CheckAll => 1,
ClearAll => 1,
- CheckboxNameRegex => '/^Want-/',
+ CheckboxNameRegex => '/^Want$/',
&>
</form>
<%INIT>
my @actions;
+
my $title = loc("Customize").' '.loc("Quick search");
+
my $user = $session{'CurrentUser'}->UserObj;
-my $unwanted = $user->Preferences('QuickSearch', {});
-my $Queues = RT::Queues->new($session{'CurrentUser'});
-$Queues->UnLimit;
-
-my $right = 'ShowTicket';
-$m->callback(
- CallbackName => 'ModifyQueues',
- Queues => \$Queues,
- Right => \$right,
- Unwanted => $unwanted,
-);
-
-my @queues = grep { $right ? $_->CurrentUserHasRight($right) : 1 } @{$Queues->ItemsArrayRef};
-
-if ($ARGS{'Save'}) {
- for my $queue (@queues) {
- if ($ARGS{"Want-".$queue->Name}) {
- delete $unwanted->{$queue->Name};
- }
- else {
- ++$unwanted->{$queue->Name};
- }
- }
-
- my ($ok, $msg) = $user->SetPreferences('QuickSearch', $unwanted);
+
+my $preference = $user->Preferences($Pref, {});
+
+my @queues;
+if ( $EditUnwanted ) {
+ my $Queues = RT::Queues->new($session{'CurrentUser'});
+ $Queues->UnLimit;
+
+ my $right = 'ShowTicket';
+ $m->callback(
+ CallbackName => 'ModifyQueues',
+ Queues => \$Queues,
+ Right => \$right,
+ Want => \@Want,
+ );
+
+ @queues = grep { $right? $_->CurrentUserHasRight( $right ) : 1 } @{ $Queues->ItemsArrayRef };
+}
+
+if ( $Save ) {
+ my %Want = map { $_ => 1 } @Want;
+ $preference->{'Unwanted'} = { map { $_ => 1 } grep !$Want{ $_ }, map $_->Name, @queues };
+
+ $preference->{$_} = $ARGS{$_} foreach qw(
+ SplitByLifecycle
+ ShowEmptyRows
+ ShowEmptyColumns
+ );
+
+ my ($ok, $msg) = $user->SetPreferences( $Pref => $preference );
push @actions, $ok ? loc('Preferences saved.') : $msg;
}
</%INIT>
+<%ARGS>
+$Pref => 'QuickSearch'
+
+$EditUnwanted => 0
+ at Want => ()
+
+$Save => 0
+</%ARGS>
commit 8e94653e206b8c3c6f770c108abfc94d4264c7d2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Feb 2 00:20:00 2011 +0300
drop "quicksearch" preferences tab
there are multiple quick search like portlets, each with its own
preferences
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index b933568..c7113b4 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -558,7 +558,6 @@ my $build_main_nav = sub {
title => loc('Dashboards in menu'),
path => '/Prefs/DashboardsInMenu.html',
);
- $settings->child( quicksearch => title => loc('Quick search'), path => '/Prefs/QueueSummary.html' );
my $search_menu = $settings->child( 'saved-searches' => title => loc('Saved Searches') );
my $searches = [ $m->comp( "/Search/Elements/SearchesForObject",
commit 5ad39efea42d74569eba69d819964990da719fef
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Mar 2 16:21:38 2011 +0300
adjust tests for new QueueSummary
no more link under preferences, use one from "rt at glance"
Want checkbox has been changed - it's an array now
diff --git a/t/web/custom_search.t b/t/web/custom_search.t
index 75f832d..408ad77 100644
--- a/t/web/custom_search.t
+++ b/t/web/custom_search.t
@@ -22,7 +22,8 @@ like ($t_link->url, qr/$id/, 'link to the ticket we created');
$m->content_lacks ('customsearch at localhost', 'requestor not displayed ');
$m->get ( $url.'Prefs/MyRT.html' );
my $cus_hp = $m->find_link( text => "My Tickets" );
-my $cus_qs = $m->find_link( text => "Quick search" );
+$m->get ( $url );
+my $cus_qs = $m->find_link( text => "Edit", url_regex => qr/QueueSummary/ );
$m->get ($cus_hp);
$m->content_contains('highest priority tickets');
@@ -66,7 +67,7 @@ $m->content_lacks ('customsearch at localhost', 'requestor not displayed ');
my $nlinks = $#{$m->find_all_links( text => "General" )};
$m->get ($cus_qs);
$m->form_name ('Preferences');
-$m->untick('Want-General', '1');
+$m->untick( Want => 'General');
$m->click_button (name => 'Save');
$m->get( $url );
@@ -76,7 +77,7 @@ is ($#{$m->find_all_links( text => "General" )}, $nlinks - 1,
# get it back
$m->get ($cus_qs);
$m->form_name ('Preferences');
-$m->tick('Want-General', '1');
+$m->tick( Want => 'General' );
$m->click_button (name => 'Save');
$m->get( $url );
commit 2a8a3a852f0b182e01943b72d9ae6e64a706f304
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Aug 28 18:06:39 2013 +0400
update license tag
diff --git a/share/html/Elements/QueueSummary b/share/html/Elements/QueueSummary
index 6e3afc3..5dcd0e4 100644
--- a/share/html/Elements/QueueSummary
+++ b/share/html/Elements/QueueSummary
@@ -2,7 +2,7 @@
%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
%# <sales at bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
commit 6116e6bbd8c1163bc861d76ae37e463756deddc0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Aug 28 18:17:42 2013 +0400
make split by lifecycle default
It was default in 4.0 and it is good default, so new preference
is 'NoSplitByLifecycle'
diff --git a/share/html/Elements/QueueSummary b/share/html/Elements/QueueSummary
index 5dcd0e4..a8d560b 100644
--- a/share/html/Elements/QueueSummary
+++ b/share/html/Elements/QueueSummary
@@ -62,9 +62,9 @@ $preference = $preference
: {}
;
-my $comp = '/Elements/QueueSummaryByStatus';
-if ( $preference->{'SplitByLifecycle'} ) {
- $comp = '/Elements/QueueSummaryByLifecycle';
+my $comp = '/Elements/QueueSummaryByLifecycle';
+if ( $preference->{'NoSplitByLifecycle'} ) {
+ $comp = '/Elements/QueueSummaryByStatus';
}
if ( $preference->{'Unwanted'} && keys %{ $preference->{'Unwanted'} } ) {
@queues = grep !$preference->{'Unwanted'}{ $_->Name }, @queues;
diff --git a/share/html/Prefs/QueueSummary.html b/share/html/Prefs/QueueSummary.html
index ba3fb2f..f8ce765 100644
--- a/share/html/Prefs/QueueSummary.html
+++ b/share/html/Prefs/QueueSummary.html
@@ -68,11 +68,11 @@ checked="checked" \
% }
/><&|/l&>Show columns with all zeros</&></label><br />
-<label><input type="checkbox" class="checkbox" name="SplitByLifecycle" value="1" \
-% if ( $preference->{'SplitByLifecycle'} ) {
+<label><input type="checkbox" class="checkbox" name="NoSplitByLifecycle" value="1" \
+% if ( $preference->{'NoSplitByLifecycle'} ) {
checked="checked" \
% }
-/><&|/l&>Split into groups with different status sets (lifecycles)</&></label><br />
+/><&|/l&>Don't split into groups with different status sets (lifecycles)</&></label><br />
% if ( $EditUnwanted ) {
<h1><&|/l&>Select queues to be displayed</&></h1>
@@ -130,7 +130,7 @@ if ( $Save ) {
$preference->{'Unwanted'} = { map { $_ => 1 } grep !$Want{ $_ }, map $_->Name, @queues };
$preference->{$_} = $ARGS{$_} foreach qw(
- SplitByLifecycle
+ NoSplitByLifecycle
ShowEmptyRows
ShowEmptyColumns
);
commit 057302c7b2b035ffd05fc4c2a0109c396c233f36
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Aug 28 18:58:38 2013 +0400
make default to show empty rows/columns
While it's useful to hide them in some conditions,
but in most situations repeated position of queues
and columns is win in user experience terms.
diff --git a/share/html/Elements/QueueSummary b/share/html/Elements/QueueSummary
index a8d560b..0c1d920 100644
--- a/share/html/Elements/QueueSummary
+++ b/share/html/Elements/QueueSummary
@@ -99,10 +99,10 @@ while ( my $entry = $report->Next ) {
$data_has_status{ $status } = 1;
}
-unless ( $preference->{'ShowEmptyColumns'} ) {
+if ( $preference->{'HideEmptyColumns'} ) {
@statuses = grep $data_has_status{$_}, @statuses;
}
-unless ( $preference->{'ShowEmptyRows'} ) {
+if ( $preference->{'HideEmptyRows'} ) {
@queues = grep $data{ $_->id }{''}, @queues;
}
diff --git a/share/html/Prefs/QueueSummary.html b/share/html/Prefs/QueueSummary.html
index f8ce765..5f24911 100644
--- a/share/html/Prefs/QueueSummary.html
+++ b/share/html/Prefs/QueueSummary.html
@@ -56,17 +56,17 @@
<h1><&|/l&>Select table preferences</&></h1>
-<label><input type="checkbox" class="checkbox" name="ShowEmptyRows" value="1" \
-% if ( $preference->{'ShowEmptyRows'} ) {
+<label><input type="checkbox" class="checkbox" name="HideEmptyRows" value="1" \
+% if ( $preference->{'HideEmptyRows'} ) {
checked="checked" \
% }
-/><&|/l&>Show rows with all zeros</&></label><br />
+/><&|/l&>Hide rows with all zeros</&></label><br />
-<label><input type="checkbox" class="checkbox" name="ShowEmptyColumns" value="1" \
-% if ( $preference->{'ShowEmptyColumns'} ) {
+<label><input type="checkbox" class="checkbox" name="HideEmptyColumns" value="1" \
+% if ( $preference->{'HideEmptyColumns'} ) {
checked="checked" \
% }
-/><&|/l&>Show columns with all zeros</&></label><br />
+/><&|/l&>Hide columns with all zeros</&></label><br />
<label><input type="checkbox" class="checkbox" name="NoSplitByLifecycle" value="1" \
% if ( $preference->{'NoSplitByLifecycle'} ) {
@@ -131,8 +131,8 @@ if ( $Save ) {
$preference->{$_} = $ARGS{$_} foreach qw(
NoSplitByLifecycle
- ShowEmptyRows
- ShowEmptyColumns
+ HideEmptyRows
+ HideEmptyColumns
);
my ($ok, $msg) = $user->SetPreferences( $Pref => $preference );
commit ca61ecfb2c4d54ed101fb235e45256769efeb6bf
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Aug 28 19:35:56 2013 +0400
upgrade script for old quicksearch preferences
diff --git a/etc/upgrade/4.3.0/content b/etc/upgrade/4.3.0/content
new file mode 100644
index 0000000..f147041
--- /dev/null
+++ b/etc/upgrade/4.3.0/content
@@ -0,0 +1,40 @@
+use strict;
+use warnings;
+
+our @Initial = (sub {
+ my $pref_name = 'QuickSearch';
+
+ my $users = RT::Users->new(RT->SystemUser);
+ $users->FindAllRows;
+
+ my $attributes = $users->Join(
+ ALIAS1 => "main",
+ FIELD1 => "id",
+ TABLE2 => RT::Attributes->Table,
+ FIELD2 => "ObjectId",
+ );
+ $users->Limit(
+ ALIAS => $attributes,
+ FIELD => "ObjectType",
+ VALUE => "RT::User",
+ );
+ $users->Limit(
+ ALIAS => $attributes,
+ FIELD => "Name",
+ VALUE => RT::User::_PrefName( $pref_name ),
+ );
+
+ # Iterate all users (including disabled), with Quicksearch preferences set.
+ # Avoids running a query for every user in the system by only selecting
+ # those known to have preferences.
+ while (my $user = $users->Next) {
+ RT->Logger->debug(sprintf "User #%d has $pref_name preferences", $user->id);
+
+ my $config = $user->Preferences( $pref_name )
+ or next;
+ $user->SetPreferences( $pref_name, { Unwanted => $config } );
+ RT->Logger->debug(sprintf "Updated $pref_name preferences for user %s (#%d)", $user->Name, $user->id);
+ }
+});
+
+1;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list