renew item
authorBill Erickson <berick@esilibrary.com>
Mon, 30 Jun 2014 15:37:11 +0000 (11:37 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 30 Jun 2014 15:37:11 +0000 (11:37 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/renew/t_renew.tt2
Open-ILS/src/templates/staff/share/t_autogrid.tt2
Open-ILS/web/js/ui/default/staff/circ/renew/app.js
Open-ILS/web/js/ui/default/staff/services/grid.js

index 2d0dbe2..b0c5c78 100644 (file)
     label="[% l('Retrieve Last Patron Who Circulated Item') %]">
   </eg-grid-action>
   <eg-grid-action 
-    handler="showBackdateDialog"
-    label="[% l('Backdate Post-Checkin') %]">
+    handler="showLastFewCircs"
+    label="[% l('Show Last Few Circluations') %]">
   </eg-grid-action>
+  <eg-grid-action divider="true"></eg-grid-action>
   <eg-grid-action 
     handler="showMarkDamaged"
     label="[% l('Mark Items Damaged') %]">
   </eg-grid-action>
+  <eg-grid-action divider="true"></eg-grid-action>
   <eg-grid-action 
     handler="abortTransit"
     label="[% l('Abort Transits') %]">
   </eg-grid-action>
 
+
   <eg-grid-field label="[% l('Alert Msg') %]"   
     path="acp.alert_message"></eg-grid-field>
 
index 65ed458..cd5b3ad 100644 (file)
         [% l('Actions') %] <span class="caret"></span>                       
       </button>                                                              
       <ul class="dropdown-menu pull-right">                                  
-        <li ng-class="{disabled : false}" ng-repeat="action in actions">
-          <a href dropdown-toggle 
+        <li ng-repeat="action in actions" ng-class="{divider: action.divider}">
+          <a ng-if="!action.divider" href dropdown-toggle
             ng-click="actionLauncher(action)">{{action.label}}</a>
-        </li>                                                                
+        </li>
       </ul>
     </div>
 
index 54d7a63..88194b7 100644 (file)
@@ -29,10 +29,8 @@ angular.module('egRenewApp',
 
 
 .controller('RenewCtrl',
-
-       ['$scope','egCore','egGridDataProvider','egCirc',
-
-function($scope , egCore , egGridDataProvider , egCirc) {
+       ['$scope','$window','$location','egCore','egGridDataProvider','egCirc',
+function($scope , $window , $location , egCore , egGridDataProvider , egCirc) {
 
     $scope.focusBarcode = true;
     $scope.renewals = [];
@@ -138,6 +136,58 @@ function($scope , egCore , egGridDataProvider , egCirc) {
         });
     }
 
+    $scope.fetchLastCircPatron = function(items) {
+        var renewal = items[0];
+        if (!renewal || !renewal.acp) return;
+
+        egCirc.last_copy_circ(renewal.acp.id())
+        .then(function(circ) {
+
+            if (circ) {
+                // jump to the patron UI (separate app)
+                $window.location.href = $location
+                    .path('/circ/patron/' + circ.usr() + '/checkout')
+                    .absUrl();
+                return;
+            }
+
+            $scope.alert = {item_never_circed : renewal.acp.barcode()};
+        });
+    }
+
+    $scope.showMarkDamaged = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) copy_ids.push(item.acp.id());
+        });
+
+        if (copy_ids.length) {
+            egCirc.mark_damaged(copy_ids).then(function() {
+                // update grid items?
+            });
+        }
+    }
+
+    // TODO: add URL-based grid actions support for ctrl-click
+    $scope.showLastFewCircs = function(items) {
+        if (items.length && (copy = items[0].acp)) {
+            $window.location.href = $location
+                .path('/cat/item/' + copy.id() + '/circ_list')
+                .absUrl();
+        }
+    }
+
+    $scope.abortTransit = function(items) {
+        var transit_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.transit) transit_ids.push(item.transit.id());
+        });
+
+        egCirc.abort_transits(transit_ids).then(function() {
+            // update grid items?
+        });
+    }
+
     $scope.print_receipt = function() {
         var print_data = {circulations : []}
 
index 3660eec..a11c397 100644 (file)
@@ -849,11 +849,13 @@ angular.module('egGridMod',
         transclude : true,
         scope : {
             label   : '@', // Action label
-            handler : '='  // Action function handler
+            handler : '=',  // Action function handler
+            divider : '='
         },
         link : function(scope, element, attrs, egGridCtrl) {
             egGridCtrl.addAction({
                 label : scope.label,
+                divider : scope.divider,
                 handler : scope.handler
             });
             scope.$destroy();