From 12894c4f76f1ee6e8f2a58ddabe27c39e281a8be Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 29 Mar 2017 16:15:31 -0400 Subject: [PATCH] LP#1673857: teach catalog how to search and display copy tags When the opac.search.enable_bookplate_search library setting is set to true, the catalog will display a "Digital Bookplates" search field in the drop-downs on both the search bar and the advanced search page. Using this will add a "copy_tag(*, search_terms)" filter to the search, i.e., all visible copy tags will be searched regardless of type. Users can also use the copy_tag() search filter directly. Visible copy tags are displayed in the copy table in the record summary page. Note that copy tags are displayed regardless of whether or not opac.search.enable_bookplate_search is on or off. Mike Rylander also contributed to this patch. Signed-off-by: Galen Charlton Signed-off-by: Josh Stompro Signed-off-by: Galen Charlton --- .../lib/OpenILS/WWW/EGCatLoader/Record.pm | 14 ++++++++++++ .../lib/OpenILS/WWW/EGCatLoader/Search.pm | 22 +++++++++++++++++-- Open-ILS/src/templates/opac/css/style.css.tt2 | 9 ++++++++ .../templates/opac/parts/qtype_selector.tt2 | 8 ++++++- .../opac/parts/record/copy_table.tt2 | 11 ++++++++++ 5 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 114de0cb69..a7f56a274c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -102,6 +102,7 @@ sub load_record { $ctx->{copies} = $copy_rec->gather(1); # Add public copy notes to each copy - and while we're in there, grab peer bib records + # and copy tags my %cached_bibs = (); foreach my $copy (@{$ctx->{copies}}) { $copy->{notes} = $U->simplereq( @@ -110,6 +111,19 @@ sub load_record { {itemid => $copy->{id}, pub => 1 } ); $self->timelog("past copy note retrieval call"); + my $meth = 'open-ils.circ.copy_tags.retrieve'; + $meth .= ".staff" if $ctx->{is_staff}; + $copy->{tags} = $U->simplereq( + 'open-ils.circ', + $meth, + { + ($ctx->{is_staff} ? (authtoken => $ctx->{authtoken}) : ()), + copy_id => $copy->{id}, + scope => $org, + depth => $copy_depth, + } + ); + $self->timelog("past copy tag retrieval call"); $copy->{peer_bibs} = $U->simplereq( 'open-ils.search', 'open-ils.search.multi_home.bib_ids.by_barcode', 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 72faa1cd80..fa72bc91eb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -20,11 +20,21 @@ sub _prepare_biblio_search_basics { $parts{$_} = [ $cgi->param($_) ] for (@part_names); my $full_query = ''; + my @bookplate_queries = (); for (my $i = 0; $i < scalar @{$parts{'qtype'}}; $i++) { my ($qtype, $contains, $query, $bool) = map { $parts{$_}->[$i] } @part_names; next unless $query =~ /\S/; + # Hack for bookplates; "bookplate" is not a real search + # class, so grabbing them out of the advanced search query + # params to convert to a copy_tag(*,...) filter later + if ($qtype eq 'bookplate') { + $query =~ s/[)(]/ /g; # don't break on 'foo(bar)baz' + push @bookplate_queries, $query; + next; + } + # Hack for journal title my $jtitle = 0; if ($qtype eq 'jtitle') { @@ -63,15 +73,23 @@ sub _prepare_biblio_search_basics { $full_query = $full_query ? "($full_query $bool $query)" : $query; } - return $full_query; + return $full_query, \@bookplate_queries; } sub _prepare_biblio_search { my ($cgi, $ctx) = @_; # XXX This will still contain the jtitle hack... - my $user_query = _prepare_biblio_search_basics($cgi) || ''; + my ($user_query, $bookplate_queries) = _prepare_biblio_search_basics($cgi); + $user_query //= ''; + $bookplate_queries //= []; my $query = $user_query; + if (@$bookplate_queries) { + $query .= " " . join(" ", map { "copy_tag(*,$_)" } @$bookplate_queries); + # hack to handle the case where a bookplate comes from the + # simple search box + $user_query = $bookplate_queries->[0] if $user_query eq ''; + } $query .= ' ' . $ctx->{global_search_filter} if $ctx->{global_search_filter}; diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2 index a8884dbf69..226b294d75 100644 --- a/Open-ILS/src/templates/opac/css/style.css.tt2 +++ b/Open-ILS/src/templates/opac/css/style.css.tt2 @@ -714,6 +714,15 @@ div.format_icon { word-wrap:normal; } +#rdetails_status tbody td.copy_tag { + border-color: [% css_colors.primary %]; + border-style: dashed; + border-width: 2px; +} +#rdetails_status tbody .copy_tag_value { + font-weight: bolder; +} + .rdetail_extras { background-color: [% css_colors.primary_fade %]; border: 1px solid [% css_colors.primary %]; diff --git a/Open-ILS/src/templates/opac/parts/qtype_selector.tt2 b/Open-ILS/src/templates/opac/parts/qtype_selector.tt2 index 4ed9e63041..ff3247ea5a 100644 --- a/Open-ILS/src/templates/opac/parts/qtype_selector.tt2 +++ b/Open-ILS/src/templates/opac/parts/qtype_selector.tt2 @@ -5,7 +5,13 @@ {value => "author", label => l("Author"), plural_label => l("Authors"), browse => 1}, {value => "subject", label => l("Subject"), plural_label => l("Subjects"), browse => 1}, {value => "series", label => l("Series"), plural_label => l("Series"), browse => 1} -] %] +]; + IF ctx.get_org_setting(ctx.search_ou, 'opac.search.enable_bookplate_search'); + query_types.push( + {value => "bookplate", label => l("Digital Bookplate"), plural_label => l("Digital Bookplates")} + ); + END; +-%]