Add Volumes shortcut in bib summary pane whenever that pane has a full xulG (which...
authorJason Etheridge <jason@esilibrary.com>
Fri, 18 Mar 2011 06:13:52 +0000 (02:13 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 18 Mar 2011 06:13:52 +0000 (02:13 -0400)
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/cat/opac.js
Open-ILS/xul/staff_client/server/cat/bib_brief.js
Open-ILS/xul/staff_client/server/cat/bib_brief.xul

index 855911a..49585ff 100644 (file)
 <!ENTITY staff.cat.bib_brief.title.label "Title:">
 <!ENTITY staff.cat.bib_brief.title.accesskey "">
 <!ENTITY staff.cat.bib_brief.view_marc "View MARC">
+<!ENTITY staff.cat.bib_brief.add_volumes "Add Volumes">
 <!ENTITY staff.cat.bib_brief.author.label "Author:">
 <!ENTITY staff.cat.bib_brief.author.accesskey "">
 <!ENTITY staff.cat.bib_brief.edition.label "Edition:">
index f815594..6dd549d 100644 (file)
@@ -89,18 +89,27 @@ function opac_wrapper_set_help_context() {
 function set_brief_view() {
     var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid); 
     dump('spawning ' + url + '\n');
+
+    var content_params = {
+        'set_tab_name' : function(n) {
+            if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+                try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
+            } else {
+                dump('no set_tab_name\n');
+            }
+        }
+    };
+
+    ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
+        "set_patron_tab", "volume_item_creator", "get_new_session",
+        "holdings_maintenance_tab", "open_chrome_window", "url_prefix",
+        "network_meter", "page_meter", "set_statusbar", "set_help_context"
+    ].forEach(function(k) { content_params[k] = xulG[k]; });
+
     top_pane.set_iframe( 
         url,
-        {}, 
-        { 
-            'set_tab_name' : function(n) { 
-                if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
-                    try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
-                } else {
-                    dump('no set_tab_name\n');
-                }
-            }
-        }  
+        {},
+        content_params
     );
 }
 
index b4e283e..f2328a4 100644 (file)
@@ -87,6 +87,14 @@ function my_init() {
     }
 }
 
+function unhide_add_volumes_button() {
+    if (xulG && typeof xulG == 'object' && typeof xulG['new_tab'] == 'function') {
+        document.getElementById('add_volumes').hidden = false;
+        document.getElementById('add_volumes_left_paren').hidden = false;
+        document.getElementById('add_volumes_right_paren').hidden = false;
+    }
+}
+
 function view_marc() {
     try {
         JSAN.use('util.window'); var win = new util.window();
@@ -114,4 +122,37 @@ function spawn_patron(span) {
     }
 }
 
+function add_volumes() {
+    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') ],
+                    [ 'CREATE_VOLUME', 'CREATE_COPY' ]
+                ]
+            ).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
+        }
+
+        var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
+
+        var w = xulG.new_tab(
+            window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
+            { 'tab_name' : title },
+            { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
+        );
+    } catch(E) {
+        alert('Error in server/cat/bib_brief.js, add_volumes(): ' + E);
+    }
+}
index 21c36c8..bce81b7 100644 (file)
@@ -22,7 +22,7 @@ vim: noet:sw=4:ts=4:
 <?xul-overlay href="/xul/server/cat/bib_brief_overlay.xul"?>
 
 <window id="cat_bib_brief_win" 
-    onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
+    onload="try { my_init(); font_helper(); persist_helper(); unhide_add_volumes_button(); } catch(E) { alert(E); }"
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
     <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
@@ -39,7 +39,13 @@ vim: noet:sw=4:ts=4:
     <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties"/>
 
     <groupbox id="groupbox" flex="1">
-        <caption id="caption"><label value="&staff.cat.bib_brief.record_summary;"/>(<label value="&staff.cat.bib_brief.view_marc;" class="click_link" onclick="view_marc();"/>)</caption>
+        <caption id="caption">
+            <label value="&staff.cat.bib_brief.record_summary;"/>
+            <label id="add_volumes_left_paren" value="(" hidden="true"/>
+            <label id="add_volumes" value="&staff.cat.bib_brief.add_volumes;" class="click_link" onclick="add_volumes();" hidden="true"/>
+            <label id="add_volumes_right_paren" value=")" hidden="true"/>
+            (<label value="&staff.cat.bib_brief.view_marc;" class="click_link" onclick="view_marc();"/>)
+        </caption>
         <grid id="bib_brief_grid" />
     </groupbox>