5 angular.module('egItemStatus',
6 ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod', 'egGridMod', 'egUserMod'])
8 .filter('boolText', function(){
14 .config(function($routeProvider, $locationProvider, $compileProvider) {
15 $locationProvider.html5Mode(true);
16 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|mailto|blob):/); // grid export
18 var resolver = {delay : function(egStartup) {return egStartup.go()}};
20 // search page shows the list view by default
21 $routeProvider.when('/cat/item/search', {
22 templateUrl: './cat/item/t_list',
23 controller: 'ListCtrl',
27 // search page shows the list view by default
28 $routeProvider.when('/cat/item/search/:idList', {
29 templateUrl: './cat/item/t_list',
30 controller: 'ListCtrl',
34 $routeProvider.when('/cat/item/:id', {
35 templateUrl: './cat/item/t_view',
36 controller: 'ViewCtrl',
40 $routeProvider.when('/cat/item/:id/:tab', {
41 templateUrl: './cat/item/t_view',
42 controller: 'ViewCtrl',
46 // default page / bucket view
47 $routeProvider.otherwise({redirectTo : '/cat/item/search'});
51 * Search bar along the top of the page.
52 * Parent scope for list and detail views
54 .controller('SearchCtrl',
55 ['$scope','$location','$timeout','egCore','egGridDataProvider','egItem',
56 function($scope , $location , $timeout , egCore , egGridDataProvider , itemSvc) {
57 $scope.args = {}; // search args
59 // sub-scopes (search / detail-view) apply their version
60 // of retrieval function to $scope.context.search
61 // and display toggling via $scope.context.toggleDisplay
66 $scope.toggleView = function($event) {
67 $scope.context.toggleDisplay();
68 $event.preventDefault(); // avoid form submission
71 // The functions that follow in this controller are never called
72 // when the List View is active, only the Detail View.
74 // In this context, we're only ever dealing with 1 item, so
75 // we can simply refresh the page. These various itemSvc
76 // functions used to live in the ListCtrl, but they're now
77 // shared between SearchCtrl (for Actions for the Detail View)
78 // and ListCtrl (Actions in the egGrid)
79 itemSvc.add_barcode_to_list = function(b) {
80 //console.log('SearchCtrl: add_barcode_to_list',b);
81 // timeout so audible can happen upon checkin
82 $timeout(function() { location.href = location.href; }, 1000);
85 $scope.add_copies_to_bucket = function() {
86 itemSvc.add_copies_to_bucket([$scope.args.copyId]);
89 $scope.make_copies_bookable = function() {
90 itemSvc.make_copies_bookable([{
91 id : $scope.args.copyId,
92 'call_number.record.id' : $scope.args.recordId
96 $scope.book_copies_now = function() {
97 itemSvc.book_copies_now([{
98 id : $scope.args.copyId,
99 'call_number.record.id' : $scope.args.recordId
103 $scope.requestItems = function() {
104 itemSvc.requestItems([$scope.args.copyId]);
107 $scope.attach_to_peer_bib = function() {
108 itemSvc.attach_to_peer_bib([{
109 id : $scope.args.copyId,
110 barcode : $scope.args.copyBarcode
114 $scope.selectedHoldingsCopyDelete = function () {
115 itemSvc.selectedHoldingsCopyDelete([{
116 id : $scope.args.copyId,
117 barcode : $scope.args.copyBarcode
121 $scope.checkin = function () {
123 id : $scope.args.copyId,
124 barcode : $scope.args.copyBarcode
128 $scope.renew = function () {
130 id : $scope.args.copyId,
131 barcode : $scope.args.copyBarcode
135 $scope.cancel_transit = function () {
136 itemSvc.cancel_transit([{
137 id : $scope.args.copyId,
138 barcode : $scope.args.copyBarcode
142 $scope.selectedHoldingsDamaged = function () {
143 itemSvc.selectedHoldingsDamaged([{
144 id : $scope.args.copyId,
145 barcode : $scope.args.copyBarcode,
150 $scope.selectedHoldingsMissing = function () {
151 itemSvc.selectedHoldingsMissing([{
152 id : $scope.args.copyId,
153 barcode : $scope.args.copyBarcode
157 $scope.selectedHoldingsVolCopyAdd = function () {
158 itemSvc.spawnHoldingsAdd([{
159 id : $scope.args.copyId,
160 'call_number.owning_lib' : $scope.args.cnOwningLib,
161 'call_number.record.id' : $scope.args.recordId,
162 barcode : $scope.args.copyBarcode
165 $scope.selectedHoldingsCopyAdd = function () {
166 itemSvc.spawnHoldingsAdd([{
167 id : $scope.args.copyId,
168 'call_number.id' : $scope.args.cnId,
169 'call_number.owning_lib' : $scope.args.cnOwningLib,
170 'call_number.record.id' : $scope.args.recordId,
171 barcode : $scope.args.copyBarcode
175 $scope.selectedHoldingsVolCopyEdit = function () {
176 itemSvc.spawnHoldingsEdit([{
177 id : $scope.args.copyId,
178 'call_number.id' : $scope.args.cnId,
179 'call_number.owning_lib' : $scope.args.cnOwningLib,
180 'call_number.record.id' : $scope.args.recordId,
181 barcode : $scope.args.copyBarcode
184 $scope.selectedHoldingsVolEdit = function () {
185 itemSvc.spawnHoldingsEdit([{
186 id : $scope.args.copyId,
187 'call_number.id' : $scope.args.cnId,
188 'call_number.owning_lib' : $scope.args.cnOwningLib,
189 'call_number.record.id' : $scope.args.recordId,
190 barcode : $scope.args.copyBarcode
193 $scope.selectedHoldingsCopyEdit = function () {
194 itemSvc.spawnHoldingsEdit([{
195 id : $scope.args.copyId,
196 'call_number.id' : $scope.args.cnId,
197 'call_number.owning_lib' : $scope.args.cnOwningLib,
198 'call_number.record.id' : $scope.args.recordId,
199 barcode : $scope.args.copyBarcode
203 $scope.replaceBarcodes = function() {
204 itemSvc.replaceBarcodes([{
205 id : $scope.args.copyId,
206 barcode : $scope.args.copyBarcode
210 $scope.changeItemOwningLib = function() {
211 itemSvc.changeItemOwningLib([{
212 id : $scope.args.copyId,
213 'call_number.id' : $scope.args.cnId,
214 'call_number.owning_lib' : $scope.args.cnOwningLib,
215 'call_number.record.id' : $scope.args.recordId,
216 'call_number.label' : $scope.args.cnLabel,
217 'call_number.label_class' : $scope.args.cnLabelClass,
218 'call_number.prefix.id' : $scope.args.cnPrefixId,
219 'call_number.suffix.id' : $scope.args.cnSuffixId,
220 barcode : $scope.args.copyBarcode
224 $scope.transferItems = function (){
225 itemSvc.transferItems([{
226 id : $scope.args.copyId,
227 barcode : $scope.args.copyBarcode
234 * List view - grid stuff
236 .controller('ListCtrl',
237 ['$scope','$q','$routeParams','$location','$timeout','$window','egCore',
238 'egGridDataProvider','egItem','egUser','$uibModal','egCirc','egConfirmDialog',
240 function($scope , $q , $routeParams , $location , $timeout , $window , egCore ,
241 egGridDataProvider , itemSvc , egUser , $uibModal , egCirc , egConfirmDialog,
245 var cp_list = $routeParams.idList;
247 copyId = cp_list.split(',');
250 $scope.context.page = 'list';
253 var provider = egGridDataProvider.instance();
254 provider.get = function(offset, count) {
258 $scope.gridDataProvider = egGridDataProvider.instance({
259 get : function(offset, count) {
260 //return provider.arrayNotifier(itemSvc.copies, offset, count);
261 return this.arrayNotifier(itemSvc.copies, offset, count);
265 // If a copy was just displayed in the detail view, ensure it's
266 // focused in the list view.
267 var selected = false;
268 var copyGrid = $scope.gridControls = {
269 itemRetrieved : function(item) {
270 if (selected || !itemSvc.copy) return;
271 if (itemSvc.copy.id() == item.id) {
272 copyGrid.selectItems([item.index]);
278 $scope.$watch('barcodesFromFile', function(newVal, oldVal) {
279 if (newVal && newVal != oldVal) {
280 $scope.args.barcode = '';
283 angular.forEach(newVal.split(/\n/), function(line) {
285 // scrub any trailing spaces or commas from the barcode
286 line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');
290 // Serialize copy retrieval since there may be many, many copies.
291 function fetch_next_copy() {
292 var barcode = barcodes.pop();
293 egProgressDialog.increment();
295 if (!barcode) { // All done here.
296 egProgressDialog.close();
298 copyGrid.selectItems([itemSvc.copies[0].index]);
302 itemSvc.fetch(barcode).then(fetch_next_copy);
305 if (barcodes.length) {
306 egProgressDialog.open({value: 0, max: barcodes.length});
312 $scope.context.search = function(args) {
313 if (!args.barcode) return;
314 $scope.context.itemNotFound = false;
315 itemSvc.fetch(args.barcode).then(function(res) {
318 copyGrid.selectItems([res.index]);
319 $scope.args.barcode = '';
321 $scope.context.itemNotFound = true;
322 egCore.audio.play('warning.item_status.itemNotFound');
324 $scope.context.selectBarcode = true;
328 var add_barcode_to_list = function (b) {
329 //console.log('listCtrl: add_barcode_to_list',b);
330 $scope.context.search({barcode:b});
332 itemSvc.add_barcode_to_list = add_barcode_to_list;
334 $scope.context.toggleDisplay = function() {
335 var item = copyGrid.selectedItems()[0];
337 $location.path('/cat/item/' + item.id);
340 $scope.context.show_triggered_events = function() {
341 var item = copyGrid.selectedItems()[0];
343 $location.path('/cat/item/' + item.id + '/triggered_events');
346 function gatherSelectedRecordIds () {
349 copyGrid.selectedItems(),
351 if (rid_list.indexOf(item['call_number.record.id']) == -1)
352 rid_list.push(item['call_number.record.id'])
358 function gatherSelectedVolumeIds (rid) {
361 copyGrid.selectedItems(),
363 if (rid && item['call_number.record.id'] != rid) return;
364 if (cn_id_list.indexOf(item['call_number.id']) == -1)
365 cn_id_list.push(item['call_number.id'])
371 function gatherSelectedHoldingsIds (rid) {
374 copyGrid.selectedItems(),
376 if (rid && item['call_number.record.id'] != rid) return;
377 cp_id_list.push(item.id)
383 $scope.add_copies_to_bucket = function() {
384 var copy_list = gatherSelectedHoldingsIds();
385 itemSvc.add_copies_to_bucket(copy_list);
388 $scope.need_one_selected = function() {
389 var items = $scope.gridControls.selectedItems();
390 if (items.length == 1) return false;
394 $scope.make_copies_bookable = function() {
395 itemSvc.make_copies_bookable(copyGrid.selectedItems());
398 $scope.book_copies_now = function() {
399 itemSvc.book_copies_now(copyGrid.selectedItems());
402 $scope.requestItems = function() {
403 var copy_list = gatherSelectedHoldingsIds();
404 itemSvc.requestItems(copy_list);
407 $scope.replaceBarcodes = function() {
408 itemSvc.replaceBarcodes(copyGrid.selectedItems());
411 $scope.attach_to_peer_bib = function() {
412 itemSvc.attach_to_peer_bib(copyGrid.selectedItems());
415 $scope.selectedHoldingsCopyDelete = function () {
416 itemSvc.selectedHoldingsCopyDelete(copyGrid.selectedItems());
419 $scope.selectedHoldingsItemStatusTgrEvt= function() {
420 var item = copyGrid.selectedItems()[0];
422 $location.path('/cat/item/' + item.id + '/triggered_events');
425 $scope.selectedHoldingsItemStatusHolds= function() {
426 var item = copyGrid.selectedItems()[0];
428 $location.path('/cat/item/' + item.id + '/holds');
431 $scope.cancel_transit = function () {
432 itemSvc.cancel_transit(copyGrid.selectedItems());
435 $scope.selectedHoldingsDamaged = function () {
436 itemSvc.selectedHoldingsDamaged(copyGrid.selectedItems());
439 $scope.selectedHoldingsMissing = function () {
440 itemSvc.selectedHoldingsMissing(copyGrid.selectedItems());
443 $scope.checkin = function () {
444 itemSvc.checkin(copyGrid.selectedItems());
447 $scope.renew = function () {
448 itemSvc.renew(copyGrid.selectedItems());
451 $scope.selectedHoldingsVolCopyAdd = function () {
452 itemSvc.spawnHoldingsAdd(copyGrid.selectedItems(),true,false);
454 $scope.selectedHoldingsCopyAdd = function () {
455 itemSvc.spawnHoldingsAdd(copyGrid.selectedItems(),false,true);
458 $scope.selectedHoldingsCopyAlertsAdd = function(items) {
460 angular.forEach(items, function(item) {
461 if (item.id) copy_ids.push(item.id);
463 egCirc.add_copy_alerts(copy_ids).then(function() {
464 // update grid items?
468 $scope.selectedHoldingsCopyAlertsEdit = function(items) {
470 angular.forEach(items, function(item) {
471 if (item.id) copy_ids.push(item.id);
473 egCirc.manage_copy_alerts(copy_ids).then(function() {
474 // update grid items?
478 $scope.gridCellHandlers = {};
479 $scope.gridCellHandlers.copyAlertsEdit = function(id) {
480 egCirc.manage_copy_alerts([id]).then(function() {
481 // update grid items?
485 $scope.showBibHolds = function () {
486 angular.forEach(gatherSelectedRecordIds(), function (r) {
487 var url = egCore.env.basePath + 'cat/catalog/record/' + r + '/holds';
488 $timeout(function() { $window.open(url, '_blank') });
492 $scope.selectedHoldingsVolCopyEdit = function () {
493 itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),false,false);
495 $scope.selectedHoldingsVolEdit = function () {
496 itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),false,true);
498 $scope.selectedHoldingsCopyEdit = function () {
499 itemSvc.spawnHoldingsEdit(copyGrid.selectedItems(),true,false);
502 $scope.changeItemOwningLib = function() {
503 itemSvc.changeItemOwningLib(copyGrid.selectedItems());
506 $scope.transferItems = function (){
507 itemSvc.transferItems(copyGrid.selectedItems());
510 $scope.print_labels = function() {
513 'open-ils.actor.anon_cache.set_value',
514 null, 'print-labels-these-copies', {
515 copies : gatherSelectedHoldingsIds()
517 ).then(function(key) {
519 var url = egCore.env.basePath + 'cat/printlabels/' + key;
520 $timeout(function() { $window.open(url, '_blank') });
522 alert('Could not create anonymous cache key!');
527 $scope.print_list = function() {
528 var print_data = { copies : copyGrid.allItems() };
530 if (print_data.copies.length == 0) return $q.when();
532 return egCore.print.print({
533 template : 'item_status',
538 if (copyId.length > 0) {
539 itemSvc.fetch(null,copyId).then(
549 * Detail view -- shows one copy
551 .controller('ViewCtrl',
552 ['$scope','$q','$location','$routeParams','$timeout','$window','egCore','egItem','egBilling','egCirc',
553 function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling , egCirc) {
554 var copyId = $routeParams.id;
555 $scope.args.copyId = copyId;
556 $scope.tab = $routeParams.tab || 'summary';
557 $scope.context.page = 'detail';
558 $scope.summaryRecord = null;
561 if ($scope.tab == 'edit') {
562 $scope.tab = 'summary';
567 // use the cached record info
569 $scope.recordId = itemSvc.copy.call_number().record().id();
570 $scope.args.recordId = $scope.recordId;
571 $scope.args.cnId = itemSvc.copy.call_number().id();
572 $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
573 $scope.args.cnLabel = itemSvc.copy.call_number().label();
574 $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
575 $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
576 $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
577 $scope.args.copyBarcode = itemSvc.copy.barcode();
580 function loadCopy(barcode) {
581 $scope.context.itemNotFound = false;
583 // Avoid re-fetching the same copy while jumping tabs.
584 // In addition to being quicker, this helps to avoid flickering
585 // of the top panel which is always visible in the detail view.
587 // 'barcode' represents the loading of a new item - refetch it
588 // regardless of whether it matches the current item.
589 if (!barcode && itemSvc.copy && itemSvc.copy.id() == copyId) {
590 $scope.copy = itemSvc.copy;
591 $scope.recordId = itemSvc.copy.call_number().record().id();
592 $scope.args.recordId = $scope.recordId;
593 $scope.args.cnId = itemSvc.copy.call_number().id();
594 $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
595 $scope.args.cnLabel = itemSvc.copy.call_number().label();
596 $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
597 $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
598 $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
599 $scope.args.copyBarcode = itemSvc.copy.barcode();
606 var deferred = $q.defer();
607 itemSvc.fetch(barcode, copyId, true).then(function(res) {
608 $scope.context.selectBarcode = true;
612 $scope.context.itemNotFound = true;
613 egCore.audio.play('warning.item_status.itemNotFound');
614 deferred.reject(); // avoid propagation of data fetch calls
623 $scope.recordId = copy.call_number().record().id();
624 $scope.args.recordId = $scope.recordId;
625 $scope.args.cnId = itemSvc.copy.call_number().id();
626 $scope.args.cnOwningLib = itemSvc.copy.call_number().owning_lib();
627 $scope.args.cnLabel = itemSvc.copy.call_number().label();
628 $scope.args.cnLabelClass = itemSvc.copy.call_number().label_class();
629 $scope.args.cnPrefixId = itemSvc.copy.call_number().prefix().id();
630 $scope.args.cnSuffixId = itemSvc.copy.call_number().suffix().id();
631 $scope.args.copyBarcode = copy.barcode();
632 $scope.args.barcode = '';
634 // locally flesh org units
635 copy.circ_lib(egCore.org.get(copy.circ_lib()));
636 copy.call_number().owning_lib(
637 egCore.org.get(copy.call_number().owning_lib()));
639 var r = copy.call_number().record();
640 if (r.owner()) r.owner(egCore.org.get(r.owner()));
642 // make boolean for auto-magic true/false display
644 ['ref','opac_visible','holdable','circulate'],
645 function(field) { copy[field](Boolean(copy[field]() == 't')) }
648 // finally, if this is a different copy, redirect.
649 // Note that we flesh first since the copy we just
650 // fetched will be used after the redirect.
651 if (copyId && copyId != copy.id()) {
652 // if a new barcode is scanned in the detail view,
653 // update the url to match the ID of the new copy
654 $location.path('/cat/item/' + copy.id() + '/' + $scope.tab);
655 deferred.reject(); // avoid propagation of data fetch calls
663 return deferred.promise;
666 // load the two most recent circulations in /circs tab
667 function loadCurrentCirc() {
669 delete $scope.circ_summary;
670 delete $scope.prev_circ_summary;
671 delete $scope.prev_circ_usr;
675 itemSvc.copy.call_number().id() == -1 ?
676 itemSvc.copy.circ_lib().id() :
677 itemSvc.copy.call_number().owning_lib().id();
679 // since a user can still view patron checkout history here, check perms
680 egCore.perm.hasPermAt('VIEW_COPY_CHECKOUT_HISTORY', true)
681 .then(function(orgIds){
682 if(orgIds.indexOf(copy_org) == -1){
683 console.warn('User is not allowed to view circ history!');
687 return fetchMaxCircHistory();
689 .then(function(maxHistCount){
691 if (!maxHistCount) $scope.isMaxCircHistoryZero = true;
693 egCore.pcrud.search('aacs',
694 {target_copy : copyId},
700 'checkin_workstation',
703 'recurring_fine_rule'
707 order_by : {aacs : 'xact_start desc'},
711 ).then(null, null, function(circ) {
714 if (!circ) return $q.when();
716 // load the chain for this circ
719 'open-ils.circ.renewal_chain.retrieve_by_circ.summary',
720 egCore.auth.token(), $scope.circ.id()
721 ).then(function(summary) {
722 $scope.circ_summary = summary;
725 if (maxHistCount <= 1) return;
727 // load the chain for the previous circ, plus the user
730 'open-ils.circ.prev_renewal_chain.retrieve_by_circ.summary',
731 egCore.auth.token(), $scope.circ.id()
733 ).then(null, null, function(summary) {
734 $scope.prev_circ_summary = summary.summary;
736 if (summary.usr) { // aged circs have no 'usr'.
737 egCore.pcrud.retrieve('au', summary.usr,
738 {flesh : 1, flesh_fields : {au : ['card']}})
740 .then(function(user) { $scope.prev_circ_usr = user });
748 function fetchMaxCircHistory() {
749 if (maxHistory) return $q.when(maxHistory);
750 return egCore.org.settings(
751 'circ.item_checkout_history.max')
752 .then(function(set) {
753 maxHistory = set['circ.item_checkout_history.max'] || 4;
754 return Number(maxHistory);
758 $scope.addBilling = function(circ) {
759 egBilling.showBillDialog({
765 $scope.retrieveAllPatrons = function() {
766 var users = new Set();
767 angular.forEach($scope.circ_list.map(function(circ) { return circ.usr(); }),function(usr) {
768 // aged circs have no 'usr'.
769 if (usr) users.add(usr);
771 users.forEach(function(usr) {
772 $timeout(function() {
773 var url = $location.absUrl().replace(
775 '/circ/patron/' + usr.id() + '/checkout');
776 $window.open(url, '_blank')
781 // load data for /circ_list tab
782 function loadCircHistory() {
783 $scope.circ_list = [];
786 itemSvc.copy.call_number().id() == -1 ?
787 itemSvc.copy.circ_lib().id() :
788 itemSvc.copy.call_number().owning_lib().id();
790 // there is an extra layer of permissibility over circ
792 egCore.perm.hasPermAt('VIEW_COPY_CHECKOUT_HISTORY', true)
793 .then(function(orgIds) {
795 if (orgIds.indexOf(copy_org) == -1) {
796 console.log('User is not allowed to view circ history');
800 return fetchMaxCircHistory();
802 }).then(function(maxHistCount) {
804 if(!maxHistCount) $scope.isMaxCircHistoryZero = true;
806 egCore.pcrud.search('aacs',
807 {target_copy : copyId},
813 'checkin_workstation',
814 'recurring_fine_rule'
818 order_by : {aacs : 'xact_start desc'},
819 // fetch at least one to see if copy ever circulated
820 limit : $scope.isMaxCircHistoryZero ? 1 : maxHistCount
823 ).then(null, null, function(circ) {
827 // flesh circ_lib locally
828 circ.circ_lib(egCore.org.get(circ.circ_lib()));
829 circ.checkin_lib(egCore.org.get(circ.checkin_lib()));
830 $scope.circ_list.push(circ);
836 function loadCircCounts() {
838 delete $scope.circ_counts;
839 $scope.total_circs = 0;
840 $scope.total_circs_this_year = 0;
841 $scope.total_circs_prev_year = 0;
844 egCore.pcrud.search('circbyyr',
845 {copy : copyId}, null, {atomic : true})
847 .then(function(counts) {
848 $scope.circ_counts = counts;
850 angular.forEach(counts, function(count) {
851 $scope.total_circs += Number(count.count());
854 var this_year = counts.filter(function(c) {
855 return c.year() == new Date().getFullYear();
858 $scope.total_circs_this_year =
859 this_year.length ? this_year[0].count() : 0;
861 var prev_year = counts.filter(function(c) {
862 return c.year() == new Date().getFullYear() - 1;
865 $scope.total_circs_prev_year =
866 prev_year.length ? prev_year[0].count() : 0;
871 function loadHolds() {
875 egCore.pcrud.search('ahr',
876 { current_copy : copyId,
878 fulfillment_time : null,
879 capture_time : {'<>' : null}
883 ahr : ['requestor', 'usr'],
887 ).then(null, null, function(hold) {
889 hold.pickup_lib(egCore.org.get(hold.pickup_lib()));
890 if (hold.current_shelf_lib()) {
891 hold.current_shelf_lib(
892 egCore.org.get(hold.current_shelf_lib()));
894 hold.behind_desk(Boolean(hold.behind_desk() == 't'));
898 function loadMostRecentTransit() {
899 delete $scope.transit;
900 delete $scope.hold_transit;
903 egCore.pcrud.search('atc',
904 {target_copy : copyId},
906 order_by : {atc : 'source_send_time DESC'},
910 ).then(null, null, function(transit) {
911 // use progress callback since we'll get up to one result
912 $scope.transit = transit;
913 transit.source(egCore.org.get(transit.source()));
914 transit.dest(egCore.org.get(transit.dest()));
919 // we don't need all data on all tabs, so fetch what's needed when needed.
920 function loadTabData() {
937 loadMostRecentTransit();
940 case 'triggered_events':
941 var url = $location.absUrl().replace(/\/staff.*/, '/actor/user/event_log');
942 url += '?copy_id=' + encodeURIComponent(copyId);
943 $scope.triggered_events_url = url;
950 'open-ils.actor.anon_cache.set_value',
951 null, 'edit-these-copies', {
952 record_id: $scope.recordId,
957 ).then(function(key) {
959 var url = egCore.env.basePath + 'cat/volcopy/' + key;
960 $window.location.href = url;
962 alert('Could not create anonymous cache key!');
970 $scope.addCopyAlerts = function(copy_id) {
971 egCirc.add_copy_alerts([copy_id]).then(function() {
972 // update grid items?
975 $scope.manageCopyAlerts = function(copy_id) {
976 egCirc.manage_copy_alerts([copy_id]).then(function() {
977 // update grid items?
981 $scope.context.toggleDisplay = function() {
982 $location.path('/cat/item/search');
985 // handle the barcode scan box, which will replace our current copy
986 $scope.context.search = function(args) {
987 loadCopy(args.barcode).then(loadTabData);
990 $scope.context.show_triggered_events = function() {
991 $location.path('/cat/item/' + copyId + '/triggered_events');
994 loadCopy().then(loadTabData);