Correct subfield format for authority lookup
authorMike Rylander <mrylander@gmail.com>
Fri, 19 Apr 2013 20:14:13 +0000 (16:14 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 16 May 2013 15:01:53 +0000 (11:01 -0400)
The Authority Control Set code expects the format of subfields
that it will be used to build a MARC.Field object to be of the
form: [[code,value],...]  This commit makes that true.

Additionally, dojo.filter over a list of lists can cause the
nested array set to be flattened.  So, instead, we loop directly.

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

index c6c6c00..adb9086 100644 (file)
@@ -289,17 +289,22 @@ if(!dojo._hasResource["openils.AuthorityControlSet"]) {
             var b_field = this.bibFieldByTag(field.tag);
 
             if (b_field) { // construct an marc authority record
-                af = b_field.authority_field();
+                var af = b_field.authority_field();
+
+                var sflist = [];                
+                for (var i = 0; i < field.subfields.length; i++) {
+                    if (af.sf_list().indexOf(field.subfields[i][0]) > -1) {
+                        sflist.push(field.subfields[i]);
+                    }
+                }
+
                 var m = new MARC.Record ({rtype:'AUT'});
                 m.appendFields(
                     new MARC.Field ({
                         tag : af.tag(),
                         ind1: field.ind1,
                         ind2: field.ind2,
-                        subfields: [dojo.filter(
-                            field.subfields,
-                            function (sf) { return (af.sf_list().indexOf(sf[0]) > -1) }
-                        )]
+                        subfields: sflist
                     })
                 );
 
index b3eb53a..614061f 100644 (file)
@@ -1606,8 +1606,7 @@ function validateAuthority (button) {
             var sf_list = [];
             for (var j = 0; j < subfields.length; j++) {
                 var sf = subfields[j];
-                sf_list.push( sf.childNodes[1].value );
-                sf_list.push( sf.childNodes[2].value );
+                sf_list.push( [ sf.childNodes[1].value, sf.childNodes[2].value ] );
             }
 
             var matches = acs.findMatchingAuthorities(