[open-ils-commits] [GIT] Evergreen ILS branch rel_3_2 updated. c208e63a33a61e318d3e5bc0a73e2eae97ad7b5f

Evergreen Git git at git.evergreen-ils.org
Thu Jul 18 12:39:40 EDT 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_3_2 has been updated
       via  c208e63a33a61e318d3e5bc0a73e2eae97ad7b5f (commit)
       via  144865c702e33534df1608ca34ad7e57b0cdfb33 (commit)
      from  fc6447abab352f131c6c863c3f51d19cf5cd74c2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c208e63a33a61e318d3e5bc0a73e2eae97ad7b5f
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Wed Jul 3 17:53:01 2019 -0400

    LP#1777207: teach egGrid how to prepend rows more efficiently
    
    The checkin and checkout grids in the AngularJS client have
    been doing full grid refreshes when adding a checkin or
    checkout to their respective grids. While this does not
    result in re-fetching data for the loans that were already
    processed, as more entries get added to the grid the time
    it takes to do a full digest of the grid contents during a
    egGrid.collect() (which empties the list of displayed rows,
    then refills it), gets progressively longer. Grids that have
    only ~40 entries have been observed to take several seconds
    purely on the AngularJS rendering phase.
    
    This patch teaches egGrid a new prepend() method that
    takes the first element from the underlying data source and
    unshifts it onto the list of displayed grid rows, saving much
    rendering time. The prepend() method will also force the
    grid offset back to 0 if it isn't already. Note that if
    an item that would be added via prepend() might duplicate an
    existing row entry, prepend() will do a full collect() instead.
    
    If the data source has sort options set, the prepend() will
    remove them. For arrayNotifier-based data sources, as are used
    in the checkin and checkout grids, this means that if the user
    sorts the contents of the grid, then does a circ transaction,
    the new transaction will still appear at the top of the list.
    Due to the way arrayNotifier currently works, the remaining
    entries will retain their previous ordering.
    
    As an implementation note, prepend() is likely going to work
    /only/ for arrayNotifier grid data sources.
    
    To test
    -------
    [1] In the checkin grid, check in a large number of items.
        Note that the time it takes to each each item gets
        progressively longer.
    [2] Apply the patch and repeat step 1. This time, the time
        for each checkin should not significantly vary.
    [3] Verify that column sorting works as expected.
    [4] Upon sorting the grid, do more checkins and note that
        the new transactions show up at the top.
    [5] Verify that the checkout grid continues to behave as expected.
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>

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 6d71f6c6dd..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
@@ -233,9 +233,13 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
                     {already_checked_in : final_resp.evt.copy_barcode};
             }
 
-            if ($scope.trim_list && checkinSvc.checkins.length > 20)
+            if ($scope.trim_list && checkinSvc.checkins.length > 20) {
                 //cut array short at 20 items
                 checkinSvc.checkins.length = 20;
+                checkinGrid.prepend(20);
+            } else {
+                checkinGrid.prepend();
+            }
         },
         function() {
             // Checkin was rejected somewhere along the way.
@@ -249,9 +253,7 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
             checkinSvc.checkins.splice(pos, 1);
 
         })['finally'](function() {
-
-            // when all is said and done, refresh the grid and refocus
-            checkinGrid.refresh();
+            // when all is said and done, refocus
             $scope.focusMe = true;
         });
     }
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 f3df2d8ace..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.refresh();
+        $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 9ee646a47c..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,6 +339,10 @@ angular.module('egGridMod',
                     grid.collect();
                 }
 
+                controls.prepend = function(limit) {
+                    grid.prepend(limit);
+                }
+
                 controls.setLimit = function(limit,forget) {
                     grid.limit = limit;
                     if (!forget && grid.persistKey) {
@@ -360,6 +364,7 @@ angular.module('egGridMod',
                 }
 
                 grid.dataProvider.refresh = controls.refresh;
+                grid.dataProvider.prepend = controls.prepend;
                 grid.controls = controls;
             }
 
@@ -1322,6 +1327,72 @@ angular.module('egGridMod',
                 });
             }
 
+            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 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
+                    // offset back to zero to display the top
+                    // of the list
+                    grid.offset = 0;
+                    grid.collect();
+                    return;
+                }
+                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,
+                function(item) {
+                    if (item) {
+                        var newIdx = grid.indexValue(item);
+                        angular.forEach($scope.items, function(existing) {
+                            if (grid.indexValue(existing) == newIdx) {
+                                console.debug('egGrid.prepend(): refusing to add duplicate item ' + newIdx);
+                                ran_into_duplicate = true;
+                                return;
+                            }
+                        });
+                        $scope.items.unshift(item);
+                        if (limit && $scope.items.length > limit) {
+                            // this accommodates the checkin grid that
+                            // allows the user to set a definite limit
+                            // without requiring that entire collect()
+                            $scope.items.length = limit;
+                        }
+                        if ($scope.items.length > grid.limit) {
+                            $scope.items.length = grid.limit;
+                        }
+                        if (grid.controls.itemRetrieved)
+                            grid.controls.itemRetrieved(item);
+                        if ($scope.selectAll)
+                            $scope.selected[grid.indexValue(item)] = true
+                    }
+                }).finally(function() {
+                    console.debug('egGrid.prepend() complete');
+                    grid.collecting = false;
+                    $scope.selected = angular.copy($scope.selected);
+                    if (ran_into_duplicate) {
+                        grid.collect();
+                    }
+                });
+            }
+
             grid.init();
         }]
     };
@@ -1912,6 +1983,7 @@ angular.module('egGridMod',
             // Calls the grid refresh function.  Once instantiated, the
             // grid will replace this function with it's own refresh()
             gridData.refresh = function(noReset) { }
+            gridData.prepend = function(limit) { }
 
             if (!gridData.get) {
                 // returns a promise whose notify() delivers items

commit 144865c702e33534df1608ca34ad7e57b0cdfb33
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Tue Jul 9 14:43:18 2019 -0400

    LP#1777207: have eg-grid generate DOM nodes only for visible columns
    
    This patch changes an ng-show to an ng-if to generate DOM nodes
    for grid cells only for visible columns. Prior to this patch, all
    grid cells were generated, but the ones that corresponded to hidden
    columns would simply be set as hidden.
    
    By not generating the cells unless they're meant to be visible, grid
    refreshes for wide grids (like the checkin table) render much more
    quickly for a couple reasons:
    
    - simply that there are fewer DOM nodes to process
    - probably more importantly, fewer AngularJS watches get
      created
    
    To test
    -------
    [1] In the checkin grid, check in a large number of items, then
        observe/profile timing as you change the number of visible rows.
    [2] Apply the patch and repeat step 1. This time, the grid
        refreshe should be measurably (and visibly) faster.
    [3] Test other AngularJS grids and verify that grid display and
        grid actions are normal.
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>

diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2
index 4d90a48408..73850e028c 100644
--- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2
+++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2
@@ -324,7 +324,7 @@
           ng-repeat="col in columns"
           ng-class="col.cssSelector"
           style="text-align:{{col.align}}; flex:{{col.flex}}"
-          ng-show="col.visible">
+          ng-if="col.visible">
 
           <!-- if the cell comes with its own template,
                translate that content into HTML and insert it here -->

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/templates/staff/share/t_autogrid.tt2  |  2 +-
 .../web/js/ui/default/staff/circ/checkin/app.js    | 10 +--
 .../js/ui/default/staff/circ/patron/checkout.js    |  2 +-
 Open-ILS/web/js/ui/default/staff/services/grid.js  | 72 ++++++++++++++++++++++
 4 files changed, 80 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list