From: Adam Bowling Date: Wed, 13 Feb 2019 17:40:17 +0000 (-0500) Subject: LP#1775870 Fixes random sort order for print labels, picking up the sort field X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fdpearl%2FLP1775870_print_label_order-signoff;p=working%2FEvergreen.git LP#1775870 Fixes random sort order for print labels, picking up the sort field specified by the user in the source grid supplying the copies. In the case that no sort field was clicked, copies are loaded into the label print interface in ascending order from oldest to newest entry on the source grid. This branch is dependent on the spine label customizations submitted in a=commit;h=ace4c873538c95459fdba5439a6167fe665551c1. Signed-off-by: Adam Bowling Signed-off-by: Dan Pearl --- 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 old mode 100644 new mode 100755 index 70eb084fd4..a900f267ef --- 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 @@ -586,24 +586,41 @@ function($scope, $q , $routeParams , $timeout , $window , $uibModal , bucketSvc }); } - $scope.print_labels = function() { - var cp_list = [] + $scope.print_labels = function () { + var cp_list = []; angular.forEach($scope.gridControls.selectedItems(), function (i) { cp_list.push(i.id); }) - egCore.net.request( - 'open-ils.actor', - 'open-ils.actor.anon_cache.set_value', - null, 'print-labels-these-copies', { - copies : cp_list - } - ).then(function(key) { - if (key) { - var url = egCore.env.basePath + 'cat/printlabels/' + key; - $timeout(function() { $window.open(url, '_blank') }); + var cp_full = [], promises = []; + promises.push( + egCore.pcrud.search('ccbi', { bucket: bucketSvc.currentBucket.a[2], "target_copy": { "in": cp_list } }).then( + null + , null + , function (ccbi) { + cp_full.push(egCore.idl.toHash(ccbi, true)); + } + ) + ); + + $q.all(promises).then(function () { + if (cp_full.length > 0) { + egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.anon_cache.set_value', + null, 'print-labels-these-copies', { + copies: cp_full + } + ).then(function (key) { + if (key) { + var url = egCore.env.basePath + 'cat/printlabels/' + key; + $timeout(function () { $window.open(url, '_blank') }); + } else { + alert('Could not create anonymous cache key!'); + } + }); } else { - alert('Could not create anonymous cache key!'); + alert('Could not create print label export.'); } }); } diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js old mode 100644 new mode 100755 index 2988d9504c..3bd142f978 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -1638,18 +1638,37 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e } $scope.selectedHoldingsPrintLabels = function() { - egCore.net.request( - 'open-ils.actor', - 'open-ils.actor.anon_cache.set_value', - null, 'print-labels-these-copies', { - copies : gatherSelectedHoldingsIds() - } - ).then(function(key) { - if (key) { - var url = egCore.env.basePath + 'cat/printlabels/' + key; - $timeout(function() { $window.open(url, '_blank') }); + var cp_list = gatherSelectedHoldingsIds(); + + var cp_full = [], promises = []; + promises.push( + egCore.pcrud.search('ccbi', { bucket: $scope.bucket_id, "target_copy": { "in": cp_list } }).then( + null + , null + , function (ccbi) { + cp_full.push(egCore.idl.toHash(ccbi, true)); + } + ) + ); + + $q.all(promises).then(function () { + if (cp_full.length > 0) { + egCore.net.request( + 'open-ils.actor', + 'open-ils.actor.anon_cache.set_value', + null, 'print-labels-these-copies', { + copies: cp_full + } + ).then(function (key) { + if (key) { + var url = egCore.env.basePath + 'cat/printlabels/' + key; + $timeout(function () { $window.open(url, '_blank') }); + } else { + alert('Could not create anonymous cache key!'); + } + }); } else { - alert('Could not create anonymous cache key!'); + alert('Could not create print label export.'); } }); } diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js old mode 100644 new mode 100755 index fc3e823dfa..49e94c4ddc --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -591,13 +591,21 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD $scope.transferItems = function (){ itemSvc.transferItems(copyGrid.selectedItems()); } - + $scope.print_labels = function() { + var cp_list = gatherSelectedHoldingsIds(); + !$scope.gridDataProvider.sort ? cp_list.reverse() : $scope.gridDataProvider.sort.length === 0 ? cp_list.reverse() : false; + var i = 1; + var cp_full = []; + angular.forEach(cp_list, function (copy) { + cp_full.push({id: i, target_copy: copy}) + i++; + }); egCore.net.request( 'open-ils.actor', 'open-ils.actor.anon_cache.set_value', null, 'print-labels-these-copies', { - copies : gatherSelectedHoldingsIds() + copies : cp_full } ).then(function(key) { if (key) { diff --git a/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js b/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js old mode 100644 new mode 100755 index 255368931f..a04f2ca520 --- a/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js @@ -265,8 +265,9 @@ function ($scope, $q, $window, $routeParams, $location, $timeout, egCore, egNet, angular.forEach(data.copies, function (copy) { promises.push( - itemSvc.fetch(null, copy).then(function (res) { + itemSvc.fetch(null, copy.target_copy).then(function (res) { var flat_copy = egCore.idl.toHash(res.copy, true); + flat_copy.copy_bucket_item_id = copy.id; $scope.preview_scope.copies.push(flat_copy); $scope.record_details[flat_copy['call_number.record.id']] = 1; }) @@ -289,6 +290,8 @@ function ($scope, $q, $window, $routeParams, $location, $timeout, egCore, egNet, }); $q.all(promises2).then(function () { + // sort copies into the order they were entered into the bucket + $scope.preview_scope.copies.sort((a, b) => (a.copy_bucket_item_id > b.copy_bucket_item_id) ? 1 : ((b.copy_bucket_item_id > a.copy_bucket_item_id) ? -1 : 0)); // today, staff, current_location, etc. egCore.print.fleshPrintScope($scope.preview_scope); $scope.template_changed(); // load the default @@ -933,4 +936,4 @@ function getPrintLabelOutputClass(index, settings) { function getPrintLabelStyle(index, settings) { return index > 0 && (index % settings.page.label.set.size === 0) ? settings.page.label.gap.size : ""; -} \ No newline at end of file +} diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js old mode 100644 new mode 100755 index 5923b401b2..ba3beeeb24 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -2009,12 +2009,19 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , ).then(function(copy_ids) { if (and_exit) { $scope.dirty = false; + !$scope.completedGridDataProvider.sort ? copy_ids.reverse() : $scope.completedGridDataProvider.sort.length === 0 ? copy_ids.reverse() : false; if ($scope.defaults.print_item_labels) { + var cp_full = []; + var i = 1; + angular.forEach(copy_ids, function (copy) { + cp_full.push({ id: i, target_copy: copy }); + i++; + }); egCore.net.request( 'open-ils.actor', 'open-ils.actor.anon_cache.set_value', null, 'print-labels-these-copies', { - copies : copy_ids + copies : cp_full } ).then(function(key) { if (key) { @@ -2187,7 +2194,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , { order_by : { 'acpt' : ['label'] } }, { atomic: true } ).then(function(list) { return list.map(function(item) { - return item.label() + " (" + egCore.org.get(item.owner()).shortname() + ")"; + return item.label(); }); }); } 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 old mode 100644 new mode 100755 index 6d71f6c6dd..452016a73a --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -397,12 +397,18 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg }); } - $scope.printSpineLabels = function(items){ - var copy_ids = []; + $scope.printSpineLabels = function(items){ + var copy_ids = [], cp_full; angular.forEach(items, function(item) { if (item.acp) copy_ids.push(item.acp.id()); }); - itemSvc.print_spine_labels(copy_ids); + !$scope.gridDataProvider.sort ? copy_ids.reverse() : $scope.gridDataProvider.sort.length === 0 ? copy_ids.reverse() : false; + var i = 0; + angular.forEach(copy_ids, function (copy) { + cp_full.push({ id: i, target_copy: copy }); + i++; + }); + itemSvc.print_spine_labels(cp_full); } $scope.addCopyAlerts = function(items) { diff --git a/Open-ILS/web/js/ui/default/staff/circ/services/item.js b/Open-ILS/web/js/ui/default/staff/circ/services/item.js old mode 100644 new mode 100755