From 741e1869ddc7d62207cd242e02afd88bb32c2f76 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sat, 1 Oct 2011 12:02:16 -0400 Subject: [PATCH] Check for bib_source.can_have_copies in cataloging. Retrieve the BRE and CBS object in the add_volumes method of opac.js. Check if the CBS can have copies, and if not, tell the user such and return. Also required adding an api entry in constants.js and a new message in offline.properties. This is the beginning of the client code changes. There are very likely to be more. Signed-off-by: Jason Stephenson Signed-off-by: Dan Scott --- .../xul/staff_client/chrome/content/cat/opac.js | 52 ++++++++++++++++++++++ .../xul/staff_client/chrome/content/cat/opac.xul | 2 +- .../staff_client/chrome/content/main/constants.js | 1 + .../chrome/locale/en-US/offline.properties | 1 + 4 files changed, 55 insertions(+), 1 deletion(-) 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 92d4dcc6ec..a07b9a4a90 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -557,6 +557,32 @@ function set_serctrl_view() { } function create_mfhd() { + // Check if the source is allowed to have copies, first. + try { + var bibObj = g.network.request( + api.FM_BRE_RETRIEVE_VIA_ID.app, + api.FM_BRE_RETRIEVE_VIA_ID.method, + [ ses(), [docid] ] + ); + + bibObj = bibObj[0]; + + var cbsObj = g.network.request( + api.FM_CBS_RETRIEVE_VIA_PCRUD.app, + api.FM_CBS_RETRIEVE_VIA_PCRUD.method, + [ ses(), bibObj.source() ] + ); + + if (cbsObj.can_have_copies() != get_db_true()) { + alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()])); + return; + } + } catch(E) { + g.error.sdump('D_ERROR','can have copies check: ' + E); + alert('Error in chrome/content/cat/opac.js, create_mfhd(): ' + E); + return; + } + try { JSAN.use('util.window'); var win = new util.window(); var select_aou_window = win.open( @@ -906,6 +932,32 @@ function add_volumes() { return; // no read-only view for this interface } + // Check if the source is allowed to have copies. + try { + var bibObj = g.network.request( + api.FM_BRE_RETRIEVE_VIA_ID.app, + api.FM_BRE_RETRIEVE_VIA_ID.method, + [ ses(), [docid] ] + ); + + bibObj = bibObj[0]; + + var cbsObj = g.network.request( + api.FM_CBS_RETRIEVE_VIA_PCRUD.app, + api.FM_CBS_RETRIEVE_VIA_PCRUD.method, + [ ses(), bibObj.source() ] + ); + + if (cbsObj.can_have_copies() != get_db_true()) { + alert(document.getElementById('offlineStrings').getFormattedString('staff.cat.bib_source.can_have_copies.false', [cbsObj.source()])); + return; + } + } catch(E) { + g.error.sdump('D_ERROR','can have copies check: ' + E); + alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E); + return; + } + var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]); var url; diff --git a/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul b/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul index b7d517f9bf..2d775d3a5f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.xul @@ -26,7 +26,7 @@ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - +