From: Galen Charlton Date: Fri, 12 Jul 2019 15:08:29 +0000 (-0400) Subject: LP#1777207: teach prepend() how to reset sorting X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=92e70b58d34b141fd0453b85a2af7f2d973cea4e;p=working%2FEvergreen.git LP#1777207: teach prepend() how to reset sorting This patch gives prepend() an option to reset the sort order (and offset) and makes the checkin and checkout grids use that option. The purpose of this is to retain the performance benefit of prepend(), as otherwise prepend() will do a full collect() when a sort order is in effect. On the checkin and checkout grids, due to a quirk of how sorting in arrayNotifier-based data sources work, the grids will behave like this: - User processes a bunch of items, with each new one showing up at the top of the list - User sorts the grid to look at something - User processes another item. A collect() happens. The new item will show up at the top of the list, with the remaining items following the previous sort order. - User processes more items; the prepending will coninue and remain fast. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js index 965529b4c5..120690a7ee 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -236,9 +236,9 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg if ($scope.trim_list && checkinSvc.checkins.length > 20) { //cut array short at 20 items checkinSvc.checkins.length = 20; - checkinGrid.prepend(20); + checkinGrid.prepend(true, 20); } else { - checkinGrid.prepend(); + checkinGrid.prepend(true); } }, function() { diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js index d79811c705..cc0f82c5da 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js @@ -189,7 +189,7 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc , }; $scope.checkouts.unshift(row_item); - $scope.gridDataProvider.prepend(); + $scope.gridDataProvider.prepend(true); egCore.hatch.setItem('circ.checkout.strict_barcode', $scope.strict_barcode); var options = {check_barcode : $scope.strict_barcode}; diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index 0d2ce9b677..e4bc86a183 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -339,8 +339,8 @@ angular.module('egGridMod', grid.collect(); } - controls.prepend = function(limit) { - grid.prepend(limit); + controls.prepend = function(resetSort, limit) { + grid.prepend(resetSort, limit); } controls.setLimit = function(limit,forget) { @@ -1327,7 +1327,7 @@ angular.module('egGridMod', }); } - grid.prepend = function(limit) { + grid.prepend = function(resetSort, limit) { var ran_into_duplicate = false; var sort = grid.dataProvider.sort; if (sort && sort.length) { @@ -1336,6 +1336,10 @@ angular.module('egGridMod', // was most recently added nor that it // belongs on top of the visible set of rows, // so we default to a full collect() + if (resetSort) { // and offset + grid.dataProvider.sort = []; + grid.offset = 0; + } grid.collect(); return; }