[Rt-commit] rt branch, 4.2/queue-summary-refactoring, created. rt-4.1.13-227-gc67f8fe

Ruslan Zakirov ruz at bestpractical.com
Thu Jul 4 13:15:32 EDT 2013


The branch, 4.2/queue-summary-refactoring has been created
        at  c67f8fe7a7fd1b97e02b2596b01fc29adc20f301 (commit)

- Log -----------------------------------------------------------------
commit da61ec9b50fe90c12ff6b54cbaf790fcfb884292
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/Prefs/Quicksearch.html b/share/html/Prefs/QueueSummary.html
similarity index 100%
rename from share/html/Prefs/Quicksearch.html
rename to share/html/Prefs/QueueSummary.html

commit a5025444f7854a806fce07de6076f0d642143c78
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Feb 2 00:15:38 2011 +0300

    RT::SQL->Quote helper

diff --git a/lib/RT/SQL.pm b/lib/RT/SQL.pm
index 1a469d6..edc7616 100644
--- a/lib/RT/SQL.pm
+++ b/lib/RT/SQL.pm
@@ -212,6 +212,13 @@ sub _BitmaskToString {
     return join ' or ', @res;
 }
 
+sub Quote {
+    my $v = defined(wantarray)? \"$_[1]" : \$_[1];
+    $$v =~ s{(['\\])}{\\$1}g;
+    $$v = "'$$v'";
+    return $$v;
+}
+
 RT::Base->_ImportOverlays();
 
 1;

commit d84ab3ee4e45eddaa806d6536bb0cd779d3e22fa
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/QueueSummary b/share/html/Elements/QueueSummary
new file mode 100644
index 0000000..8463d13
--- /dev/null
+++ b/share/html/Elements/QueueSummary
@@ -0,0 +1,121 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%INIT>
+$queues ||= RT::Queues->new( $session{'CurrentUser'} );
+$queues->UnLimit unless $queues->_isLimited;
+
+$m->callback( CallbackName => 'SQLFilter', Queues => $queues );
+
+my @queues = $queue_filter
+    ? grep $queue_filter->($_), @{ $queues->ItemsArrayRef }
+    : @{ $queues->ItemsArrayRef }
+;
+$m->callback( CallbackName => 'Filter', Queues => \@queues );
+
+$preference = $preference
+    ? $session{'CurrentUser'}->UserObj->Preferences($preference, {})
+    : {}
+;
+
+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 $_->Lifecycle, @queues;
+
+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);
+        }
+    }
+}
+
+use RT::Report::Tickets;
+my $report = RT::Report::Tickets->new( RT->SystemUser );
+my $query =
+    '('. join(" OR ", map "Status = $_", map 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 ) {
+    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;
+}
+
+return $m->comp(
+    $comp,
+    queues   => \@queues,
+    statuses => \@statuses,
+    data     => \%data,
+);
+</%INIT>
+<%ARGS>
+$queues => undef
+$queue_filter => undef
+$preference => undef,
+ at statuses => ()
+</%ARGS>
diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index adcf489..ce1fe22 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -45,37 +45,38 @@
 %# 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="<% $link_all->($queue, \@cur_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}}->{$status } || '-' %></a>
+    <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->id}->{$status } || '-' %></a>
 </td>
 %   }
 </tr>
@@ -83,6 +84,8 @@ for my $queue (@queues) {
 </table>
 % }
 <%INIT>
+return unless @queues && @statuses;
+
 my $build_search_link = sub {
     my ($queue_name, $extra_query) = @_;
     $queue_name =~ s/(['\\])/\\$1/g; #'
@@ -109,58 +112,29 @@ $m->callback(
     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 );
+my $max = 0;
 
- 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            => {}
 </%ARGS>
diff --git a/share/html/Elements/QueueSummaryByStatus b/share/html/Elements/QueueSummaryByStatus
index ee6ae8f..84624d6 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummaryByStatus
@@ -58,13 +58,12 @@
 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>
+    <a href="<% $link_all->($queue, \@queue_statuses) %>" title="<% $queue->Description %>"><% $queue->Name %></a>
 </td>
 
 <%perl>
@@ -72,7 +71,7 @@ for my $queue (@queues) {
    if ( $lifecycle->IsValid( $status ) ) {
 </%perl>
 <td align="right">
-    <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->{id}}->{$status } || '-' %></a>
+    <a href="<% $link_status->($queue, $status) %>"><% $data->{$queue->id}->{$status } || '-' %></a>
 </td>
 %   } else {
 <td align="right">-</td>
@@ -82,6 +81,8 @@ for my $queue (@queues) {
 % }
 </table>
 <%INIT>
+return unless @queues && @statuses;
+
 my $build_search_link = sub {
     my ($queue_name, $extra_query) = @_;
     $queue_name =~ s/(['\\])/\\$1/g; #'
@@ -107,59 +108,9 @@ $m->callback(
     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;
-}
 </%INIT>
 <%ARGS>
-$queue_filter => undef
- at statuses => ()
+ at queues          => ()
+ at statuses        => ()
+$data            => {}
 </%ARGS>

commit d4ce4f4a5bcb80c24f229ecef068750a0bcf5d8f
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 77814ed..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/Quicksearch.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 bdf44621ad9a3461bb083bfeafd4c8616bdd15e1
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 81757b9..4895355 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="Quicksearch.html" name="Preferences">
+
+<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>
+
+<input type="checkbox" class="checkbox" name="ShowEmptyRows" value="1" \
+% if ( $preference->{'ShowEmptyRows'} ) {
+checked="checked" \
+% }
+/><&|/l&>Show rows with all zeros</&><br />
+
+<input type="checkbox" class="checkbox" name="ShowEmptyColumns" value="1" \
+% if ( $preference->{'ShowEmptyColumns'} ) {
+checked="checked" \
+% }
+/><&|/l&>Show columns with all zeros</&><br />
+
+<input type="checkbox" class="checkbox" name="SplitByLifecycle" value="1" \
+% if ( $preference->{'SplitByLifecycle'} ) {
+checked="checked" \
+% }
+/><&|/l&>Split into groups with different status sets (lifecycles)</&><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,
+        Unwanted        => $unwanted,
+    );
+
+    @queues = grep { $right? $_->CurrentUserHasRight('ShowTicket') : 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 301657cd881d71cfbda2556fcb7b4f94b5b4b804
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 e4b4914..27815e6 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -564,7 +564,6 @@ 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' );
 
         my $search_menu = $settings->child( 'saved-searches' => title => loc('Saved Searches') );
         my $searches = [ $m->comp( "/Search/Elements/SearchesForObject",

commit c67f8fe7a7fd1b97e02b2596b01fc29adc20f301
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 );

-----------------------------------------------------------------------


More information about the Rt-commit mailing list