JBAS-1929 Catalog browse mattype filter
authorBill Erickson <berickxx@gmail.com>
Tue, 28 Nov 2017 22:28:40 +0000 (17:28 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
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 <berickxx@gmail.com>
KCLS/openils/var/templates_kcls/opac/parts/advanced/browse.tt2
KCLS/openils/var/templates_kcls/opac/parts/searchbar_browse.tt2
Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm
Open-ILS/web/js/ui/default/opac/browse_set_navigation.js

index d7f7072..e54a7d9 100644 (file)
     [% 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) %]
 
     <input id='search-submit-go' type="submit" value="[% l('Browse') %]" alt="[% l('Browse') %]" class="opac-button"/>
     <img id="browse-submit-spinner" src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif" class="hidden" style="width: 16px; height: 16px;" alt="" />
index 9105445..5b0d44f 100644 (file)
             [% 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) %]
             <input id='search-submit-go' type="submit" value="[% l('Browse') %]" alt="[% l('Browse') %]" class="opac-button"/>
             <img id="browse-submit-spinner" src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif" class="hidden" style="width: 16px; height: 16px;" alt="" />
             [% # Sets the browse search term field as the default on browse search page load. %]
index ba1b892..eee4db3 100644 (file)
@@ -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 = {};
index a19741f..6bbdd20 100644 (file)
@@ -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 (
index e83a0ab..d335e9d 100644 (file)
@@ -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);