add copy alert ack/manage action to checkin, checkout, and item status
authorGalen Charlton <gmc@esilibrary.com>
Tue, 8 Dec 2015 16:22:57 +0000 (11:22 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 3 Nov 2017 20:01:20 +0000 (16:01 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Conflicts:
Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/cat/item/t_summary_pane.tt2
Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2
Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
Open-ILS/src/templates/staff/share/t_copy_alert_manager_dialog.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/circ/services/circ.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index 4b9abe3..a24326d 100644 (file)
   </div>
 
   <div class="flex-row">
-    <div class="flex-cell">[% l('Alert Message') %]</div>
-    <div class="well" style="flex:7">{{copy.alert_message()}}</div>
+    <div class="flex-cell">[% l('Copy Alerts') %]</div>
+    <div id="item-status-alert-msg">
+      <button ng-click="manageCopyAlerts(copy.id())" >[% l('Manage') %]</button>
+    </div>
   </div>
 
 </div>
index 4d34a61..51d9dfe 100644 (file)
     handler="abortTransit"
     label="[% l('Cancel Transits') %]">
   </eg-grid-action>
+  <eg-grid-action 
+    handler="manageCopyAlerts"
+    label="[% l('Acknowledge Alerts') %]">
+  </eg-grid-action>
+
   <!-- Show Group -->
   <eg-grid-action handler="showBibHolds" group="[% l('Show') %]"
     label="[% l('Record Holds') %]">
index 773d911..089b586 100644 (file)
   persist-key="circ.patron.checkout"
   dateformat="{{$root.egDateAndTimeFormat}}">
 
+  <eg-grid-action
+    handler="manageCopyAlerts"
+    label="[% l('Acknowledge Alerts') %]">
+  </eg-grid-action>
+
   <eg-grid-field label="[% l('Alert Msg') %]"   
     path="acp.alert_message"></eg-grid-field>
 
index 2b615e8..e055505 100644 (file)
@@ -15,6 +15,9 @@
           <button ng-if="canBeAcknowledged(alert)"
                   class="btn btn-xs btn-default"
                   ng-click="alert.acked = !alert.acked" >[% l('Acknowledge') %]</button>
+          <button ng-if="canBeRemoved(alert) && mode == 'manage'"
+                  class="btn btn-xs btn-default"
+                  ng-click="alert.acked = !alert.acked" >[% l('Remove') %]</button>
         </div>
       </div>
     </div>
index 3624b2a..c2c79f1 100644 (file)
@@ -511,8 +511,8 @@ function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
  * Detail view -- shows one copy
  */
 .controller('ViewCtrl', 
-       ['$scope','$q','$location','$routeParams','$timeout','$window','egCore','egItem','egBilling',
-function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling) {
+       ['$scope','$q','$location','$routeParams','$timeout','$window','egCore','egItem','egBilling','egCirc',
+function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling , egCirc) {
     var copyId = $routeParams.id;
     $scope.args.copyId = copyId;
     $scope.tab = $routeParams.tab || 'summary';
@@ -897,6 +897,12 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
         return;
     }
 
+    $scope.manageCopyAlerts = function(copy_id) {
+        egCirc.manage_copy_alerts([copy_id]).then(function() {
+            // update grid items?
+        });
+    }
+
     $scope.context.toggleDisplay = function() {
         $location.path('/cat/item/search');
     }
index 7be19fb..d5eb598 100644 (file)
@@ -387,5 +387,16 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
         });
         itemSvc.print_spine_labels(copy_ids);
     }
+
+    $scope.manageCopyAlerts = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) copy_ids.push(item.acp.id());
+        });
+        egCirc.manage_copy_alerts(copy_ids).then(function() {
+            // update grid items?
+        });
+    }
+
 }])
 
index 4234f5c..8acad73 100644 (file)
@@ -255,6 +255,16 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         }
     }
 
+    $scope.manageCopyAlerts = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) copy_ids.push(item.acp.id());
+        });
+        egCirc.manage_copy_alerts(copy_ids).then(function() {
+            // update grid items?
+        });
+    }
+
     $scope.print_receipt = function() {
         var print_data = {circulations : []}
 
index 1cbe96f..dd3c51f 100644 (file)
@@ -1339,7 +1339,14 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egCopyAlert
         });
     }
 
-
+    service.manage_copy_alerts = function(item_ids) {
+        return egCopyAlertManagerDialog.open({
+            copy_id : item_ids[0],
+            mode : 'manage',
+            ok : function() { },
+            cancel : function() {}
+        }).result.then(function() { });
+    }
 
     // alert when copy location alert_message is set.
     // This does not affect processing, it only produces a click-through
index 71d7ddb..b8dec81 100644 (file)
@@ -579,31 +579,53 @@ function($window , egStrings) {
 function($modal , $interpolate , egCore) {
     var service = {};
 
+    service.get_user_copy_alerts = function(copy_id) {
+        return egCore.pcrud.search('aca', { copy : copy_id, ack_time : null },
+            { flesh : 1, flesh_fields : { aca : ['alert_type'] } },
+            { atomic : true }
+        );
+    }
+
     service.open = function(args) {
         return $modal.open({
             templateUrl: './share/t_copy_alert_manager_dialog',
-            controller: ['$scope', '$modalInstance',
-                function($scope, $modalInstance) {
-                    $scope.alerts = args.alerts;
+            controller: ['$scope','$q','$modalInstance',
+                function( $scope , $q , $modalInstance) {
+
+                    function init(args) {
+                        var defer = $q.defer();
+                        if (args.copy_id) {
+                            service.get_user_copy_alerts(args.copy_id).then(function(aca) {
+                                defer.resolve(aca);
+                            });
+                        } else {
+                            defer.resolve(args.alerts);
+                        }
+                        return defer.promise;
+                    }
+
                     $scope.mode = args.mode || 'checkin';
 
                     var next_statuses = [];
                     var seen_statuses = {};
-                    angular.forEach($scope.alerts, function(copy_alert) {
-                        var state = copy_alert.alert_type().state();
-                        var evt   = copy_alert.alert_type().event();
-
-                        copy_alert.message = copy_alert.note() ||
-                            egCore.strings.ON_DEMAND_COPY_ALERT[evt][state];
-
-                        if (copy_alert.temp() == 't') {
-                            angular.forEach(copy_alert.alert_type().next_status(), function (st) {
-                                if (!seen_statuses[st]) {
-                                    seen_statuses[st] = true;
-                                    next_statuses.push(st);
-                                }
-                            });
-                        }
+                    init(args).then(function(copy_alerts) {
+                        $scope.alerts = copy_alerts;
+                        angular.forEach($scope.alerts, function(copy_alert) {
+                            var state = copy_alert.alert_type().state();
+                            var evt   = copy_alert.alert_type().event();
+
+                            copy_alert.message = copy_alert.note() ||
+                                egCore.strings.ON_DEMAND_COPY_ALERT[evt][state];
+
+                            if (copy_alert.temp() == 't') {
+                                angular.forEach(copy_alert.alert_type().next_status(), function (st) {
+                                    if (!seen_statuses[st]) {
+                                        seen_statuses[st] = true;
+                                        next_statuses.push(st);
+                                    }
+                                });
+                            }
+                        });
                     });
 
                     // returns a promise resolved with the list of circ mods
@@ -637,6 +659,9 @@ function($modal , $interpolate , egCore) {
                     $scope.canBeAcknowledged = function(copy_alert) {
                         return (!copy_alert.ack_time() && copy_alert.temp() == 't');
                     };
+                    $scope.canBeRemoved = function(copy_alert) {
+                        return (!copy_alert.ack_time() && copy_alert.temp() == 'f');
+                    };
 
                     $scope.ok = function() {
                         var acks = [];