From: Bill Erickson Date: Tue, 28 Nov 2017 22:28:40 +0000 (-0500) Subject: JBAS-1929 Catalog browse mattype filter X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7598cd50f91b5316f9456c64013eef543779fb6c;p=working%2FEvergreen.git JBAS-1929 Catalog browse mattype filter Adds a 'format' selector to the catalog browse UI. When a format is selected, only browse results linked to bibs using the selected format will be displayed. Code heavily inspired by Catalyst code posted in https://catalystit.atlassian.net/browse/KMAIN-1513. Signed-off-by: Bill Erickson --- diff --git a/KCLS/openils/var/templates_kcls/opac/parts/advanced/browse.tt2 b/KCLS/openils/var/templates_kcls/opac/parts/advanced/browse.tt2 index d7f70728f3..e54a7d92b2 100644 --- a/KCLS/openils/var/templates_kcls/opac/parts/advanced/browse.tt2 +++ b/KCLS/openils/var/templates_kcls/opac/parts/advanced/browse.tt2 @@ -18,7 +18,11 @@ [% control_locg = INCLUDE build_org_selector id='browse-context' show_loc_groups=1 arialabel=l('Select holding library') %] - [% l('Browse for [_1] that begin with [_2] in [_3]', control_qtype, control_bterm, control_locg) %] + [% control_mattype = INCLUDE "opac/parts/coded_value_selector.tt2" + attr=["mattype", "item_type"] none_ok=1 none_label=l('All Formats') + id="browse-search-format" browse_only=1 plural=1 %] + [% l('Browse for [_1] that begin with [_2] at [_3] in [_4]', + control_qtype, control_bterm, control_locg, control_mattype) %] diff --git a/KCLS/openils/var/templates_kcls/opac/parts/searchbar_browse.tt2 b/KCLS/openils/var/templates_kcls/opac/parts/searchbar_browse.tt2 index 9105445c8c..5b0d44f617 100644 --- a/KCLS/openils/var/templates_kcls/opac/parts/searchbar_browse.tt2 +++ b/KCLS/openils/var/templates_kcls/opac/parts/searchbar_browse.tt2 @@ -28,8 +28,11 @@ [% control_locg = INCLUDE build_org_selector id='browse-context' show_loc_groups=1 arialabel=l('Select holding library') %] - [% l('Browse for [_1] that begin with [_2] in [_3]', control_qtype, control_bterm, control_locg) %] - + [% control_mattype = INCLUDE "opac/parts/coded_value_selector.tt2" + attr=["mattype", "item_type"] none_ok=1 none_label=l('All Formats') + id="browse-search-format" browse_only=1 plural=1 %] + [% l('Browse for [_1] that begin with [_2] at [_3] in [_4]', + control_qtype, control_bterm, control_locg, control_mattype) %] [% # Sets the browse search term field as the default on browse search page load. %] diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm index ba1b89289e..eee4db3bb9 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm @@ -56,6 +56,7 @@ sub browseSetNav { my $searchClass = shift; my $searchTerm = shift; my $locg = shift; + my $mattype = shift; # JBAS-1929 my $e = new_editor; @@ -63,7 +64,8 @@ sub browseSetNav { my $isStaffClient = 't'; my $results = $e->json_query({ - from => [ "metabib.browse", $searchClass, $searchTerm, $locg, undef, $isStaffClient, $browseEntry, '3' ] + from => [ "metabib.browse", $searchClass, $searchTerm, + $locg, undef, $isStaffClient, $browseEntry, '3', $mattype ] }); my $navResults = {}; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm index a19741fcc4..6bbdd20992 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm @@ -69,7 +69,9 @@ sub prepare_browse_parameters { int( $self->cgi->param('blimit') || $self->ctx->{opac_hits_per_page} || 10 - ) + ), + # KCLS JBAS-1929 + $self->cgi->param('fi:mattype') || undef ); return ( diff --git a/Open-ILS/web/js/ui/default/opac/browse_set_navigation.js b/Open-ILS/web/js/ui/default/opac/browse_set_navigation.js index e83a0ab461..d335e9dc31 100644 --- a/Open-ILS/web/js/ui/default/opac/browse_set_navigation.js +++ b/Open-ILS/web/js/ui/default/opac/browse_set_navigation.js @@ -25,6 +25,14 @@ function set_navigator () { searchClass = matches[1]; } + // JBAS-1929 + var mattype = null; + var mattypeRegex = /fi%3Amattype=(\w)/; // %3A => : + var mattypeMatches = mattypeRegex.exec(url); + if (mattypeMatches && mattypeMatches.length > 1) { + mattype = mattypeMatches[1]; + } + // - browse term var searchTermRegex = /bterm\=(.+?)\;/; matches = searchTermRegex.exec(url); @@ -35,7 +43,7 @@ function set_navigator () { var locg = matches[1]; var retrieve = ['open-ils.search', 'open-ils.search.metabib.browse.setnav']; - var params = [ browseEntry, searchClass, searchTerm, locg ]; + var params = [ browseEntry, searchClass, searchTerm, locg, mattype ]; fieldmapper.standardRequest( retrieve, @@ -129,4 +137,4 @@ function addLoadEvent(func) { } } -addLoadEvent (set_navigator); \ No newline at end of file +addLoadEvent (set_navigator);