From: Mike Rylander Date: Wed, 20 May 2020 21:13:36 +0000 (-0400) Subject: LP#1758381: Force copy bucket pending list to scan order X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fmiker%2Flp-1758381-copy-bucket-pending-order;p=working%2FEvergreen.git LP#1758381: Force copy bucket pending list to scan order The order of rows in the pending list of copy buckets is currently undefined and, due to the way the query is constructed, looks random. This commit adds the ability to force a specific order on the contents of a grid and uses that ability to match the grid row order to the scan order. Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js index bebb642c56..17cf34b3b9 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js @@ -393,6 +393,9 @@ function($scope, $routeParams, bucketSvc , egGridDataProvider, egCore) { var query; $scope.gridControls = { + forceOrder : function () { + return { field : 'id', order : bucketSvc.pendingList }; + }, setQuery : function(q) { if (bucketSvc.pendingList.length) return {id : bucketSvc.pendingList}; @@ -485,8 +488,11 @@ function($scope, $routeParams, bucketSvc , egGridDataProvider, egCore) { {} ).then(function(copy) { if (copy) { - bucketSvc.pendingList.push(copy.id()); - $scope.gridControls.setQuery({id : bucketSvc.pendingList}); + var seen = bucketSvc.pendingList.filter(function (e) { return e == copy.id()}).length; + if (!seen) { + bucketSvc.pendingList.push(copy.id()); + $scope.gridControls.setQuery({id : bucketSvc.pendingList}); + } bucketSvc.barcodeString = ''; // clear form on valid copy } else { $scope.context.itemNotFound = true; 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 ce84caa657..0b8f24cd4f 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -1339,6 +1339,24 @@ angular.module('egGridMod', $scope.selected[grid.indexValue(item)] = true } }).finally(function() { + if (grid.controls.forceOrder) { + var f = grid.controls.forceOrder().field; + var o = grid.controls.forceOrder().order; + var ordered_items = []; + angular.forEach(o, function(v) { + ov = $scope.items.filter(function (i) { + var test_val = i[f]; + if (angular.isFunction(test_val)) { + test_val = i[f](); + } + return v == test_val; + }); + if (ov && angular.isArray(ov)) { + ordered_items.push(ov[0]) + } + }); + $scope.items = ordered_items; + } console.debug('egGrid.collect() complete'); grid.collecting = false $scope.selected = angular.copy($scope.selected);