From: Galen Charlton Date: Wed, 7 Feb 2018 21:30:04 +0000 (-0500) Subject: LP#1676608: conditionally enable manage copy alerts button on item status details X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=56679c9b7b96c818935b9004c41a76587e679db9;p=contrib%2FConifer.git LP#1676608: conditionally enable manage copy alerts button on item status details The 'Manage' button for copy alerts on the Item Status Detail view is now enabled only if there is at least one active copy alert. This patch also tweaks how the copy alert dialogs sequence record update and modal-closing so that the caller can be sure that the transaction has committed. Signed-off-by: Galen Charlton Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 b/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 index a5dbbdd1b1..3ef0b351df 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2 @@ -180,7 +180,7 @@
[% l('Copy Alerts') %]
- +
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 index 2a3d7a71f1..1effdca985 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -566,6 +566,9 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore , // use the cached record info if (itemSvc.copy) { + $scope.copy_alert_count = itemSvc.copy.copy_alerts().filter(function(aca) { + return !aca.ack_time(); + }).length; $scope.recordId = itemSvc.copy.call_number().record().id(); $scope.args.recordId = $scope.recordId; $scope.args.cnId = itemSvc.copy.call_number().id(); @@ -588,6 +591,9 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore , // regardless of whether it matches the current item. if (!barcode && itemSvc.copy && itemSvc.copy.id() == copyId) { $scope.copy = itemSvc.copy; + $scope.copy_alert_count = itemSvc.copy.copy_alerts().filter(function(aca) { + return !aca.ack_time(); + }).length; $scope.recordId = itemSvc.copy.call_number().record().id(); $scope.args.recordId = $scope.recordId; $scope.args.cnId = itemSvc.copy.call_number().id(); @@ -620,6 +626,10 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore , $scope.copy = copy; + $scope.copy_alert_count = copy.copy_alerts().filter(function(aca) { + return !aca.ack_time(); + }).length; +console.debug($scope.copy_alert_count); $scope.recordId = copy.call_number().record().id(); $scope.args.recordId = $scope.recordId; $scope.args.cnId = itemSvc.copy.call_number().id(); @@ -969,12 +979,14 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore , $scope.addCopyAlerts = function(copy_id) { egCirc.add_copy_alerts([copy_id]).then(function() { - // update grid items? + // force a refresh + loadCopy($scope.copy.barcode()).then(loadTabData); }); } $scope.manageCopyAlerts = function(copy_id) { egCirc.manage_copy_alerts([copy_id]).then(function() { - // update grid items? + // force a refresh + loadCopy($scope.copy.barcode()).then(loadTabData); }); } diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index 1a3f8220ed..fb48ea0d71 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -683,11 +683,15 @@ function($uibModal , $interpolate , egCore) { copy_alerts.push( a ); }); if (copy_alerts.length > 0) { - egCore.pcrud.apply(copy_alerts); + egCore.pcrud.apply(copy_alerts).finally(function() { + if (args.ok) args.ok(); + $uibModalInstance.close() + }); } + } else { + if (args.ok) args.ok(); + $uibModalInstance.close() } - if (args.ok) args.ok(); - $uibModalInstance.close() } $scope.cancel = function() { if (args.cancel) args.cancel(); @@ -804,10 +808,14 @@ function($uibModal , $interpolate , egCore) { } }); if (acks.length > 0) { - egCore.pcrud.apply(acks); + egCore.pcrud.apply(acks).finally(function() { + if (args.ok) args.ok($scope.params.the_next_status); + $uibModalInstance.close() + }); + } else { + if (args.ok) args.ok($scope.params.the_next_status); + $uibModalInstance.close() } - if (args.ok) args.ok($scope.params.the_next_status); - $uibModalInstance.close() } $scope.cancel = function() { if (args.cancel) args.cancel(); @@ -870,8 +878,9 @@ function($uibModal , $interpolate , egCore) { }); $scope.ok = function() { - egCore.pcrud.apply($scope.copy_alert_list); - $uibModalInstance.close() + egCore.pcrud.apply($scope.copy_alert_list).finally(function() { + $uibModalInstance.close(); + }); } $scope.cancel = function() { if (args.cancel) args.cancel();