[open-ils-commits] r12891 - in trunk/Open-ILS/web: js/ui/default/acq/common templates/default/acq/common (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 16 10:56:05 EDT 2009


Author: erickson
Date: 2009-04-16 10:56:01 -0400 (Thu, 16 Apr 2009)
New Revision: 12891

Modified:
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
use new receive response types.  cleaned up some progress handling

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2009-04-16 14:54:40 UTC (rev 12890)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2009-04-16 14:56:01 UTC (rev 12891)
@@ -494,7 +494,7 @@
     this.createAssets = function() {
         if(!this.isPO) return;
         if(!confirm(localeStrings.CREATE_PO_ASSETS_CONFIRM)) return;
-        this.show('acq-lit-create-po-progress');
+        this.show('acq-lit-progress-numbers');
         var self = this;
         fieldmapper.standardRequest(
             ['open-ils.acq', 'open-ils.acq.purchase_order.assets.create'],
@@ -502,17 +502,7 @@
                 params: [this.authtoken, this.isPO],
                 onresponse: function(r) {
                     var resp = openils.Util.readResponse(r);
-                    if(!resp) return;
-                    dojo.byId('acq-pl-lit-li-processed').innerHTML = resp.li;
-                    dojo.byId('acq-pl-lit-lid-processed').innerHTML = resp.lid;
-                    dojo.byId('acq-pl-lit-debits-processed').innerHTML = resp.debits_accrued;
-                    dojo.byId('acq-pl-lit-bibs-processed').innerHTML = resp.bibs;
-                    dojo.byId('acq-pl-lit-indexed-processed').innerHTML = resp.indexed;
-                    dojo.byId('acq-pl-lit-copies-processed').innerHTML = resp.copies;
-                    if(resp.complete) {
-                        openils.Util.hide('acq-lit-create-po-progress');
-                        self.show('list');
-                    }
+                    self._updateProgressNumbers(resp, true);
                 }
             }
         );
@@ -529,7 +519,7 @@
                     progressDialogInd.hide();
                     var evt = openils.Util.readResponse(r);
                     if(evt && evt.template_output()) {
-                        win = window.open('','', 'resizable,width=700,height=500,scrollbars=1');
+                        win = window.open('','', 'resizable,width=800,height=600,scrollbars=1');
                         win.document.body.innerHTML = evt.template_output().data();
                     }
                 }
@@ -540,34 +530,35 @@
 
     this.receivePO = function() {
         if(!this.isPO) return;
-        progressDialog.show();
-        var maximum = 1;
-        dojo.forEach(this.liCache, function(){maximum += 1; });
-        dojo.forEach(this.copyCache, function(){maximum += 1; });
+        this.show('acq-lit-progress-numbers');
+        var self = this;
         fieldmapper.standardRequest(
             ['open-ils.acq', 'open-ils.acq.purchase_order.receive'],
             {   async: true,
                 params: [this.authtoken, this.isPO],
                 onresponse : function(r) {
-                    var stat = openils.Util.readResponse(r);
-                    
-                    // we don't know the total amount of items to be processed
-                    // since we only have 1 page of data
-                    if(stat.progress > maximum) maximum *= 2;
-
-                    progressDialog.update({maximum:maximum, progress:stat.progress});
-                    if(stat.complete) {
-                        // XXX
-                        location.href = location.href;
-                    }
+                    var resp = openils.Util.readResponse(r);
+                    self._updateProgressNumbers(resp, true);
                 },
             }
         );
     }
 
+    this._updateProgressNumbers = function(resp, reloadOnComplete) {
+        if(!resp) return;
+        dojo.byId('acq-pl-lit-li-processed').innerHTML = resp.li;
+        dojo.byId('acq-pl-lit-lid-processed').innerHTML = resp.lid;
+        dojo.byId('acq-pl-lit-debits-processed').innerHTML = resp.debits_accrued;
+        dojo.byId('acq-pl-lit-bibs-processed').innerHTML = resp.bibs;
+        dojo.byId('acq-pl-lit-indexed-processed').innerHTML = resp.indexed;
+        dojo.byId('acq-pl-lit-copies-processed').innerHTML = resp.copies;
+        if(resp.complete && reloadOnComplete) 
+            location.href = location.href;
+    }
 
+
     this._createPO = function(fields) {
-        this.show('acq-lit-create-po-progress');
+        this.show('acq-lit-progress-numbers');
         var po = new fieldmapper.acqpo();
         po.provider(this.createPoProviderSelector.attr('value'));
 
@@ -576,6 +567,7 @@
 
         var max = selected.length * 3;
 
+        var self = this;
         fieldmapper.standardRequest(
             ['open-ils.acq', 'open-ils.acq.purchase_order.create'],
             {   async: true,
@@ -590,13 +582,7 @@
 
                 onresponse : function(r) {
                     var resp = openils.Util.readResponse(r);
-                    if(!resp) return;
-                    dojo.byId('acq-pl-lit-li-processed').innerHTML = resp.li;
-                    dojo.byId('acq-pl-lit-lid-processed').innerHTML = resp.lid;
-                    dojo.byId('acq-pl-lit-debits-processed').innerHTML = resp.debits_accrued;
-                    dojo.byId('acq-pl-lit-bibs-processed').innerHTML = resp.bibs;
-                    dojo.byId('acq-pl-lit-indexed-processed').innerHTML = resp.indexed;
-                    dojo.byId('acq-pl-lit-copies-processed').innerHTML = resp.copies;
+                    self._updateProgressNumbers(resp);
                     if(resp.complete) 
                         location.href = oilsBasePath + '/eg/acq/po/view/' + resp.purchase_order.id();
                 }

Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2009-04-16 14:54:40 UTC (rev 12890)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2009-04-16 14:56:01 UTC (rev 12891)
@@ -192,7 +192,7 @@
         </table>
     </div>
 
-    <div class='hidden' id='acq-lit-create-po-progress'>
+    <div class='hidden' id='acq-lit-progress-numbers'>
         <table class='oils-generic-table'>
             <tbody>
                 <tr>
@@ -216,7 +216,7 @@
                     <td><span id='acq-pl-lit-indexed-processed'>0</span></td>
                 </tr>
                 <tr>
-                    <td>Copies Created</td>
+                    <td>Copies Processed</td>
                     <td><span id='acq-pl-lit-copies-processed'>0</span></td>
                 </tr>
             </tbody>



More information about the open-ils-commits mailing list