[Rt-commit] rt branch, librarize-search-logic, updated. 3c5392a734b770de304a9aabb245b42bb471ee72

jesse jesse at bestpractical.com
Thu Nov 5 20:46:13 EST 2009


The branch, librarize-search-logic has been updated
       via  3c5392a734b770de304a9aabb245b42bb471ee72 (commit)
       via  eb5083994f781813f051dc19e41c0aad194ba291 (commit)
      from  20fdc5f179a20f0adc1530f2675a216d9afbcf6a (commit)

Summary of changes:
 lib/RT/Interface/Web.pm              |   31 -------------------------
 lib/RT/Interface/Web/QueryBuilder.pm |   42 +++++++++++++++++++++++++++++-----
 share/html/Elements/ShowSearch       |    2 +-
 share/html/Search/Build.html         |    4 +-
 share/html/Widgets/SavedSearch       |    2 +-
 5 files changed, 40 insertions(+), 41 deletions(-)

- Log -----------------------------------------------------------------
commit eb5083994f781813f051dc19e41c0aad194ba291
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Nov 5 20:44:10 2009 -0500

    fix a missing paren

diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index 5e4537b..473843f 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -117,7 +117,7 @@
 
 </&>
 <%INIT>
-my $saved_search;
+my $saved_search = {};
 my %query = map { $_ => $ARGS{$_} } qw(query format order_by order rows_per_page);
 my @actions = RT::Interface::Web::QueryBuilder->load_saved_search( \%ARGS, \%query, $saved_search );
 
@@ -257,7 +257,7 @@ if ($new_query) {
 }
 
 if ( $ARGS{'do_search'} ) {
-	Jifty->web->redirect( Jifty->web->url . "Search/Results.html?" .$query_string;
+	Jifty->web->redirect( Jifty->web->url . "Search/Results.html?" .$query_string);
 }
 
 </%INIT>

commit 3c5392a734b770de304a9aabb245b42bb471ee72
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Nov 5 20:44:22 2009 -0500

    refactor saved-search loading code

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c06d800..c7f4a14 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1488,37 +1488,6 @@ sub get_column_map_entry {
     return undef;
 }
 
-=head2 _load_container_object ( $type, $id );
-
-Instantiate container object for saving searches.
-
-=cut
-
-sub _load_container_object {
-    my ( $obj_type, $obj_id ) = @_;
-    return RT::SavedSearch->new()->_load_privacy_object( $obj_type, $obj_id );
-}
-
-=head2 _parse_saved_search ( $arg );
-
-Given a serialization string for saved search, and returns the
-container object and the search id.
-
-=cut
-
-sub _parse_saved_search {
-    my $spec = shift;
-    return unless $spec;
-    if ( $spec !~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) {
-        return;
-    }
-    my $obj_type  = $1;
-    my $obj_id    = $2;
-    my $search_id = $3;
-
-    return ( _load_container_object( $obj_type, $obj_id ), $search_id );
-}
-
 =head2 get_jifty_messages
 
 =cut
diff --git a/lib/RT/Interface/Web/QueryBuilder.pm b/lib/RT/Interface/Web/QueryBuilder.pm
index 87fe764..92f84c3 100644
--- a/lib/RT/Interface/Web/QueryBuilder.pm
+++ b/lib/RT/Interface/Web/QueryBuilder.pm
@@ -179,7 +179,7 @@ sub load_saved_search {
     }
 
     if ( $ARGS->{'saved_search_load'} ) {
-        my ( $container, $id ) = _parse_saved_search( $ARGS->{'saved_search_load'} );
+        my ( $container, $id ) = RT::Interface::Web::QueryBuilder::_parse_saved_search( $ARGS->{'saved_search_load'} );
         my $search = $container->attributes->with_id($id);
 
         $saved_search->{'id'}          = $ARGS->{'saved_search_load'};
@@ -195,7 +195,7 @@ sub load_saved_search {
     } elsif ( $ARGS->{'saved_search_delete'} ) {
 
         # We set $SearchId to 'new' above already, so peek into the %ARGS
-        my ( $container, $id ) = _parse_saved_search( $saved_search->{'id'} );
+        my ( $container, $id ) = RT::Interface::Web::QueryBuilder::_parse_saved_search( $saved_search->{'id'} );
         if ( $container && $container->id ) {
 
             # We have the object the entry is an attribute on; delete the entry...
@@ -206,7 +206,7 @@ sub load_saved_search {
         $saved_search->{'description'} = undef;
         push @results, _("Deleted saved search");
     } elsif ( $ARGS->{'saved_search_copy'} ) {
-        my ( $container, $id ) = _parse_saved_search( $ARGS->{'saved_search_id'} );
+        my ( $container, $id ) = RT::Interface::Web::QueryBuilder::_parse_saved_search( $ARGS->{'saved_search_id'} );
         $saved_search->{'object'} = $container->attributes->withid($id);
         if (   $ARGS->{'saved_search_description'}
             && $ARGS->{'saved_search_description'} ne $saved_search->{'object'}->description )
@@ -223,11 +223,10 @@ sub load_saved_search {
         && $saved_search->{'id'} ne 'new'
         && !$saved_search->{'object'} )
     {
-        my ( $container, $id ) = _parse_saved_search( $ARGS->{'saved_search_id'} );
+        my ( $container, $id ) = RT::Interface::Web::QueryBuilder::_parse_saved_search( $ARGS->{'saved_search_id'} );
         $saved_search->{'object'} = $container->attributes->with_id($id);
         $saved_search->{'description'} ||= $saved_search->{'object'}->description;
     }
-
     return @results;
 }
 
@@ -245,7 +244,6 @@ sub save_search {
     my $obj  = $saved_search->{'object'};
     my $id   = $saved_search->{'id'};
     my $desc = $saved_search->{'description'};
-
     my $privacy = $saved_search->{'Privacy'};
 
     my %params = map { $_ => $query->{$_} } @$search_fields;
@@ -312,6 +310,38 @@ sub save_search {
     return @results;
 }
 
+=head2 _parse_saved_search ( $arg );
+
+Given a serialization string for saved search, and returns the
+container object and the search id.
+
+=cut
+
+sub _parse_saved_search {
+    my $spec = shift;
+    return unless $spec;
+    if ( $spec !~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) {
+        return;
+    }
+    my $obj_type  = $1;
+    my $obj_id    = $2;
+    my $search_id = $3;
+
+    return ( _load_container_object( $obj_type, $obj_id ), $search_id );
+}
+
+=head2 _load_container_object ( $type, $id );
+
+Instantiate container object for saving searches.
+
+=cut
+
+sub _load_container_object {
+    my ( $obj_type, $obj_id ) = @_;
+    return RT::SavedSearch->new()->_load_privacy_object( $obj_type, $obj_id );
+}
+
+
 sub build_format_string {
     my $self = shift;
     my %args = (
diff --git a/share/html/Elements/ShowSearch b/share/html/Elements/ShowSearch
index 9a7ff67..a946cc6 100644
--- a/share/html/Elements/ShowSearch
+++ b/share/html/Elements/ShowSearch
@@ -63,7 +63,7 @@ my $query_display_component = '/Elements/CollectionList';
 my $query_link_url = RT->config->get('web_path').'/Search/Results.html';
 
 if ($saved_search) {
-    my ( $container_object, $search_id ) = _parse_saved_search($saved_search);
+    my ( $container_object, $search_id ) = RT::Interface::Web::QueryBuilder::_parse_saved_search($saved_search);
     unless ( $container_object ) {
         $m->out(_("Either you have no rights to view saved search %1 or identifier is incorrect", $saved_search));
         return;
diff --git a/share/html/Widgets/SavedSearch b/share/html/Widgets/SavedSearch
index 7185c0f..bf421e9 100644
--- a/share/html/Widgets/SavedSearch
+++ b/share/html/Widgets/SavedSearch
@@ -62,7 +62,7 @@ push @objects, RT::System->new()
 $self->{SearchId} ||= 'new';
 my $search_params = { map { $_ => $args->{$_} } @{$self->{SearchFields}} };
 
-if ( my ( $container_object, $search_id ) = _parse_saved_search( $args->{'SavedSearchLoad'} ) ) {
+if ( my ( $container_object, $search_id ) = RT::Interface::Web::QueryBuilder::_parse_saved_search( $args->{'SavedSearchLoad'} ) ) {
     my $search = $container_object->attributes->with_id($search_id);
     # We have a $search and now; import the others
     $self->{SearchId} = $args->{'SavedSearchLoad'};

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


More information about the Rt-commit mailing list