Acq: Make the distribution formula UI page like it was supposed to
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 27 Oct 2010 14:52:36 +0000 (14:52 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 27 Oct 2010 14:52:36 +0000 (14:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@18489 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm
Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js

index 34b61a6..8a4d2e7 100644 (file)
@@ -456,13 +456,19 @@ __PACKAGE__->register_method(
         desc => 'Ranged distribution formulas, fleshed with entries',
         params => [
             {desc => 'Authentication token', type => 'string'},
+            {desc => "offset", type => "number"},
+            {desc => "limit", type => "number"}
         ],
         return => {desc => 'List of distribution formulas'}
     }
 );
 
 sub ranged_distrib_formulas {
-    my($self, $conn, $auth, $org) = @_;
+    my ($self, $conn, $auth, $offset, $limit) = @_;
+
+    $offset ||= 0;
+    $limit ||= 10;
+
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
     my $orgs = $U->user_has_work_perm_at($e, 'CREATE_PICKLIST', {descendants =>1});
@@ -472,9 +478,11 @@ sub ranged_distrib_formulas {
         {
             flesh => 1, 
             flesh_fields => {acqdf => ['entries']},
-            order_by => {acqdfe => ['position']}
+            order_by => {acqdf => "name"},
+            limit => $limit,
+            offset => $offset
         }
-    ]);
+    ]) or return $e->die_event;
 
     for (@$forms) {
 
index b992d26..69e3932 100644 (file)
@@ -8,12 +8,35 @@ dojo.requireLocalization('openils.conify', 'conify');
 var localeStrings = dojo.i18n.getLocalization('openils.conify', 'conify');
 
 
-var formCache = [];
+var formCache = {};
 var formula, entryTbody, entryTemplate, dndSource;
 var virtualId = -1;
 var pcrud;
 
 
+function gridDataLoader() {
+    fListGrid.resetStore();
+    fListGrid.showLoadProgressIndicator();
+    fieldmapper.standardRequest(
+        ["open-ils.acq", "open-ils.acq.distribution_formula.ranged.retrieve"], {
+            "async": true,
+            "params": [
+                openils.User.authtoken,
+                fListGrid.displayOffset,
+                fListGrid.displayLimit
+            ],
+            "onresponse": function(r) {
+                var form = openils.Util.readResponse(r);
+                formCache[form.id()] = form;
+                fListGrid.store.newItem(form.toStoreItem());
+            },
+            "oncomplete": function() {
+                fListGrid.hideLoadProgressIndicator();
+            }
+        }
+    );
+}
+
 function draw() {
 
     pcrud = new openils.PermaCrud();
@@ -28,21 +51,8 @@ function draw() {
             location.href = location.href + '/' + fmObject.id();
         }
 
-        fieldmapper.standardRequest(
-            ['open-ils.acq', 'open-ils.acq.distribution_formula.ranged.retrieve'],
-            {   async: true,
-                params: [openils.User.authtoken],
-                onresponse: function (r) { 
-                    var form = openils.Util.readResponse(r);
-                    formCache[form.id()] = form;
-                    fListGrid.store.newItem(form.toStoreItem());
-                },
-                oncomplete: function() {
-                    fListGrid.hideLoadProgressIndicator();
-                }
-            }
-        );
-
+        fListGrid.dataLoader = gridDataLoader;
+        gridDataLoader();
     }
 }