[Rt-commit] rt branch, 4.2/queue-summary-refactoring, created. rt-4.0.8-574-g2fd44a5

Ruslan Zakirov ruz at bestpractical.com
Sun Nov 25 07:18:47 EST 2012


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

- Log -----------------------------------------------------------------
commit d87938b77cdb1d21eba9f45a56a0235cd5b028c0
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 4c762caec52bbf0f4c8d26b693d86392fd538c25
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 22def26..a2aa061 100644
--- a/lib/RT/SQL.pm
+++ b/lib/RT/SQL.pm
@@ -217,6 +217,13 @@ sub _BitmaskToString {
     return join ' or ', @res;
 }
 
+sub Quote {
+    my $v = defined(wantarray)? \"$_[1]" : \$_[1];
+    $$v =~ s{(['\\])}{\\$1}g;
+    $$v = "'$$v'";
+    return $$v;
+}
+
 sub PossibleCustomFields {
     my %args = (Query => undef, CurrentUser => undef, @_);
 

commit 87705ff0c874f6c7a158a3de3203d1edd7ac8d79
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 55%
copy from share/html/Elements/QueueSummaryByStatus
copy to share/html/Elements/QueueSummary
index f649d28..8463d13 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummary
@@ -45,68 +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 $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 ) . ')';
-</%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>
-</td>
-
-<%perl>
-   for my $status (@statuses) {
-   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>
-</td>
-%   } else {
-<td align="right">-</td>
-%   }
-%   }
-</tr>
-% }
-</table>
 <%INIT>
+$queues ||= RT::Queues->new( $session{'CurrentUser'} );
+$queues->UnLimit unless $queues->_isLimited;
 
-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->Name,
-    }
-} grep $_, @queues;
-
-my %lifecycle;
+$preference = $preference
+    ? $session{'CurrentUser'}->UserObj->Preferences($preference, {})
+    : {}
+;
 
-for my $queue (@queues) {
-    my $cycle = RT::Lifecycle->Load( $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 $_->Lifecycle, @queues;
 
 unless (@statuses) {
     my %seen;
@@ -117,27 +83,39 @@ 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 = $_", 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 ) {
-    $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;
+}
+
+return $m->comp(
+    $comp,
+    queues   => \@queues,
+    statuses => \@statuses,
+    data     => \%data,
+);
 </%INIT>
 <%ARGS>
+$queues => undef
 $queue_filter => undef
+$preference => undef,
 @statuses => ()
 </%ARGS>
diff --git a/share/html/Elements/QueueSummaryByLifecycle b/share/html/Elements/QueueSummaryByLifecycle
index 1410e82..314de08 100644
--- a/share/html/Elements/QueueSummaryByLifecycle
+++ b/share/html/Elements/QueueSummaryByLifecycle
@@ -45,41 +45,41 @@
 %# 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++;
-    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 ) . ')';
+    my $name = RT::SQL->Quote( $queue->Name );
+    my $queue_cond = "Queue = $name AND ";
+    my $all_q = $queue_cond . '(' . join( " OR ", map "Status = $_", map RT::SQL->Quote($_), @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="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->Description %>"><% $queue->Name %></a>
 </td>
 
-%   for my $status (@cur_statuses) {
+%   for my $status (@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="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = ". RT::SQL->Quote($status) |u,n %>"><% $data->{ $queue->id }->{ $status } || '0' %></a>
 </td>
 %   }
 </tr>
@@ -87,59 +87,31 @@ for my $queue (@queues) {
 </table>
 % }
 <%INIT>
+return unless @queues && @statuses;
 
-my $Queues = RT::Queues->new( $session{'CurrentUser'} );
-$Queues->UnLimit();
-$m->callback( CallbackName => 'SQLFilter', Queues => $Queues );
+my $max = 0;
 
-my @queues = grep $queue_filter->($_), @{ $Queues->ItemsArrayRef };
-$m->callback( CallbackName => 'Filter', Queues => \@queues );
-
- at queues = map {
-    {  id          => $_->Id,
-       Name        => $_->Name,
-       Description => $_->Description || '',
-       Lifecycle   => $_->Lifecycle->Name,
+my %groups;
+foreach my $queue ( @queues ) {
+    my $cycle = $queue->Lifecycle;
+    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( $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);
-        }
-    }
+    $groups{ $cycle_name } = {
+        cycle => $cycle,
+        statuses => [ grep $cycle->IsValid( $_), @statuses ],
+        queues => [$queue],
+    };
+    $max = @{ $groups{ $cycle_name }{'statuses'} }
+        if $max < @{ $groups{ $cycle_name }{'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;
-$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 f649d28..ddc0159 100644
--- a/share/html/Elements/QueueSummaryByStatus
+++ b/share/html/Elements/QueueSummaryByStatus
@@ -58,16 +58,16 @@
 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_cond = "Queue = ". RT::SQL->Quote($queue->Name) ." AND ";
+    my $lifecycle = $queue->Lifecycle;
+    my $all_q = $queue_cond . '(' . join( " OR ",
+        map "Status = ". RT::SQL->Quote($_), 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="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $all_q |u,n %>" title="<% $queue->Description %>"><% $queue->Name %></a>
 </td>
 
 <%perl>
@@ -75,7 +75,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="<% RT->Config->Get('WebPath') %>/Search/Results.html?Query=<% $queue_cond ."Status = ". RT::SQL->Quote($status) |u,n %>"><% $data->{ $queue->id }->{$status } || '0' %></a>
 </td>
 %   } else {
 <td align="right">-</td>
@@ -85,59 +85,10 @@ for my $queue (@queues) {
 % }
 </table>
 <%INIT>
-
-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->Name,
-    }
-} grep $_, @queues;
-
-my %lifecycle;
-
-for my $queue (@queues) {
-    my $cycle = RT::Lifecycle->Load( $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            => {}
 </%ARGS>

commit 4c340c34c3fc0884f30128fdcc9308dd9bbd1863
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 92c87b5..5a8c1d1 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 a098d5e..2c6115d 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 abc859b..3fc27d8 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 6ce7e8ca04a77b71ac6144dbedfcb92f56834f57
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 ea820fa..e9b0ae3 100644
--- a/share/html/Prefs/QueueSummary.html
+++ b/share/html/Prefs/QueueSummary.html
@@ -46,45 +46,86 @@
 %#
 %# 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" name="Want-<%$queue->Name%>" value="1"
-% unless ($unwanted->{$queue->Name}) {
-checked="checked"
+<li><input type="checkbox" class="checkbox" name="Want" value="<% $queue->Name %>" \
+% unless ($preference->{'Unwanted'}{ $queue->Name }) {
+checked="checked" \
 % }
-/><%$queue->Name%><% $queue->Description ? ': '.$queue->Description : '' %></li>
+/><% $queue->Name %><% $queue->Description ? ': '.$queue->Description : '' %></li>
 % }
 </ul>
+% }
 <& /Elements/Submit, CheckAll => 1, ClearAll => 1, Caption => loc("Save Changes"), Label => loc('Save'), Name => 'Save'&>
 
 </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 @queues = grep {$_->CurrentUserHasRight('ShowTicket')} @{$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;
+    @queues = grep { $_->CurrentUserHasRight('ShowTicket') } @{ $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 0ea1ce6b00a9e028eee29343fff1304872c43b04
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 280bc3c..9e0cdb4 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -523,7 +523,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 2fd44a53ad54e62583287c31826611d2ea0613e3
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 bf7d659..c599d3f 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