[Rt-commit] rt branch, librarize-search-logic, updated. 25d69933c91b683cbc913812044c87f5c5c2312d
jesse
jesse at bestpractical.com
Fri Nov 6 16:11:02 EST 2009
The branch, librarize-search-logic has been updated
via 25d69933c91b683cbc913812044c87f5c5c2312d (commit)
via b59581df5b8eab0ba7cfc207e0e6a8dbf998b50e (commit)
from 12204037e3c29765fbbca46eeced23cdf27b8543 (commit)
Summary of changes:
lib/RT/Interface/Web/QueryBuilder.pm | 25 +++++++++++++++++++++++++
share/html/Search/Build.html | 15 +--------------
2 files changed, 26 insertions(+), 14 deletions(-)
- Log -----------------------------------------------------------------
commit b59581df5b8eab0ba7cfc207e0e6a8dbf998b50e
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Fri Nov 6 16:00:18 2009 -0500
extract some defaults-setting into a sub
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index 176d843..bf4e6b0 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -119,7 +119,10 @@ if ($new_query) {
Jifty->web->session->get('tickets')->clean_slate if defined Jifty->web->session->get('tickets');
}
-{ # Attempt to load what we can from the session and preferences, set defaults
+
+
+my $set_query_defaults = sub {
+ # Attempt to load what we can from the session and preferences, set defaults
my $current = Jifty->web->session->get('CurrentSearchHash');
my $prefs = Jifty->web->current_user->user_object->preferences("SearchDisplay") || {};
@@ -135,8 +138,12 @@ if ($new_query) {
$query{$param} = join( '|', @{ $query{$param} } ) if ( ref $query{$param} eq "ARRAY" )
}
- $query{'format'} = RT::Interface::Web->scrub_html( $query{'format'} ) if ( $query{'format'} );
-}
+ $query{'format'} = RT::Interface::Web->scrub_html( $query{'format'} ) if ( $query{'format'} );
+ return %query;
+};
+
+%query = $set_query_defaults->(%query);
+
my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
push @actions, $tree->parse_sql( query => $query{query} );
commit 25d69933c91b683cbc913812044c87f5c5c2312d
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Fri Nov 6 16:10:48 2009 -0500
extract out query default setting into lib
diff --git a/lib/RT/Interface/Web/QueryBuilder.pm b/lib/RT/Interface/Web/QueryBuilder.pm
index c38d01f..b58bad8 100644
--- a/lib/RT/Interface/Web/QueryBuilder.pm
+++ b/lib/RT/Interface/Web/QueryBuilder.pm
@@ -2,6 +2,31 @@ package RT::Interface::Web::QueryBuilder;
use warnings;
use strict;
+
+sub set_query_defaults {
+ my $self = shift;
+ my %query = (@_);
+ # Attempt to load what we can from the session and preferences, set defaults
+
+ my $current = Jifty->web->session->get('CurrentSearchHash');
+ my $prefs = Jifty->web->current_user->user_object->preferences("SearchDisplay") || {};
+ my $default = { query => '', format => '', order_by => 'id', order => 'ASC', rows_per_page => 50 };
+
+ for my $param (qw(query format order_by order rows_per_page)) {
+ $query{$param} = $current->{$param} unless defined $query{$param};
+ $query{$param} = $prefs->{$param} unless defined $query{$param};
+ $query{$param} = $default->{$param} unless defined $query{$param};
+ }
+
+ for my $param (qw(order order_by)) {
+ $query{$param} = join( '|', @{ $query{$param} } ) if ( ref $query{$param} eq "ARRAY" )
+ }
+
+ $query{'format'} = RT::Interface::Web->scrub_html( $query{'format'} ) if ( $query{'format'} );
+ return %query;
+}
+
+
sub process_query {
my $self = shift;
my $ARGS = shift;
diff --git a/share/html/Search/Build.html b/share/html/Search/Build.html
index bf4e6b0..44dc383 100644
--- a/share/html/Search/Build.html
+++ b/share/html/Search/Build.html
@@ -121,28 +121,8 @@ if ($new_query) {
-my $set_query_defaults = sub {
- # Attempt to load what we can from the session and preferences, set defaults
- my $current = Jifty->web->session->get('CurrentSearchHash');
- my $prefs = Jifty->web->current_user->user_object->preferences("SearchDisplay") || {};
- my $default = { query => '', format => '', order_by => 'id', order => 'ASC', rows_per_page => 50 };
-
- for my $param (qw(query format order_by order rows_per_page)) {
- $query{$param} = $current->{$param} unless defined $query{$param};
- $query{$param} = $prefs->{$param} unless defined $query{$param};
- $query{$param} = $default->{$param} unless defined $query{$param};
- }
-
- for my $param (qw(order order_by)) {
- $query{$param} = join( '|', @{ $query{$param} } ) if ( ref $query{$param} eq "ARRAY" )
- }
-
- $query{'format'} = RT::Interface::Web->scrub_html( $query{'format'} ) if ( $query{'format'} );
- return %query;
-};
-
-%query = $set_query_defaults->(%query);
+%query = RT::Interface::Web::QueryBuilder->set_query_defaults(%query);
my $tree = RT::Interface::Web::QueryBuilder::Tree->new('AND');
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list