[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-92-g9c3e93a

Kevin Falcone falcone at bestpractical.com
Fri Jun 18 16:32:09 EDT 2010


The branch, 3.9-trunk has been updated
       via  9c3e93a0ac550c894cba45d8b4c264d50c9a2399 (commit)
       via  69642a9912b9b8feea4ccd53c97f7c754c252048 (commit)
      from  7cfa19b2076252e593d9b3adbb2bf978898379fb (commit)

Summary of changes:
 etc/RT_Config.pm.in                                |    2 +-
 lib/RT/SavedSearches.pm                            |   23 +++++++
 .../{RT__Template => RT__SavedSearch}/ColumnMap    |   63 ++++++++++----------
 share/html/Elements/SavedSearches                  |   29 +++++++++
 4 files changed, 84 insertions(+), 33 deletions(-)
 copy share/html/Elements/{RT__Template => RT__SavedSearch}/ColumnMap (73%)
 create mode 100644 share/html/Elements/SavedSearches

- Log -----------------------------------------------------------------
commit 69642a9912b9b8feea4ccd53c97f7c754c252048
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Jun 18 16:29:45 2010 -0400

    Add some stubby methods to make CollectionList happier

diff --git a/lib/RT/SavedSearches.pm b/lib/RT/SavedSearches.pm
index 0848fc8..7f5aabe 100644
--- a/lib/RT/SavedSearches.pm
+++ b/lib/RT/SavedSearches.pm
@@ -146,6 +146,29 @@ sub Count {
     return scalar @{$self->{'objects'}};
 }
 
+=head2 CountAll
+
+Returns the number of search objects found
+
+=cut
+
+sub CountAll {
+    my $self = shift;
+    return $self->Count;
+}
+
+=head2 GotoPage
+
+Act more like a normal L<DBIx::SearchBuilder> collection.
+Moves the internal index around
+
+=cut
+
+sub GotoPage {
+    my $self = shift;
+    $self->{idx} = shift;
+}
+
 ### Internal methods
 
 # _GetObject: helper routine to load the correct object whose parameters

commit 9c3e93a0ac550c894cba45d8b4c264d50c9a2399
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Jun 18 13:00:01 2010 -0400

    Add a SavedSearch Homepage element
    
    Uses a basic CollectionList to show all your personal and
    group SavedSearches as clickable result links on your homepage.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 85d04b5..125fafb 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1348,7 +1348,7 @@ customized homepage ("RT at a glance").
 
 =cut
 
-Set($HomepageComponents, [qw(QuickCreate Quicksearch MyAdminQueues MySupportQueues MyReminders RefreshHomepage Dashboards)]);
+Set($HomepageComponents, [qw(QuickCreate Quicksearch MyAdminQueues MySupportQueues MyReminders RefreshHomepage Dashboards SavedSearches)]);
 
 =item C<@MasonParameters>
 
diff --git a/share/html/Elements/RT__SavedSearch/ColumnMap b/share/html/Elements/RT__SavedSearch/ColumnMap
new file mode 100644
index 0000000..795b5a2
--- /dev/null
+++ b/share/html/Elements/RT__SavedSearch/ColumnMap
@@ -0,0 +1,86 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%#                                          <jesse 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 }}}
+<%ARGS>
+$Name
+$Attr => undef
+</%ARGS>
+<%ONCE>
+my $COLUMN_MAP = {
+    id => {
+        title     => '#', # loc
+        attribute => 'id',
+        align     => 'right',
+        value     => sub { return $_[0]->Id },
+    },
+    Name => {
+        title     => sub { return "foo" }, #'Name', # loc
+        attribute => 'Name',
+        value     => sub { return $_[0]->Name()||loc("Unnamed search") },
+    },
+    Query => {
+        title     => 'Query', # loc
+        attribute => 'Query',
+        value     => sub { return $_[0]->GetParameter('Query') },
+    },
+    ResultsURL => {
+        title     => '',
+        attribute => 'ResultsURL',
+        value     => sub { my $search = shift;
+                           return join('&', sort
+                            map { $m->interp->apply_escapes($_,'u') .
+                                  '=' .
+                                  $m->interp->apply_escapes($search->GetParameter($_),'u') }
+                            qw(Query Format Rows Order OrderBy)) },
+    }
+};
+
+</%ONCE>
+<%INIT>
+$m->callback( COLUMN_MAP => $COLUMN_MAP, CallbackName => 'ColumnMap', CallbackOnce => 1 );
+return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
+</%INIT>
diff --git a/share/html/Elements/SavedSearches b/share/html/Elements/SavedSearches
new file mode 100644
index 0000000..e7b7d1e
--- /dev/null
+++ b/share/html/Elements/SavedSearches
@@ -0,0 +1,29 @@
+<&|/Widgets/TitleBox, title => loc('Saved Searches') &>
+% foreach my $Object (@Objects) {
+%   my $SavedSearches = RT::SavedSearches->new($session{CurrentUser});
+%   $SavedSearches->LimitToPrivacy(join('-',ref($Object),$Object->Id),'Ticket');
+%   my $title;
+%   if (ref $Object eq 'RT::User' && $Object->Id == $session{CurrentUser}->Id) {
+%       $title = loc("My saved searches");
+%   } else {
+%       $title = loc("[_1]'s saved searches",$Object->Name);
+%   }
+%   $title = $m->interp->apply_escapes($title, 'h');
+<& /Elements/CollectionList,
+    %ARGS,
+    Class => 'RT::SavedSearch',
+    Format => qq{'<a href="__WebPath__/Search/Results.html?__ResultsURL__">__Name__</a>/TITLE:$title'},
+    Collection => $SavedSearches,
+    PassArguments => [qw(Format Name id)],
+&>
+% }
+</&>
+<%init>
+my @Objects = RT::SavedSearches->new($session{CurrentUser})->_PrivacyObjects;
+push @Objects, RT::System->new( $session{'CurrentUser'} )
+    if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
+                                          Right => 'SuperUser' );
+</%init>
+<%ARGS>
+$user_attrs => undef
+</%ARGS>

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


More information about the Rt-commit mailing list