Modify copy browser to check for bib_source.can_have_copies.
authorJason Stephenson <jstephenson@mvlc.org>
Tue, 4 Oct 2011 14:29:23 +0000 (10:29 -0400)
committerDan Scott <dscott@laurentian.ca>
Mon, 5 Dec 2011 18:25:54 +0000 (13:25 -0500)
Add code to server/cat/copy_browser.js.
Add error string to server/local/en-US/cat.properties.
Swap obj. for g. that was copied from opac.js.

Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/xul/staff_client/server/cat/copy_browser.js
Open-ILS/xul/staff_client/server/locale/en-US/cat.properties

index d234f37..90cad41 100644 (file)
@@ -34,6 +34,8 @@ cat.copy_browser.prototype = {
 
             obj.list_init(params);
 
+            obj.source_init();
+
             obj.controller.render();
 
             obj.default_depth = obj.depth_menu_init();
@@ -339,6 +341,11 @@ cat.copy_browser.prototype = {
 
                                     if (edit==0) return; // no read-only view for this interface
 
+                                    if (!obj.can_have_copies) {
+                                        alert(document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.can_have_copies.false', obj.source));
+                                        return;
+                                    }
+
                                     var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.title');
 
                                     var url;
@@ -633,6 +640,11 @@ cat.copy_browser.prototype = {
                                         return; // no read-only view for this interface
                                     }
 
+                                    if (!obj.can_have_copies) {
+                                        alert(document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.can_have_copies.false', obj.source));
+                                        return;
+                                    }
+
                                     var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.title');
 
                                     var url;
@@ -1839,6 +1851,29 @@ cat.copy_browser.prototype = {
         }
     },
 
+    // Sets can_have_copies and source member variables.
+    'source_init' : function() {
+        var obj = this;
+        try {
+            var bibObj = obj.network.request(
+                api.FM_BRE_RETRIEVE_VIA_ID.app,
+                api.FM_BRE_RETRIEVE_VIA_ID.method,
+                [ ses(), [obj.docid] ]
+            );
+            bibObj = bibObj[0];
+            var cbsObj = obj.network.request(
+                api.FM_CBS_RETRIEVE_VIA_PCRUD.app,
+                api.FM_CBS_RETRIEVE_VIA_PCRUD.method,
+                [ ses(), bibObj.source() ]
+            );
+            obj.can_have_copies = (cbsObj.can_have_copies() == get_db_true());
+            obj.source = cbsObj.source();
+        } catch(E) {
+            obj.error.sdump('D_ERROR','can have copies check: ' + E);
+            alert(E);
+        }
+    },
+
     'toggle_actions' : function() {
         var obj = this;
         try {
index 3e8b411..f8ac40c 100644 (file)
@@ -50,6 +50,7 @@ staff.cat.edit_volume.title=Volume
 staff.cat.edit_volume.title.plural=Volumes
 staff.cat.edit_volumes.override.confirm=Override volume re-labeling collision and merge the volumes?
 staff.cat.edit_volumes.label_exists.details=%1$s
+staff.cat.copy_browser.can_have_copies.false=Records from %1$s cannot have copies.
 staff.cat.copy_browser.delete_volume.prompt=Are you sure you would like to delete this volume?
 staff.cat.copy_browser.delete_volume.prompt.plural=Are you sure you would like to delete these %1$s volumes?
 staff.cat.copy_browser.delete_volume.title=Delete Volumes?