From: dbs Date: Tue, 8 Feb 2011 05:11:47 +0000 (+0000) Subject: Ensure new authority ID subfield is inserted in the correct XUL DOM location X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=26c638e872fad3e2c5101564d4ca00f191c6fe8d;p=evergreen%2Fjoelewis.git 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... git-svn-id: svn://svn.open-ils.org/ILS/trunk@19402 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index 71c8c4fd0c..eeb76fbc27 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -2401,11 +2401,7 @@ function browseAuthority (sf_popup, menu_id, target, sf, limit, page) { [source_f, xulG.marc_control_number_identifier, ses()] ); if (new_auth && new_auth.id()) { - var id_sf = ({xulG.marc_control_number_identifier}){new_auth.id()}; - 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); } } }) @@ -2687,6 +2683,20 @@ function onBibSourceSelect() { } } +function addNewAuthorityID(authority, sf, target) { + var id_sf = ({xulG.marc_control_number_identifier}){authority.id()}; + 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 @@ -2714,11 +2724,9 @@ function loadMarcEditor(pcrud, marcxml, target, sf) { if (!new_rec) { return ''; } - var id_sf = ({xulG.marc_control_number_identifier}){new_rec.id()}; - 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(); } });