subject searching now includes the parent subject in the search terms
authorberick <berick@esilibrary.com>
Fri, 1 Apr 2011 13:46:56 +0000 (09:46 -0400)
committerberick <berick@esilibrary.com>
Fri, 1 Apr 2011 13:46:56 +0000 (09:46 -0400)
Open-ILS/web/opac/skin/kcls/js/marc.js

index 3c6ce53..cef0bca 100644 (file)
@@ -105,6 +105,7 @@ MarcRecord.prototype.render = function(fields, args) {
 // wrap each item in the array with an anchor tag for searching
 // excluding those subfields specified in 'codes'
 MarcRecord.prototype.buildSearchStr = function(arr, args, codes) {
+    var subjStrs = [];
   for(var i in arr) {
        var skip = false;
        for(var n in args.unlink)
@@ -120,6 +121,14 @@ MarcRecord.prototype.buildSearchStr = function(arr, args, codes) {
        args2[PARAM_OFFSET] = 0;
        args2[PARAM_TERM] = arr[i];
        args2[PARAM_STYPE] = args.searchType;
+    if(args.searchType == STYPE_SUBJECT) {
+        // subject searching is hierarchical, so we string them together
+        // into a long search string, which includes all parent subjects
+        subjStrs.push(arr[i]);
+        args2[PARAM_TERM] = subjStrs[0];
+        for(var idx = 1; idx < subjStrs.length; idx++)
+            args2[PARAM_TERM] =  args2[PARAM_TERM] + ' ' + subjStrs[idx];
+    }
        arr[i] = "<a href='"+buildOPACLink(args2).replace("'", "%27")+"'>"+arr[i]+"</a>";
   }
 };