CAT-207 XUL catalog Update Items fix
authorKatlyn Beck <kbeck@catalyte.io>
Tue, 26 Feb 2019 21:44:14 +0000 (21:44 +0000)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:51:45 +0000 (15:51 -0400)
- Added missing update_items function

Signed-off-by: Katlyn Beck <kbeck@catalyte.io>
 Changes to be committed:
modified:   Open-ILS/xul/staff_client/chrome/content/cat/opac.js

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/xul/staff_client/chrome/content/cat/opac.js

index 3b8a8cf..a4d58c4 100644 (file)
@@ -362,6 +362,69 @@ function open_acq_orders() {
     }
 }
 
+function update_items(){
+    try {
+        var edit = 0;
+        try {
+            edit = g.network.request(
+                api.PERM_MULTI_ORG_CHECK.app,
+                api.PERM_MULTI_ORG_CHECK.method,
+                [ 
+                    ses(), 
+                    ses('staff_id'), 
+                    [ ses('ws_ou') ],
+                    [ 'UPDATE_ITEMS' ]
+                ]
+            ).length == 0 ? 1 : 0;
+        } catch(E) {
+            g.error.sdump('D_ERROR','batch permission check: ' + E);
+        }
+
+        if (edit==0) {
+            alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
+            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 && 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, update_items(): ' + E);
+            return;
+        }
+
+        var title = document.getElementById('offlineStrings').getFormattedString('staff.cat.update_items.title', [docid]);
+
+        var url = window.xulG.url_prefix( 'XUL_UPDATE_ITEMS' );
+               
+        var w = xulG.new_tab(
+            url,
+            { 'tab_name' : title },
+            { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ], 'reload_opac' : xulG.reload_opac }
+        );
+    } catch(E) {
+        alert('Error in chrome/content/cat/opac.js, update_items(): ' + E);
+    }
+}
+
 function open_alt_serial_mgmt() {
     try {
         var content_params = {