Acq+Vandelay : skip unneeded vandeley forms
authorBill Erickson <berick@esilibrary.com>
Wed, 29 Feb 2012 22:34:14 +0000 (17:34 -0500)
committerBen Shum <bshum@biblio.org>
Tue, 13 Mar 2012 19:28:49 +0000 (15:28 -0400)
If all lineitems in question are linked to catalog records, avoid
showing the unnecessary vandelay form.  This was already true from the
PO activation action, but this patch adds the same check to the
create-po action from a selection list and PO 'load bibs and items'.

Minor label change for consistency in li_table (Queue -> queue).

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/po/view_po.js

index 3a23351..3628b88 100644 (file)
                                         <span name='po' class='hidden'> | <a title='Purchase Order' name='po_link' href='javascript:void(0);'>&#x2318; </a></span>
                                         <span name="show_requests"> | <a title='Patron Requests' name="show_requests_link" href="javascript:void(0);">requests</a></span> 
                                         <span name='pro' class='hidden'> | <a title='[% l('Provider') %]' name='pro_link' href='javascript:void(0);'>&#x235F; </a></span>
-                                        <span name='queue' class='hidden'> | <a title='[% l('Import Queue') %]' name='queue_link' href='javascript:void(0);'>&#x27AC; Queue</a></span>
+                                        <span name='queue' class='hidden'> | <a title='[% l('Import Queue') %]' name='queue_link' href='javascript:void(0);'>[% l('&#x27AC; queue') %]</a></span>
                                     </td>
                                 </tr>
                             </tbody>
index f2585a1..860f82a 100644 (file)
@@ -2124,21 +2124,40 @@ function AcqLiTable() {
 
     this.showAssetCreator = function(onAssetsCreated) {
         if(!this.isPO) return;
-        this.show('asset-creator');
-        if(!this.vlAgent.loaded)
-            this.vlAgent.init();
         var self = this;
-        dojo.connect(assetCreatorButton, 'onClick', 
-            function() { self.createAssets(onAssetsCreated) });
+    
+        // first, let's see if this PO has any LI's that need to be merged/imported
+        self.pcrud.search('jub', {purchase_order : this.isPO, eg_bib_id : null}, {
+            id_list : true,
+            oncomplete : function(r) {
+                var resp = openils.Util.readResponse(r);
+                if (resp && resp.length) {
+                    // PO has some non-linked jubs.  
+                    
+                    self.show('asset-creator');
+                    if(!self.vlAgent.loaded)
+                        self.vlAgent.init();
+
+                    dojo.connect(assetCreatorButton, 'onClick', 
+                        function() { self.createAssets(onAssetsCreated) });
+
+                } else {
+
+                    // all jubs linked, move on to asset creation
+                    self.createAssets(onAssetsCreated, true); 
+                }
+            }
+        });
     }
 
-    this.createAssets = function(onAssetsCreated) {
+    this.createAssets = function(onAssetsCreated, noVl) {
         this.show('acq-lit-progress-numbers');
         var self = this;
+        var vlArgs = (noVl) ? {} : {vandelay : this.vlAgent.values()};
         fieldmapper.standardRequest(
             ['open-ils.acq', 'open-ils.acq.purchase_order.assets.create'],
             {   async: true,
-                params: [this.authtoken, this.isPO, {vandelay : this.vlAgent.values()}],
+                params: [this.authtoken, this.isPO, vlArgs],
                 onresponse: function(r) {
                     var resp = openils.Util.readResponse(r);
                     self._updateProgressNumbers(resp, !Boolean(onAssetsCreated), onAssetsCreated);
index 6c08ce1..07c29e7 100644 (file)
@@ -513,19 +513,7 @@ function activatePo() {
             return false;
     }
 
-    // first, let's see if this PO has any LI's that need to be merged/imported
-    pcrud.search('jub', {purchase_order : poId, eg_bib_id : null}, {
-        id_list : true,
-        oncomplete : function(r) {
-            var resp = openils.Util.readResponse(r);
-            if (resp && resp.length) {
-                // kick off the merge/import process
-                liTable.showAssetCreator(activatePoStage2);
-            } else {
-                activatePoStage2();
-            }
-        }
-    });
+    liTable.showAssetCreator(activatePoStage2);
 }
 
 function activatePoStage2() {