[open-ils-commits] r19403 - branches/rel_2_0/Open-ILS/xul/staff_client/server/cat (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 8 00:12:31 EST 2011


Author: dbs
Date: 2011-02-08 00:12:28 -0500 (Tue, 08 Feb 2011)
New Revision: 19403

Modified:
   branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js
Log:
Ensure new authority ID subfield is inserted in the correct XUL DOM location

Addresses LP 712499. After creating an authority via the context menu
in the MARC editor, the new ID subfield ($0) would be created right after
the subfield on which the context menu was invoked. It turns out that it
was being placed in the wrong location, and one symptom was that the
Validate button would not validate the controlled field against the newly
created authority.

Now we hunt through the parent DOM nodes until we find the 'sf_box' element
and then we append the ID subfield to that node. We also eliminate some
duplicate code by defining a common function so that the problem can be
fixed in one stroke...


Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js	2011-02-08 05:11:47 UTC (rev 19402)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/marcedit.js	2011-02-08 05:12:28 UTC (rev 19403)
@@ -2399,11 +2399,7 @@
                         [source_f, xulG.marc_control_number_identifier, ses()]
                     );
                     if (new_auth && new_auth.id()) {
-                        var id_sf = <subfield code="0" xmlns="http://www.loc.gov/MARC21/slim">({xulG.marc_control_number_identifier}){new_auth.id()}</subfield>;
-                        sf.parent().appendChild(id_sf);
-                        var new_sf = marcSubfield(id_sf);
-                        target.parentNode.appendChild(new_sf);
-                        alert($('catStrings').getString('staff.cat.marcedit.create_authority_success.label'));
+                        addNewAuthorityID(new_auth, sf, target);
                     }
                 }
             })
@@ -2685,6 +2681,20 @@
     }
 }
 
+function addNewAuthorityID(authority, sf, target) {
+    var id_sf = <subfield code="0" xmlns="http://www.loc.gov/MARC21/slim">({xulG.marc_control_number_identifier}){authority.id()}</subfield>;
+    sf.parent().appendChild(id_sf);
+    var new_sf = marcSubfield(id_sf);
+
+    var node = target;
+    while (dojo.attr(node, 'name') != 'sf_box') {
+        node = node.parentNode;
+    }
+    node.appendChild( new_sf );
+
+    alert($('catStrings').getString('staff.cat.marcedit.create_authority_success.label'));
+}
+
 function loadMarcEditor(pcrud, marcxml, target, sf) {
     /*
        To run in Firefox directly, must set signed.applets.codebase_principal_support
@@ -2712,11 +2722,9 @@
                         if (!new_rec) {
                             return '';
                         }
-                        var id_sf = <subfield code="0" xmlns="http://www.loc.gov/MARC21/slim">({xulG.marc_control_number_identifier}){new_rec.id()}</subfield>;
-                        sf.parent().appendChild(id_sf);
-                        var new_sf = marcSubfield(id_sf);
-                        target.parentNode.appendChild(new_sf);
-                        alert($('catStrings').getString('staff.cat.marcedit.create_authority_success.label'));
+
+                        addNewAuthorityID(new_rec, sf, target);
+
                         win.close();
                     }
                 });



More information about the open-ils-commits mailing list