From 02f1c1f1c5c31159bb7c8df147c4ff5588fdca76 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 19 Apr 2013 16:14:13 -0400 Subject: [PATCH] Correct subfield format for authority lookup 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 Signed-off-by: Bill Erickson --- .../web/js/dojo/openils/AuthorityControlSet.js | 15 ++++++++++----- Open-ILS/xul/staff_client/server/cat/marcedit.js | 3 +-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js b/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js index c6c6c00445..adb9086a21 100644 --- a/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js +++ b/Open-ILS/web/js/dojo/openils/AuthorityControlSet.js @@ -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 }) ); diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index b3eb53aa08..614061f835 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -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( -- 2.43.2