From 5d1516c10d72336311289f1159c1a608a4db7b35 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 10 Aug 2015 16:55:58 -0400 Subject: [PATCH] JBAS-769 Holds pull list uses alt title/author as well The CHS and pull list UI's use the same template code to display holds. Modifying the template for one, means modifying for both. This udpates the hold pull list template to use the alternate title/author extraction code (for 245ab and 100ac display) for consistency with the display template. Signed-off-by: Bill Erickson --- Open-ILS/web/opac/extras/circ/alt_holds_print.js | 82 +++++++++++++----------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/Open-ILS/web/opac/extras/circ/alt_holds_print.js b/Open-ILS/web/opac/extras/circ/alt_holds_print.js index 366116e75d..c140d95f4c 100644 --- a/Open-ILS/web/opac/extras/circ/alt_holds_print.js +++ b/Open-ILS/web/opac/extras/circ/alt_holds_print.js @@ -1,11 +1,46 @@ dojo.require("dojo.cookie"); dojo.require("dojox.xml.parser"); -dojo.require("openils.BibTemplate"); dojo.require("openils.widget.ProgressDialog"); var authtoken; var cgi; +// extract the title and author from a MARCXML string. +function get_marc_bits(marcxml) { + var m100a = ''; + var m100c = ''; + var m245a = ''; + var m245b = ''; + + var xmlDoc = new DOMParser().parseFromString(marcxml, 'text/xml'); + + dojo.forEach( + xmlDoc.documentElement.getElementsByTagName('datafield'), + function(node) { + var tag = node.getAttribute('tag'); + if (tag == '100') { + dojo.forEach(node.childNodes, function(sub_node) { + var code = sub_node.getAttribute('code'); + if (code == 'a') m100a = sub_node.textContent; + if (code == 'c') m100c = sub_node.textContent; + }); + } else if (tag == '245') { + dojo.forEach(node.childNodes, function(sub_node) { + var code = sub_node.getAttribute('code'); + if (code == 'a') m245a = sub_node.textContent; + if (code == 'b') m245b = sub_node.textContent; + }); + } + } + ); + + return { + title : m100a + ' ' + m100c, + author : m245a + ' ' + m245b + }; +} + + function do_pull_list() { progress_dialog.show(true); @@ -42,6 +77,12 @@ function do_pull_list() { hold.current_copy.parts_stringified += ' ' + part.label(); }); + var bits = get_marc_bits( + hold.current_copy.call_number.record.marc); + + hold.title = bits.title; + hold.author = bits.author; + // clone the template's html var tr = dojo.clone( @@ -54,12 +95,6 @@ function do_pull_list() { } ); - new openils.BibTemplate({ - root : tr, - xml : dojox.xml.parser.parse(hold.current_copy.call_number.record.marc), - delay: false - }); - dojo.place(tr, "target"); }); }, @@ -214,36 +249,11 @@ function do_clear_holds_from_cache(cache_key) { var hold = hashify_fields(resp.hold_details); hold.action = resp.action; - var xmlDoc = new DOMParser().parseFromString( - hold.current_copy.call_number.record.marc,"text/xml"); - - var m100a = ''; - var m100c = ''; - var m245a = ''; - var m245b = ''; - - dojo.forEach( - xmlDoc.documentElement.getElementsByTagName('datafield'), - function(node) { - var tag = node.getAttribute('tag'); - if (tag == '100') { - dojo.forEach(node.childNodes, function(sub_node) { - var code = sub_node.getAttribute('code'); - if (code == 'a') m100a = sub_node.textContent; - if (code == 'c') m100c = sub_node.textContent; - }); - } else if (tag == '245') { - dojo.forEach(node.childNodes, function(sub_node) { - var code = sub_node.getAttribute('code'); - if (code == 'a') m245a = sub_node.textContent; - if (code == 'b') m245b = sub_node.textContent; - }); - } - } - ); + var bits = get_marc_bits( + hold.current_copy.call_number.record.marc); - hold.author = m100a + ' ' + m100c; - hold.title = m245a + ' ' + m245b; + hold.title = bits.title; + hold.author = bits.author; if(resp.hold_details.hold_type) { hold.hold_type = resp.hold_details.hold_type; -- 2.11.0