From c601157a51cf90a71b291958e33278400c402089 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Mon, 22 Aug 2011 18:28:18 -0400 Subject: [PATCH] Make the sort-by and limit-to-available controls appear after adv search This is hackish and suboptimal until we leverage the parsed queries soon to be returned by QP. Signed-off-by: Lebbeous Fogle-Weekley --- .../src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 14 ++++++++++++-- Open-ILS/web/js/ui/default/opac/simple.js | 6 ++++++ Open-ILS/web/templates/default/opac/results.tt2 | 3 +-- 3 files changed, 19 insertions(+), 4 deletions(-) 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 d97ac9624e..d15c7228f6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -54,7 +54,10 @@ sub _prepare_biblio_search { my $query = _prepare_biblio_search_basics($cgi) || ''; - $query = ('#' . $_ . ' ' . $query) foreach ($cgi->param('modifier')); + foreach ($cgi->param('modifier')) { + # The unless bit is to avoid stacking modifiers. + $query = ('#' . $_ . ' ' . $query) unless $query =~ qr/\#\Q$_/; + } # filters foreach (grep /^fi:/, $cgi->param) { @@ -63,10 +66,16 @@ sub _prepare_biblio_search { $query .= " $1($term)" if length $term; } + # sort is treated specially, even though it's actually a filter if ($cgi->param('sort')) { + $query =~ s/sort\([^\)]*\)//g; # override existing sort(). no stacking. my ($axis, $desc) = split /\./, $cgi->param('sort'); $query .= " sort($axis)"; - $query .= '#descending' if $desc; + if ($desc and not $query =~ /\#descending/) { + $query .= '#descending'; + } elsif (not $desc) { + $query =~ s/\#descending//; + } } if ($cgi->param('pubdate') && $cgi->param('date1')) { @@ -204,6 +213,7 @@ sub load_rresults { $ctx->{search_facets} = {}; $ctx->{page_size} = $limit; $ctx->{hit_count} = $results->{count}; + $ctx->{parsed_query} = $results->{parsed_query}; return Apache2::Const::OK if @$rec_ids == 0; diff --git a/Open-ILS/web/js/ui/default/opac/simple.js b/Open-ILS/web/js/ui/default/opac/simple.js index eaa11e2499..c120e4b2f3 100644 --- a/Open-ILS/web/js/ui/default/opac/simple.js +++ b/Open-ILS/web/js/ui/default/opac/simple.js @@ -73,3 +73,9 @@ function select_all_checkboxes(name, checked) { } } } +function avail_change_adv_search(checkbox) { + if (checkbox.form._adv && !checkbox.checked) { + var search_box = document.getElementById("search_box"); + search_box.value = search_box.value.replace(/#available ?/g, ""); + } +} diff --git a/Open-ILS/web/templates/default/opac/results.tt2 b/Open-ILS/web/templates/default/opac/results.tt2 index d368a70a2e..bfe96330f7 100644 --- a/Open-ILS/web/templates/default/opac/results.tt2 +++ b/Open-ILS/web/templates/default/opac/results.tt2 @@ -45,7 +45,6 @@ [% END %]
- [% UNLESS is_advanced || is_special %]
[% l('Sort by') %]
[% INCLUDE "default/opac/parts/filtersort.tt2" value=CGI.param('sort') %]
@@ -60,12 +59,12 @@
- [% END %]
-- 2.11.0