ACQ+Vandelay open picklist/PO/queue in new tab
authorBill Erickson <berick@esilibrary.com>
Wed, 8 Feb 2012 19:37:44 +0000 (14:37 -0500)
committerBen Shum <bshum@biblio.org>
Tue, 13 Mar 2012 19:28:07 +0000 (15:28 -0400)
In the staff client, after a file upload, if a picklist, queue, or PO
are created, make the links open their respective pages in new tabs.
When not running inside the staff client, allow the links be regular
href's.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/web/js/ui/default/acq/picklist/upload.js

index d857b62..667e272 100644 (file)
@@ -9,6 +9,7 @@ dojo.require("dojo.io.iframe");
 dojo.require('openils.User');
 dojo.require('openils.widget.AutoFieldWidget');
 dojo.require('openils.acq.Picklist');
+dojo.require('openils.XUL');
 
 var VANDELAY_URL = '/vandelay-upload';
 var providerWidget;
@@ -117,21 +118,28 @@ function acqHandlePostUpload(key, plId) {
                         openils.Util.hide('acq-pl-upload-progress-bar');
                         openils.Util.show('acq-pl-upload-complete');
 
+                        function activateLink(link, url, name) {
+                            link = dojo.byId(link);
+                            openils.Util.show(link);
+                            if (name) link.innerHTML = name;
+                            if (typeof xulG == 'undefined') { // browser
+                                link.setAttribute('href', url); 
+                            } else {
+                                link.setAttribute('href', 'javascript:;'); // for linky-ness
+                                link.onclick = function() { openils.XUL.newTabEasy(url) };
+                            }
+                        }
+                            
                         if(res.picklist_url) {
-                            openils.Util.show('acq-pl-upload-complete-pl');
-                            dojo.byId('acq-pl-upload-complete-pl').setAttribute('href', res.picklist_url);
+                            activateLink('acq-pl-upload-complete-pl', res.picklist_url);
                         } 
 
                         if(res.po_url) {
-                            openils.Util.show('acq-pl-upload-complete-po');
-                            dojo.byId('acq-pl-upload-complete-po').setAttribute('href', res.po_url);
+                            activateLink('acq-pl-upload-complete-po', res.po_url);
                         }
 
                         if (res.queue_url) {
-                            link = dojo.byId('acq-pl-upload-complete-q');
-                            openils.Util.show(link);
-                            link.setAttribute('href', res.queue_url);
-                            link.innerHTML = resp.queue.name();
+                            activateLink('acq-pl-upload-complete-q', res.queue_url, resp.queue.name());
                         }
                     }
                 );