[open-ils-commits] [GIT] Evergreen ILS branch master updated. 3eeb80320ce04ba4e910cce828e28dfc8cd2fa94

Evergreen Git git at git.evergreen-ils.org
Wed May 9 14:49:14 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  3eeb80320ce04ba4e910cce828e28dfc8cd2fa94 (commit)
      from  bd190b0b66baaeb669f042b90053732596771311 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3eeb80320ce04ba4e910cce828e28dfc8cd2fa94
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Tue May 8 11:25:23 2012 -0400

    TPAC: Keep site() and depth() out of basic search box when widgets suffice
    
    This is a short term but working solution to the problem described here:
    https://bugs.launchpad.net/evergreen/+bug/986196
    
    Now when you have a selection for site on the advanced search page, it
    doesn't lead to redundant site() and depth() terms in your basic search
    query box.
    
    Item type selections and search class selections (keyword/author/etc)
    can still lead to ugliness in the advanced search box, but that's
    because in the advanced search page you get a multi-select widget for
    item type and in a basic search page you only get a single-select
    dropdown, so there's not a clean way to map your advanced page
    selections to basic page selections.  Search classes are kind of the
    same issue, since you have three dropdowns on the advanced search page
    and one on the basic.
    
    So the "bigger" problem is one that we will have to solve later, but for
    the common case at least we don't get the extra site() and depth() for
    now.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
index 53365e0..1bf8b61 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
@@ -100,11 +100,14 @@ sub _prepare_biblio_search {
         }
     }
 
-    my $site;
+    my (@naive_query_re, $site);
+
     my $org = $ctx->{search_ou};
     if (defined($org) and $org ne '' and ($org ne $ctx->{aou_tree}->()->id) and not $query =~ /site\(\S+\)/) {
-        $site = $ctx->{get_aou}->($org)->shortname;
-        $query .= " site($site)";
+        my $thing = " site(" . $ctx->{get_aou}->($org)->shortname . ")";
+
+        $query .= $thing;
+        push @naive_query_re, $thing;
     }
 
     my $pref_ou = $ctx->{pref_ou};
@@ -137,9 +140,21 @@ sub _prepare_biblio_search {
             my ($org) = grep { $_->shortname eq $site } @{$ctx->{aou_list}->()};
             $depth = $org->ou_type->depth;
         }
-        $query .= " depth($depth)";
+        my $thing = " depth($depth)";
+
+        $query .= $thing;
+        push @naive_query_re, $thing;
     }
 
+    # This gives templates a way to take site() and depth() back out of
+    # query strings when they shouldn't be there (because they're controllable
+    # with other widgets).
+    $ctx->{naive_query_scrub} = sub {
+        my ($query) = @_;
+        $query =~ s/\Q$_\E// foreach (@naive_query_re);
+        return $query;
+    };
+
     $logger->info("tpac: site=$site, depth=$depth, query=$query");
 
     return ($query, $site, $depth);
diff --git a/Open-ILS/src/templates/opac/parts/searchbar.tt2 b/Open-ILS/src/templates/opac/parts/searchbar.tt2
index fccac11..3a2f6f0 100644
--- a/Open-ILS/src/templates/opac/parts/searchbar.tt2
+++ b/Open-ILS/src/templates/opac/parts/searchbar.tt2
@@ -16,7 +16,7 @@
         %]
         <span class='search_box_wrapper'>
             <input type="text" id="search_box" name="query"
-                value="[% is_advanced ? ctx.processed_search_query : CGI.param('query') | html %]"
+                value="[% is_advanced ? ctx.naive_query_scrub(ctx.processed_search_query) : CGI.param('query') | html %]"
                 [%- IF use_autosuggest.enabled == "t" %]
                 dojoType="openils.widget.AutoSuggest" type_selector="'qtype'"
                 submitter="this.textbox.form.submit();"

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

Summary of changes:
 .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm |   23 ++++++++++++++++---
 Open-ILS/src/templates/opac/parts/searchbar.tt2    |    2 +-
 2 files changed, 20 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list