From 38a90121222d10a883abb6e1d2572c0ee624f50a Mon Sep 17 00:00:00 2001 From: Adam Bowling Date: Wed, 13 Feb 2019 12:40:17 -0500 Subject: [PATCH] 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 --- .../web/js/ui/default/staff/cat/bucket/copy/app.js | 43 +++++++++++++++------- .../web/js/ui/default/staff/cat/catalog/app.js | 41 +++++++++++++++------ Open-ILS/web/js/ui/default/staff/cat/item/app.js | 12 +++++- .../web/js/ui/default/staff/cat/printlabels/app.js | 7 +++- .../web/js/ui/default/staff/cat/volcopy/app.js | 11 +++++- .../web/js/ui/default/staff/circ/checkin/app.js | 12 ++++-- .../web/js/ui/default/staff/circ/services/item.js | 0 7 files changed, 93 insertions(+), 33 deletions(-) mode change 100644 => 100755 Open-ILS/web/js/ui/default/staff/cat/bucket/copy/app.js mode change 100644 => 100755 Open-ILS/web/js/ui/default/staff/cat/catalog/app.js mode change 100644 => 100755 Open-ILS/web/js/ui/default/staff/cat/item/app.js mode change 100644 => 100755 Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js mode change 100644 => 100755 Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js mode change 100644 => 100755 Open-ILS/web/js/ui/default/staff/circ/checkin/app.js mode change 100644 => 100755 Open-ILS/web/js/ui/default/staff/circ/services/item.js 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 f39346ef35..62a4063c83 --- 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 74f7190589..6bd266dd7a --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -1632,18 +1632,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 a8142b9428..bcdfc24c53 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -536,13 +536,21 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore , $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 11547dc4c6..92b9b910a9 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -1962,12 +1962,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) { @@ -2140,7 +2147,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 e9f9f51361..4ea190843e --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -411,12 +411,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 -- 2.11.0