Create authorities that only contain controlled subfields (LP 712496)
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Feb 2011 06:12:24 +0000 (06:12 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Feb 2011 06:12:24 +0000 (06:12 +0000)
Selecting "Create authority" on a field containing uncontrolled subfields
would generate an authority record that contained those uncontrolled
subfields. This would, in turn, prevent the "Validate" button from operating
correctly - if you added a 700 with $a and $c subfields, clicked "Create
authority", and then immediately clicked "Validate", the field would show
up as red.

Now we filter out the uncontrolled subfields before they get sent to
the "Create authority" function, avoiding this validation problem.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19404 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/marcedit.js

index eeb76fb..9dc0137 100644 (file)
@@ -2610,16 +2610,25 @@ function summarizeField(sf) {
         "ind2": '',
         "subfields": []
     };
-    for (var i = 0; i < sf.parent().subfield.length(); i++) {
-        source_f.subfields.push([sf.parent().subfield[i].@code.toString(), sf.parent().subfield[i].toString()]);
-    }
+
     source_f.tag = sf.parent().@tag.toString();
     source_f.ind1 = sf.parent().@ind1.toString();
     source_f.ind1 = sf.parent().@ind2.toString();
+
+    for (var i = 0; i < sf.parent().subfield.length(); i++) {
+        var sf_iter = sf.parent().subfield[i];
+
+        /* Filter out subfields that are not controlled for this tag */
+        if (!control_map[source_f.tag][sf_iter.@code.toString()]) {
+            continue;
+        }
+
+        source_f.subfields.push([sf_iter.@code.toString(), sf_iter.toString()]);
+    }
+
     return source_f;
 }
 
-
 function buildBibSourceList (authtoken, recId) {
     /* TODO: Work out how to set the bib source of the bre that does not yet
      * exist - this is specifically in the case of Z39.50 imports. Right now