From 00294ea6d3f4482b502cdc4cb68b7791c4c531a6 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Wed, 14 Dec 2011 14:30:52 -0500 Subject: [PATCH] Fix can_have_copies checks Bibs aren't required to have sources. Thus, adjust all appropriate locations to support a default state of "no source bibs can have copies", without erroring out. Signed-off-by: Thomas Berezansky Signed-off-by: Dan Scott --- Open-ILS/web/opac/skin/default/js/rdetail.js | 2 +- Open-ILS/xul/staff_client/chrome/content/cat/opac.js | 4 ++-- Open-ILS/xul/staff_client/server/cat/bib_brief.js | 2 +- Open-ILS/xul/staff_client/server/cat/copy_browser.js | 8 ++++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index da5f86c9ba..dfc4c7d5f8 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -197,7 +197,7 @@ function rdetailDraw() { var sourceReq = new Request(FETCH_BIB_SOURCE, G.user.session, bib.source()); sourceReq.send(true); var source = sourceReq.result(); - if (source.can_have_copies() == 'f') { + if (source && source.can_have_copies() == 'f') { alert(dojo.string.substitute(opac_strings.SOURCE_CANNOT_HAVE_COPIES, [source.source()])); } else { var req = new Request(CREATE_MFHD_RECORD, G.user.session, 1, here.id(), getRid()); diff --git a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js index a07b9a4a90..659d652adf 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -573,7 +573,7 @@ function create_mfhd() { [ ses(), bibObj.source() ] ); - if (cbsObj.can_have_copies() != get_db_true()) { + if (cbsObj && cbsObj.can_have_copies() != get_db_true()) { alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()])); return; } @@ -948,7 +948,7 @@ function add_volumes() { [ ses(), bibObj.source() ] ); - if (cbsObj.can_have_copies() != get_db_true()) { + if (cbdObj && cbsObj.can_have_copies() != get_db_true()) { alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()])); return; } diff --git a/Open-ILS/xul/staff_client/server/cat/bib_brief.js b/Open-ILS/xul/staff_client/server/cat/bib_brief.js index df04c3d169..face076996 100644 --- a/Open-ILS/xul/staff_client/server/cat/bib_brief.js +++ b/Open-ILS/xul/staff_client/server/cat/bib_brief.js @@ -173,7 +173,7 @@ function add_volumes() { try { JSAN.use('cat.util'); var cbsObj = cat.util.get_cbs_for_bre_id(docid); - if (cbsObj.can_have_copies() != get_db_true()) { + if (cbsObj && cbsObj.can_have_copies() != get_db_true()) { alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()])); return; } diff --git a/Open-ILS/xul/staff_client/server/cat/copy_browser.js b/Open-ILS/xul/staff_client/server/cat/copy_browser.js index 046c88e05a..c71183f33e 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_browser.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_browser.js @@ -1857,8 +1857,12 @@ cat.copy_browser.prototype = { try { JSAN.use('cat.util'); var cbsObj = cat.util.get_cbs_for_bre_id(obj.docid); - obj.can_have_copies = (cbsObj.can_have_copies() == get_db_true()); - obj.source = cbsObj.source(); + if(cbsObj) { + obj.can_have_copies = (cbsObj.can_have_copies() == get_db_true()); + obj.source = cbsObj.source(); + } else { + obj.can_have_copies = true; + } } catch(E) { obj.error.sdump('D_ERROR','can have copies check: ' + E); alert(E); -- 2.43.2