Repair faulty MARC editor authority validation
authorBill Erickson <berick@esilibrary.com>
Thu, 16 May 2013 13:11:50 +0000 (09:11 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 16 May 2013 15:01:49 +0000 (11:01 -0400)
Repair how the JS inspects the results of
open-ils.search.authority.simple_heading.from_xml.batch.atomic, which is
used to look up matches for authority validation.  It returns a more
complex structure in the brave new world of authority control sets.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/xul/staff_client/server/cat/marcedit.js

index 1fbf544..b3eb53a 100644 (file)
@@ -1616,11 +1616,28 @@ function validateAuthority (button) {
                     'subfields' : sf_list
                 })
             );
+
+            // matches = [ { "$csetId" : [ ... ] } ]
+
+            var found = false;
+            if (matches[0]) { // probably set
+                for (var cset in matches[0]) {
+                    var arr = matches[0][cset];
+                    if (arr.length) {
+                        // protect against errant empty string values
+                        if (arr.length == 1 && arr[0] == '')
+                            continue;
+                        found = true;
+                        break;
+                    }
+                }
+            }
+
     
             // XXX If adt, etc should be validated separately from vxz, etc then move this up into the above for loop
             for (var j = 0; j < subfields.length; j++) {
                 var sf = subfields[j];
-                if (!matches.length) {
+                if (!found) {
                     dojo.removeClass(sf.childNodes[2], 'marcValidated');
                     dojo.addClass(sf.childNodes[2], 'marcUnvalidated');
                 } else {
@@ -1629,7 +1646,7 @@ function validateAuthority (button) {
                 }
             }
 
-            if (matches.length) done = true;
+            if (found) done = true;
         });
     }