From 51ff52adfad0edd97a51a0fc1cc8ae4f4e1ba315 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Wed, 27 Jul 2011 17:31:30 -0400 Subject: [PATCH] It's ugly and hacky, but numeric search fully works (item barcode included) Signed-off-by: Lebbeous Fogle-Weekley --- .../lib/OpenILS/WWW/EGCatLoader/Search.pm | 42 +++++++++++++++++++ .../default/opac/parts/advanced/numeric.tt2 | 3 +- .../templates/default/opac/parts/header.tt2 | 1 + .../default/opac/parts/searchbar.tt2 | 8 ++-- .../web/templates/default/opac/results.tt2 | 4 +- 5 files changed, 51 insertions(+), 7 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 d445250449..ea33fa004c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -132,6 +132,9 @@ sub load_rresults { my $e = $self->editor; $ctx->{page} = 'rresult'; + + return $self->item_barcode_shortcut if $cgi->param("qtype") eq "item_barcode"; + my $page = $cgi->param('page') || 0; my $facet = $cgi->param('facet'); my $limit = $self->_get_search_limit; @@ -213,4 +216,43 @@ sub load_rresults { return Apache2::Const::OK; } +# Searching by barcode is a special search that does /not/ respect any other +# of the usual search parameters, not even the ones for sorting and paging! +sub item_barcode_shortcut { + my ($self) = @_; + + my $method = "open-ils.search.multi_home.bib_ids.by_barcode"; + if (my $search = create OpenSRF::AppSession("open-ils.search")) { + my $rec_ids = $search->request( + $method, $self->cgi->param("query") + )->gather(1); + + if (ref $rec_ids ne 'ARRAY') { + if (defined $U->event_code($rec_ids)) { + $self->apache->log->warn( + "$method returned event: " . $U->event_code($rec_ids) + ); + } else { + $self->apache->log->warn( + "$method returned something unexpected: $rec_ids" + ); + } + return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + } + + my ($facets, @data) = $self->get_records_and_facets( + $rec_ids, undef, {flesh => "{holdings_xml,mra}"} + ); + + $self->ctx->{records} = [@data]; + $self->ctx->{search_facets} = {}; + $self->ctx->{hit_count} = scalar @data; + $self->ctx->{page_size} = $self->ctx->{hit_count}; + + return Apache2::Const::OK; + } { + $self->apache->log->warn("couldn't connect to open-ils.search"); + return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + } +} 1; diff --git a/Open-ILS/web/templates/default/opac/parts/advanced/numeric.tt2 b/Open-ILS/web/templates/default/opac/parts/advanced/numeric.tt2 index 8835a5c7c0..c2a1d3dfdd 100644 --- a/Open-ILS/web/templates/default/opac/parts/advanced/numeric.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/advanced/numeric.tt2 @@ -1,6 +1,7 @@
[% l("Numeric Search") %]
+ - [% IF is_advanced %] + [% IF is_advanced || is_special %] [% END %] - [% IF ctx.processed_search_query OR NOT is_advanced %] + [% IF ctx.processed_search_query OR (NOT is_advanced AND NOT is_special) %] [% END %] - [% UNLESS is_advanced %] + [% UNLESS is_advanced OR is_special %]
@@ -10,7 +11,7 @@ - [%# XXX have to implement special logic for this later %] + diff --git a/Open-ILS/web/templates/default/opac/parts/header.tt2 b/Open-ILS/web/templates/default/opac/parts/header.tt2 index 114b4c3494..581307dc0d 100644 --- a/Open-ILS/web/templates/default/opac/parts/header.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/header.tt2 @@ -20,6 +20,7 @@ propagator = '?' _ query_string; is_advanced = CGI.param("_adv").size; + is_special = CGI.param("_special").size; %] diff --git a/Open-ILS/web/templates/default/opac/parts/searchbar.tt2 b/Open-ILS/web/templates/default/opac/parts/searchbar.tt2 index 433ce68a27..bf4a26ef39 100644 --- a/Open-ILS/web/templates/default/opac/parts/searchbar.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/searchbar.tt2 @@ -13,7 +13,7 @@
[% ELSE %] @@ -21,7 +21,7 @@ [% INCLUDE "default/opac/parts/qtype_selector.tt2" %]
@@ -45,7 +45,7 @@
[% INCLUDE "default/opac/parts/coded_value_selector.tt2" attr=["mattype", "item_type"] none_ok=1 %] @@ -63,7 +63,7 @@ [% END %]
[% UNLESS took_care_of_form %]
[% END %] - [% IF is_advanced AND CGI.param('qtype') %] + [% IF (is_advanced AND NOT is_special) AND CGI.param('qtype') %] [% END %]
- [% UNLESS is_advanced %] + [% UNLESS is_advanced || is_special %]
Sort by
[% INCLUDE "default/opac/parts/filtersort.tt2" value=CGI.param('sort') %]
-- 2.43.2