Check for bib_source.can_have_copies in cataloging.
authorJason Stephenson <jstephenson@mvlc.org>
Sat, 1 Oct 2011 16:02:16 +0000 (12:02 -0400)
committerDan Scott <dscott@laurentian.ca>
Mon, 5 Dec 2011 18:25:39 +0000 (13:25 -0500)
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 <jstephenson@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>

Open-ILS/xul/staff_client/chrome/content/cat/opac.js
Open-ILS/xul/staff_client/chrome/content/cat/opac.xul
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties

index 92d4dcc..a07b9a4 100644 (file)
@@ -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;
index b7d517f..2d775d3 100644 (file)
@@ -26,7 +26,7 @@
         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
     </script>
         <scripts id="openils_util_scripts"/>
-
+<script type="text/javascript" src="chrome://openils_staff_client/content/OpenILS/util/fmall.js"/>
     <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/JSAN.js"/>
     <script type="text/javascript" src="chrome://open_ils_staff_client/content/cat/opac.js"/>
     
index 1de4e6c..f7ecfe0 100644 (file)
@@ -228,6 +228,7 @@ var api = {
     'FM_BRE_DELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.delete', 'secure' : false },
     'FM_BRE_UNDELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.undelete', 'secure' : false },
     'FM_BRN_FROM_MARCXML' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.marcxml_to_brn', 'secure' : false },
+    'FM_CBS_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.retrieve.cbs' },
     'FM_CBT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.billing_type.ranged.retrieve.all', 'secure' : false },
     'FM_CCS_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.config.copy_status.retrieve.all', 'secure' : false },
     'FM_CIRC_AGE_TO_LOST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.age_to_lost' },
index ca7eedf..eaef490 100644 (file)
@@ -280,6 +280,7 @@ staff.cat.opac.title_for_hold_transfer.failure.label=Holds not transferred.
 staff.cat.opac.related_items=Related Lineitems
 staff.cat.opac.serial_alt_mgmt=Subscriptions
 staff.cat.create_or_rebarcode_items=Create or Re-barcode Items
+staff.cat.bib_source.can_have_copies.false=Records from %1$s cannot have copies.
 printing.nothing_to_reprint=Nothing to re-print
 printing.prompt_for_external_print_cmd=Enter external print command and parameters (use %receipt.txt% or %receipt.html% as the file containing the print data. Those values will be substituted with the proper path.):
 printing.print_strategy_saved=Print strategy (%1$s) for %2$s context saved to file system.