LP#1739648 - fix grid nextPage button by setting grid.totalCount
authorCesar Velez <cesar.velez@equinoxinitiative.org>
Mon, 8 Jan 2018 21:55:56 +0000 (16:55 -0500)
committerMike Rylander <mrylander@gmail.com>
Mon, 12 Feb 2018 20:41:51 +0000 (15:41 -0500)
This wires up the grid.totalCount in the implemented DataProvider's
get method, which allows us to properly disable the next page button
for when we know there's no more data.

Signed-off by: Cesar Velez <cesar.velez@equinoxinitiative.org>

Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/staff/share/t_autogrid.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/holds.js
Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js
Open-ILS/web/js/ui/default/staff/services/grid.js

index 941aa63..c6b45d9 100644 (file)
@@ -84,6 +84,7 @@
     <button type="button" class="btn btn-default" 
       ng-show="showPagination"
       ng-class="{disabled : !hasNextPage()}"
+      ng-disabled="!hasNextPage()"
       ng-click="incrementPage()"
       title="[% l('Next Page') %]">
         <span class="glyphicon glyphicon-forward"></span>
index 6d017d4..c3ce75b 100644 (file)
@@ -90,7 +90,14 @@ function($scope,  $q,  $routeParams,  egCore,  egUser,  patronSvc,
             egCore.auth.token(), $scope.patron_id
 
         ).then(function(hold_ids) {
-            if (!hold_ids.length || hold_ids.length < offset + 1) { deferred.resolve(); return; }
+            
+            if (!hold_ids.length || hold_ids.length < offset + 1)
+            {
+                deferred.resolve();
+                return;
+            }
+
+            $scope.gridDataProvider.grid.totalCount = hold_ids.length;
 
             patronSvc.hold_ids = hold_ids;
             fetchHolds(offset, count)
index daf0041..777900a 100644 (file)
@@ -261,7 +261,7 @@ function($scope,  $q,  $routeParams,  $timeout,  egCore , egUser,  patronSvc , $
         get_circ_ids().then(function() {
 
             id_list = $scope[$scope.items_out_display + '_list'];
-
+            $scope.gridDataProvider.grid.totalCount = id_list.length;
             // relay the notified circs back to the grid through our promise
             fetch_circs(id_list, offset, count).then(
                 deferred.resolve, null, deferred.notify);
index 266a972..7144970 100644 (file)
@@ -178,6 +178,9 @@ angular.module('egGridMod',
                 delete $scope.idField;
 
                 grid.dataProvider = $scope.itemsProvider;
+                // make grid ref available in get() to set totalCount, if known.
+                // this allows us disable the 'next' paging button correctly
+                grid.dataProvider.grid = grid;
 
                 if (!grid.indexField && grid.idlClass)
                     grid.indexField = egCore.idl.classes[grid.idlClass].pkey;