From 639bfcf6455e768dd0cebd46ef00c1faea512386 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 18 Jul 2019 11:27:35 -0400 Subject: [PATCH] LP#1777207: more tweaks [1] Reset sort options during a prepend() is now unconditional. [2] Removed a grid.collect() that's unnecessary under certain circumstances. [3] Edited the comments. Signed-off-by: Galen Charlton --- .../web/js/ui/default/staff/circ/checkin/app.js | 4 +-- .../js/ui/default/staff/circ/patron/checkout.js | 2 +- Open-ILS/web/js/ui/default/staff/services/grid.js | 29 +++++++++++----------- 3 files changed, 18 insertions(+), 17 deletions(-) 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 120690a7ee..965529b4c5 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(true, 20); + checkinGrid.prepend(20); } else { - checkinGrid.prepend(true); + checkinGrid.prepend(); } }, 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 cc0f82c5da..d79811c705 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(true); + $scope.gridDataProvider.prepend(); 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 e4bc86a183..3998abba1e 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(resetSort, limit) { - grid.prepend(resetSort, limit); + controls.prepend = function(limit) { + grid.prepend(limit); } controls.setLimit = function(limit,forget) { @@ -1327,21 +1327,18 @@ angular.module('egGridMod', }); } - grid.prepend = function(resetSort, limit) { + grid.prepend = function(limit) { var ran_into_duplicate = false; var sort = grid.dataProvider.sort; if (sort && sort.length) { - // if sorting is in effect, we have no - // have no way here of knowing which row - // 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; + // If sorting is in effect, we have no way + // of knowing that the new item should be + // visible _if the sort order is retained_. + // However, since the grids that do prepending in + // the first place are ones where we always + // want the new row to show up on top, we'll + // remove the current sort options. + grid.dataProvider.sort = []; } if (grid.offset > 0) { // if we're prepending, we're forcing the @@ -1354,6 +1351,10 @@ angular.module('egGridMod', if (grid.collecting) return; // avoid parallel collect() or prepend() grid.collecting = true; console.debug('egGrid.prepend() starting'); + // Note that we can count on the most-recently added + // item being at offset 0 in the data provider only + // for arrayNotifier data sources that do not have + // sort options currently set. grid.dataProvider.get(0, 1).then( null, null, -- 2.11.0