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>
[% 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>
.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 = [];
});
}
+ $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 : []}
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();