<div class="flex-cell">[% l('Copy Alerts') %]</div>
<div class="flex-cell" id="item-status-alert-msg">
<button class="btn btn-default" ng-click="addCopyAlerts(copy.id())" >[% l('Add') %]</button>
- <button class="btn btn-default" ng-click="manageCopyAlerts(copy.id())" >[% l('Manage') %]</button>
+ <button class="btn btn-default" ng-disabled="!copy_alert_count" ng-click="manageCopyAlerts(copy.id())" >[% l('Manage') %]</button>
</div>
<!-- hack to adjust positioning -->
<div class="flex-cell"></div>
// 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();
// 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();
$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();
$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);
});
}
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();
}
});
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();
});
$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();