LP#1287791: Restrict authority browse to controlled subfields
authorMike Rylander <mrylander@gmail.com>
Tue, 4 Mar 2014 16:31:13 +0000 (11:31 -0500)
committerDan Wells <dbw2@calvin.edu>
Mon, 2 Mar 2015 21:32:26 +0000 (16:32 -0500)
Back in bug 1175308 I added some logic that improves the behavior
of the MARC editor's right-click authority popup. Now we need to
go a little farther and adjust that logic to be more careful about
which subfields it uses to browse for authority records. Specifically,
it should only use controlled subfields.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/xul/staff_client/server/cat/marcedit.js

index 3455b41..a8eeb10 100644 (file)
@@ -1967,12 +1967,27 @@ function searchAuthority (term, tag, sf, limit) {
 function browseAuthority (sf_popup, menu_id, target, sf, limit, page) {
     dojo.require('dojox.xml.parser');
 
+    var target_tag = sf.parent().@tag.toString();
+
+    var found_acs = [];
+    dojo.forEach( acs.controlSetList(), function (acs_id) {
+        if (acs.controlSet(acs_id).control_map[target_tag]) found_acs.push(acs_id);
+    });
+
+    var cmap;
+    if (!found_acs.length) {
+        target.setAttribute('context', 'clipboard');
+        return false;
+    } else {
+        cmap = acs.controlSet(found_acs[0]).control_map;
+    }
+
     // map tag + subfield to the appropriate authority browse axis:
     // currently authority.author, authority.subject, authority.title, authority.topic
     // based on mappings in OpenILS::Application::SuperCat, though Authority Control
     // Sets will change that
 
-    var axis_list = acs.bibFieldBrowseAxes( sf.parent().@tag.toString() );
+    var axis_list = acs.bibFieldBrowseAxes( target_tag );
 
     // No matching tag means no authorities to search - shortcut
     if (axis_list.length == 0) {
@@ -1993,6 +2008,9 @@ function browseAuthority (sf_popup, menu_id, target, sf, limit, page) {
     var sf_string = '';
     var sf_list = sf.parent().subfield;
     for ( var i in sf_list) {
+        if (!cmap[target_tag][sf_list[i].@code.toString()]) {
+            continue; // This is not a controlled subfield, such as $0
+        }
         sf_string += sf_list[i].toString() + ' ';
         if (sf_list[i] === sf) break;
     }