4 * currently, this app doesn't use routes for each sub-ui, because
5 * reloading the catalog each time is sloooow. better so far to
6 * swap out divs w/ ng-if / ng-show / ng-hide as needed.
10 angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','ngLocationUpdate','egCoreMod','egGridMod', 'egMarcMod', 'egUserMod', 'egHoldingsMod', 'ngToast'])
12 .config(['ngToastProvider', function(ngToastProvider) {
13 ngToastProvider.configure({
14 verticalPosition: 'bottom',
19 .config(function($routeProvider, $locationProvider, $compileProvider) {
20 $locationProvider.html5Mode(true);
21 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export
23 var resolver = {delay : ['egCore','egStartup','egUser', function(egCore, egStartup, egUser) {
24 egCore.env.classLoaders.aous = function() {
25 return egCore.org.settings([
26 'cat.marc_control_number_identifier'
27 ]).then(function(settings) {
28 // local settings are cached within egOrg. Caching them
29 // again in egEnv just simplifies the syntax for access.
30 egCore.env.aous = settings;
33 egCore.env.loadClasses.push('aous');
37 $routeProvider.when('/cat/catalog/index', {
38 templateUrl: './cat/catalog/t_catalog',
39 controller: 'CatalogCtrl',
43 // Jump directly to the results page. Any URL parameter
44 // supported by the embedded catalog is supported here.
45 $routeProvider.when('/cat/catalog/results', {
46 templateUrl: './cat/catalog/t_catalog',
47 controller: 'CatalogCtrl',
51 $routeProvider.when('/cat/catalog/retrieve_by_id', {
52 templateUrl: './cat/catalog/t_retrieve_by_id',
53 controller: 'CatalogRecordRetrieve',
57 $routeProvider.when('/cat/catalog/retrieve_by_tcn', {
58 templateUrl: './cat/catalog/t_retrieve_by_tcn',
59 controller: 'CatalogRecordRetrieve',
63 $routeProvider.when('/cat/catalog/new_bib', {
64 templateUrl: './cat/catalog/t_new_bib',
65 controller: 'NewBibCtrl',
69 // create some catalog page-specific mappings
70 $routeProvider.when('/cat/catalog/record/:record_id', {
71 templateUrl: './cat/catalog/t_catalog',
72 controller: 'CatalogCtrl',
76 // create some catalog page-specific mappings
77 $routeProvider.when('/cat/catalog/record/:record_id/:record_tab', {
78 templateUrl: './cat/catalog/t_catalog',
79 controller: 'CatalogCtrl',
83 $routeProvider.when('/cat/catalog/batchEdit', {
84 templateUrl: './cat/catalog/t_batchedit',
85 controller: 'BatchEditCtrl',
89 $routeProvider.when('/cat/catalog/batchEdit/:container_type/:container_id', {
90 templateUrl: './cat/catalog/t_batchedit',
91 controller: 'BatchEditCtrl',
95 $routeProvider.when('/cat/catalog/vandelay', {
96 templateUrl: './cat/catalog/t_vandelay',
97 controller: 'VandelayCtrl',
101 $routeProvider.when('/cat/catalog/verifyURLs', {
102 templateUrl: './cat/catalog/t_verifyurls',
103 controller: 'URLVerifyCtrl',
107 $routeProvider.when('/cat/catalog/manageAuthorities', {
108 templateUrl: './cat/catalog/t_manageauthorities',
109 controller: 'ManageAuthoritiesCtrl',
113 $routeProvider.when('/cat/catalog/authority/:authority_id/marc_edit', {
114 templateUrl: './cat/catalog/t_authority',
115 controller: 'AuthorityCtrl',
119 $routeProvider.otherwise({redirectTo : '/cat/catalog/index'});
125 .controller('CatalogRecordRetrieve',
126 ['$scope','$routeParams','$location','$q','egCore',
127 function($scope , $routeParams , $location , $q , egCore ) {
129 $scope.focusMe = true;
131 // jump to the patron checkout UI
132 function loadRecord(record_id) {
134 .path('/cat/catalog/record/' + record_id);
137 $scope.submitId = function(args) {
138 $scope.recordNotFound = null;
139 if (!args.record_id) return;
141 // blur so next time it's set to true it will re-apply select()
142 $scope.selectMe = false;
144 return loadRecord(args.record_id);
147 $scope.submitTCN = function(args) {
148 $scope.recordNotFound = null;
149 $scope.moreRecordsFound = null;
150 if (!args.record_tcn) return;
152 // blur so next time it's set to true it will re-apply select()
153 $scope.selectMe = false;
158 'open-ils.search.biblio.tcn',
161 .then(function(resp) { // get_barcodes
163 if (evt = egCore.evt.parse(resp)) {
169 $scope.recordNotFound = args.record_tcn;
170 $scope.selectMe = true;
174 if (resp.count > 1) {
175 $scope.moreRecordsFound = args.record_tcn;
176 $scope.selectMe = true;
180 var record_id = resp.ids[0];
181 return loadRecord(record_id);
187 .controller('NewBibCtrl',
188 ['$scope','$routeParams','$location','$window','$q','egCore',
189 'egGridDataProvider','egHoldGridActions','$timeout','holdingsSvc',
190 function($scope , $routeParams , $location , $window , $q , egCore) {
192 $scope.have_template = false;
193 $scope.marc_template = '';
194 $scope.stop_unload = false;
195 $scope.template_list = [];
196 $scope.template_name = '';
197 $scope.new_bib_id = 0;
201 'open-ils.cat.marc_template.types.retrieve'
202 ).then(function(resp) {
203 angular.forEach(resp, function(name) {
204 $scope.template_list.push(name);
206 $scope.template_list.sort();
208 $scope.template_name = egCore.hatch.getSessionItem('eg.cat.last_bib_marc_template');
209 if (!$scope.template_name) {
210 egCore.hatch.getItem('cat.default_bib_marc_template').then(function(template) {
211 $scope.template_name = template;
215 $scope.loadTemplate = function() {
216 if ($scope.template_name) {
219 'open-ils.cat.biblio.marc_template.retrieve',
221 ).then(function(template) {
222 $scope.marc_template = template;
223 $scope.have_template = true;
224 egCore.hatch.setSessionItem('eg.cat.last_bib_marc_template', $scope.template_name);
229 $scope.setDefaultTemplate = function() {
230 var hatch_key = "cat.default_bib_marc_template";
231 if ($scope.template_name) {
232 egCore.hatch.setItem(hatch_key, $scope.template_name);
234 egCore.hatch.removeItem(hatch_key);
238 $scope.$watch('new_bib_id', function(newVal, oldVal) {
240 $location.path('/cat/catalog/record/' + $scope.new_bib_id);
246 .controller('CatalogCtrl',
247 ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast',
248 'egGridDataProvider','egHoldGridActions','egProgressDialog','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc',
250 function($scope , $routeParams , $location , $window , $q , egCore , egHolds , egCirc , egConfirmDialog , ngToast ,
251 egGridDataProvider , egHoldGridActions , egProgressDialog , $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc,
255 var holdingsSvcInst = new holdingsSvc();
257 // set record ID on page load if available...
258 $scope.record_id = $routeParams.record_id;
259 $scope.summary_pane_record;
261 if ($routeParams.record_id) $scope.from_route = true;
262 else $scope.from_route = false;
264 // set search and preferred library cookies
265 egCore.hatch.getItem('eg.search.search_lib').then(function(val) {
266 $cookies.put('eg_search_lib', val, { path : '/' });
268 egCore.hatch.getItem('eg.search.pref_lib').then(function(val) {
269 $cookies.put('eg_pref_lib', val, { path : '/' });
272 // will hold a ref to the opac iframe
273 $scope.opac_iframe = null;
274 $scope.parts_iframe = null;
276 $scope.search_result_index = 1;
277 $scope.search_result_hit_count = 1;
280 'opac_iframe.dom.contentWindow.search_result_index',
282 if (!isNaN(parseInt(n)))
283 $scope.search_result_index = n + 1;
288 'opac_iframe.dom.contentWindow.search_result_hit_count',
290 if (!isNaN(parseInt(n)))
291 $scope.search_result_hit_count = n;
295 $scope.in_opac_call = false;
296 $scope.opac_call = function (opac_frame_function, force_opac_tab) {
297 if ($scope.opac_iframe) {
298 if (force_opac_tab) $scope.record_tab = 'catalog';
299 $scope.in_opac_call = true;
300 $scope.opac_iframe.dom.contentWindow[opac_frame_function]();
301 if (opac_frame_function == 'rdetailBackToResults') {
302 $location.update_path('/cat/catalog/index');
307 $scope.add_to_record_bucket = function() {
308 var recId = $scope.record_id;
309 return $uibModal.open({
310 templateUrl: './cat/catalog/t_add_to_bucket',
314 ['$scope','$uibModalInstance',
315 function($scope , $uibModalInstance) {
317 $scope.bucket_id = 0;
318 $scope.newBucketName = '';
319 $scope.allBuckets = [];
322 'open-ils.actor.container.retrieve_by_class.authoritative',
323 egCore.auth.token(), egCore.auth.user().id(),
324 'biblio', 'staff_client'
325 ).then(function(buckets) { $scope.allBuckets = buckets; });
327 $scope.add_to_bucket = function() {
328 var item = new egCore.idl.cbrebi();
329 item.bucket($scope.bucket_id);
330 item.target_biblio_record_entry(recId);
333 'open-ils.actor.container.item.create',
334 egCore.auth.token(), 'biblio', item
335 ).then(function(resp) {
336 $uibModalInstance.close();
340 $scope.add_to_new_bucket = function() {
341 var bucket = new egCore.idl.cbreb();
342 bucket.owner(egCore.auth.user().id());
343 bucket.name($scope.newBucketName);
344 bucket.description('');
345 bucket.btype('staff_client');
349 'open-ils.actor.container.create',
350 egCore.auth.token(), 'biblio', bucket
351 ).then(function(bucket) {
352 $scope.bucket_id = bucket;
353 $scope.add_to_bucket();
357 $scope.cancel = function() {
358 $uibModalInstance.dismiss();
364 $scope.current_overlay_target = egCore.hatch.getLocalItem('eg.cat.marked_overlay_record');
365 $scope.current_voltransfer_target = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
366 $scope.current_conjoined_target = egCore.hatch.getLocalItem('eg.cat.marked_conjoined_record');
368 $scope.markConjoined = function () {
369 $scope.current_conjoined_target = $scope.record_id;
370 egCore.hatch.setLocalItem('eg.cat.marked_conjoined_record',$scope.record_id);
371 ngToast.create(egCore.strings.MARK_CONJ_TARGET);
374 $scope.markVolTransfer = function () {
375 ngToast.create(egCore.strings.MARK_VOL_TARGET);
376 $scope.current_voltransfer_target = $scope.record_id;
377 egCore.hatch.setLocalItem('eg.cat.marked_volume_transfer_record',$scope.record_id);
380 $scope.markOverlay = function () {
381 $scope.current_overlay_target = $scope.record_id;
382 egCore.hatch.setLocalItem('eg.cat.marked_overlay_record',$scope.record_id);
383 ngToast.create(egCore.strings.MARK_OVERLAY_TARGET);
386 $scope.clearRecordMarks = function () {
387 $scope.current_overlay_target = null;
388 $scope.current_voltransfer_target = null;
389 $scope.current_conjoined_target = null;
390 $scope.current_hold_transfer_dest = null;
391 egCore.hatch.removeLocalItem('eg.cat.marked_volume_transfer_record');
392 egCore.hatch.removeLocalItem('eg.cat.marked_conjoined_record');
393 egCore.hatch.removeLocalItem('eg.cat.marked_overlay_record');
394 egCore.hatch.removeLocalItem('eg.circ.hold.title_transfer_target');
397 $scope.stop_unload = false;
398 $scope.$watch('stop_unload',
399 function(newVal, oldVal) {
400 if (newVal && newVal != oldVal && $scope.opac_iframe) {
401 $($scope.opac_iframe.dom.contentWindow).on('beforeunload', function(){
402 return 'There is unsaved data in this record.'
405 if ($scope.opac_iframe)
406 $($scope.opac_iframe.dom.contentWindow).off('beforeunload');
411 // Set the "last bib" cookie, if we have that
412 if ($scope.record_id)
413 egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
415 $scope.refresh_record_callback = function (record_id) {
416 egCore.pcrud.retrieve('bre', record_id, {
419 bre : ['simple_record','creator','editor']
421 }).then(function(rec) {
422 rec.owner(egCore.org.get(rec.owner()));
423 $scope.summary_pane_record = rec;
429 // also set it when the iframe changes to a new record
430 $scope.handle_page = function(url) {
432 if (!url || url == 'about:blank') {
433 // nothing loaded. If we already have a record ID, leave it.
437 var match = url.match(/\/+opac\/+record\/+(\d+)/);
439 $scope.record_id = match[1];
440 egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
441 $scope.holdings_record_id_changed($scope.record_id);
442 conjoinedSvc.fetch($scope.record_id).then(function(){
443 $scope.conjoinedGridDataProvider.refresh();
445 egHolds.fetch_holds(hold_ids).then($scope.hold_grid_data_provider.refresh);
447 $location.update_path('/cat/catalog/record/' + $scope.record_id);
449 delete $scope.record_id;
450 $scope.from_route = false;
453 // child scope is executing this function, so our digest doesn't fire ... thus,
456 if (!$scope.in_opac_call) {
457 if ($scope.record_id) {
458 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
459 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
461 tab = $routeParams.record_tab || 'catalog';
463 $scope.set_record_tab(tab);
465 $scope.in_opac_call = false;
469 // xulG catalog handlers
470 $scope.handlers = { }
472 // ------------------------------------------------------------------
475 $scope.conjoinedGridControls = {};
476 $scope.conjoinedGridDataProvider = egGridDataProvider.instance({
477 get : function(offset, count) {
478 return this.arrayNotifier(conjoinedSvc.items, offset, count);
482 $scope.changeConjoinedType = function () {
483 var peers = egCore.idl.Clone($scope.conjoinedGridControls.selectedItems());
484 angular.forEach(peers, function (p) {
485 p.target_copy(p.target_copy().id());
486 p.peer_type(p.peer_type().id());
489 var conjoinedGridDataProviderRef = $scope.conjoinedGridDataProvider;
491 return $uibModal.open({
492 templateUrl: './cat/catalog/t_conjoined_selector',
495 ['$scope','$uibModalInstance',
496 function($scope , $uibModalInstance) {
497 $scope.update = true;
499 $scope.peer_type = null;
500 $scope.peer_type_list = [];
501 conjoinedSvc.get_peer_types().then(function(list){
502 $scope.peer_type_list = list;
505 $scope.ok = function(type) {
508 angular.forEach(peers, function (p) {
511 promises.push(egCore.pcrud.update(p));
514 return $q.all(promises)
515 .then(function(){$uibModalInstance.close()})
516 .then(function(){return conjoinedSvc.fetch()})
517 .then(function(){conjoinedGridDataProviderRef.refresh()});
520 $scope.cancel = function($event) {
521 $uibModalInstance.dismiss();
522 $event.preventDefault();
529 $scope.refreshConjoined = function () {
530 conjoinedSvc.fetch($scope.record_id)
531 .then(function(){$scope.conjoinedGridDataProvider.refresh();});
534 $scope.deleteSelectedConjoined = function () {
535 var peers = $scope.conjoinedGridControls.selectedItems();
537 if (peers.length > 0) {
538 egConfirmDialog.open(
539 egCore.strings.CONFIRM_DELETE_PEERS,
540 egCore.strings.CONFIRM_DELETE_PEERS_MESSAGE,
541 {peers : peers.length}
542 ).result.then(function() {
543 angular.forEach(peers, function (p) {
547 egCore.pcrud.remove(peers).then(function() {
548 return conjoinedSvc.fetch();
550 $scope.conjoinedGridDataProvider.refresh();
555 if ($scope.record_id)
556 conjoinedSvc.fetch($scope.record_id);
558 // ------------------------------------------------------------------
561 $scope.holdingsGridControls = {
562 activateItem : function (item) {
563 $scope.selectedHoldingsVolCopyEdit();
566 $scope.holdingsGridDataProvider = egGridDataProvider.instance({
567 get : function(offset, count) {
568 return this.arrayNotifier(holdingsSvcInst.copies, offset, count);
572 $scope.add_copies_to_bucket = function() {
573 var copy_list = gatherSelectedHoldingsIds();
574 if (copy_list.length == 0) return;
576 return $uibModal.open({
577 templateUrl: './cat/catalog/t_add_to_bucket',
581 ['$scope','$uibModalInstance',
582 function($scope , $uibModalInstance) {
584 $scope.bucket_id = 0;
585 $scope.newBucketName = '';
586 $scope.allBuckets = [];
590 'open-ils.actor.container.retrieve_by_class.authoritative',
591 egCore.auth.token(), egCore.auth.user().id(),
592 'copy', 'staff_client'
593 ).then(function(buckets) { $scope.allBuckets = buckets; });
595 $scope.add_to_bucket = function() {
597 angular.forEach(copy_list, function (cp) {
598 var item = new egCore.idl.ccbi()
599 item.bucket($scope.bucket_id);
600 item.target_copy(cp);
604 'open-ils.actor.container.item.create',
605 egCore.auth.token(), 'copy', item
609 return $q.all(promises).then(function() {
610 $uibModalInstance.close();
615 $scope.add_to_new_bucket = function() {
616 var bucket = new egCore.idl.ccb();
617 bucket.owner(egCore.auth.user().id());
618 bucket.name($scope.newBucketName);
619 bucket.description('');
620 bucket.btype('staff_client');
622 return egCore.net.request(
624 'open-ils.actor.container.create',
625 egCore.auth.token(), 'copy', bucket
626 ).then(function(bucket) {
627 $scope.bucket_id = bucket;
628 $scope.add_to_bucket();
632 $scope.cancel = function() {
633 $uibModalInstance.dismiss();
639 // TODO: refactor common code between cat/catalog/app.js and cat/item/app.js
641 $scope.need_one_selected = function() {
642 var items = $scope.holdingsGridControls.selectedItems();
643 if (items.length == 1) return false;
647 $scope.make_copies_bookable = function() {
649 var copies_by_record = {};
650 var record_list = [];
652 $scope.holdingsGridControls.selectedItems(),
654 var record_id = item['call_number.record.id'];
655 if (typeof copies_by_record[ record_id ] == 'undefined') {
656 copies_by_record[ record_id ] = [];
657 record_list.push( record_id );
659 copies_by_record[ record_id ].push(item.id);
664 var combined_results = [];
665 angular.forEach(record_list, function(record_id) {
669 'open-ils.booking.resources.create_from_copies',
671 copies_by_record[record_id]
672 ).then(function(results) {
673 if (results && results['brsrc']) {
674 combined_results = combined_results.concat(results['brsrc']);
680 $q.all(promises).then(function() {
681 if (combined_results.length > 0) {
683 template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
687 ['$scope','$location','egCore','$uibModalInstance',
688 function($scope , $location , egCore , $uibModalInstance) {
691 ses : egCore.auth.token(),
692 resultant_brsrc : combined_results.map(function(o) { return o[0]; })
695 var booking_path = '/eg/conify/global/booking/resource';
697 $scope.booking_admin_url =
698 $location.absUrl().replace(/\/eg\/staff.*/, booking_path);
705 $scope.book_copies_now = function() {
706 var copies_by_record = {};
707 var record_list = [];
709 $scope.holdingsGridControls.selectedItems(),
711 var record_id = item['call_number.record.id'];
712 if (typeof copies_by_record[ record_id ] == 'undefined') {
713 copies_by_record[ record_id ] = [];
714 record_list.push( record_id );
716 copies_by_record[ record_id ].push(item.id);
721 var combined_brt = [];
722 var combined_brsrc = [];
723 angular.forEach(record_list, function(record_id) {
727 'open-ils.booking.resources.create_from_copies',
729 copies_by_record[record_id]
730 ).then(function(results) {
731 if (results && results['brt']) {
732 combined_brt = combined_brt.concat(results['brt']);
734 if (results && results['brsrc']) {
735 combined_brsrc = combined_brsrc.concat(results['brsrc']);
741 $q.all(promises).then(function() {
742 if (combined_brt.length > 0 || combined_brsrc.length > 0) {
744 template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
748 ['$scope','$location','egCore','$uibModalInstance',
749 function($scope , $location , egCore , $uibModalInstance) {
752 ses : egCore.auth.token(),
753 bresv_interface_opts : {
756 ,brsrc : combined_brsrc
761 var booking_path = '/eg/booking/reservation';
763 $scope.booking_admin_url =
764 $location.absUrl().replace(/\/eg\/staff.*/, booking_path);
773 $scope.requestItems = function() {
774 var copy_list = gatherSelectedHoldingsIds();
775 if (copy_list.length == 0) return;
777 return $uibModal.open({
778 templateUrl: './cat/catalog/t_request_items',
781 ['$scope','$uibModalInstance',
782 function($scope , $uibModalInstance) {
784 $scope.first_user_fetch = true;
788 copy_list : copy_list,
789 pickup_lib: egCore.org.get(egCore.auth.user().ws_ou()),
790 user : egCore.auth.user().id()
793 egUser.get( $scope.hold_data.user ).then(function(u) {
795 $scope.barcode = u.card().barcode();
796 $scope.user_name = egUser.format_name(u);
797 $scope.hold_data.user = u.id();
800 $scope.user_name = '';
802 $scope.$watch('barcode', function (n) {
803 if (!$scope.first_user_fetch) {
804 egUser.getByBarcode(n).then(function(u) {
806 $scope.user_name = egUser.format_name(u);
807 $scope.hold_data.user = u.id();
810 $scope.user_name = '';
811 delete $scope.hold_data.user;
814 $scope.first_user_fetch = false;
817 $scope.ok = function(h) {
820 hold_type : h.hold_type,
821 pickup_lib: h.pickup_lib.id(),
827 'open-ils.circ.holds.test_and_create.batch.override',
828 egCore.auth.token(), args, h.copy_list
831 $uibModalInstance.close();
834 $scope.cancel = function($event) {
835 $uibModalInstance.dismiss();
836 $event.preventDefault();
842 $scope.view_place_orders = function() {
843 if (!$scope.record_id) return;
844 var url = egCore.env.basePath + 'acq/legacy/lineitem/related/' + $scope.record_id + '?target=bib';
845 $timeout(function() { $window.open(url, '_blank') });
848 $scope.replaceBarcodes = function() {
849 var copy_list = gatherSelectedRawCopies();
850 if (copy_list.length == 0) return;
852 var holdingsGridDataProviderRef = $scope.holdingsGridDataProvider;
854 angular.forEach(copy_list, function (cp) {
856 templateUrl: './cat/share/t_replace_barcode',
859 ['$scope','$uibModalInstance',
860 function($scope , $uibModalInstance) {
861 $scope.isModal = true;
862 $scope.focusBarcode = false;
863 $scope.focusBarcode2 = true;
864 $scope.barcode1 = cp.barcode();
866 $scope.updateBarcode = function() {
867 $scope.copyNotFound = false;
868 $scope.updateOK = false;
870 egCore.pcrud.search('acp',
871 {deleted : 'f', barcode : $scope.barcode1})
872 .then(function(copy) {
875 $scope.focusBarcode = true;
876 $scope.copyNotFound = true;
880 $scope.copyId = copy.id();
881 copy.barcode($scope.barcode2);
883 egCore.pcrud.update(copy).then(function(stat) {
884 $scope.updateOK = stat;
885 $scope.focusBarcode = true;
886 holdingsSvc.fetchAgain().then(function (){
887 holdingsGridDataProviderRef.refresh();
892 $uibModalInstance.close();
895 $scope.cancel = function($event) {
896 $uibModalInstance.dismiss();
897 $event.preventDefault();
905 // refresh the list of holdings when the record_id is changed.
906 $scope.holdings_record_id_changed = function(id) {
907 if ($scope.record_id != id) $scope.record_id = id;
908 console.log('record id changed to ' + id + ', loading new holdings');
909 holdingsSvcInst.fetch({
910 rid : $scope.record_id,
911 org : $scope.holdings_ou,
912 copy: $scope.holdings_show_copies,
913 vol : $scope.holdings_show_vols,
914 empty: $scope.holdings_show_empty
916 $scope.holdingsGridDataProvider.refresh();
920 // refresh the list of holdings when the filter lib is changed.
921 $scope.holdings_ou = egCore.org.get(egCore.auth.user().ws_ou());
922 $scope.holdings_ou_changed = function(org) {
923 $scope.holdings_ou = org;
924 holdingsSvcInst.fetch({
925 rid : $scope.record_id,
926 org : $scope.holdings_ou,
927 copy: $scope.holdings_show_copies,
928 vol : $scope.holdings_show_vols,
929 empty: $scope.holdings_show_empty
931 $scope.holdingsGridDataProvider.refresh();
935 $scope.holdings_cb_changed = function(cb,newVal,norefresh) {
937 egCore.hatch.setItem('cat.' + cb, newVal);
938 if (!norefresh) holdingsSvcInst.fetch({
939 rid : $scope.record_id,
940 org : $scope.holdings_ou,
941 copy: $scope.holdings_show_copies,
942 vol : $scope.holdings_show_vols,
943 empty: $scope.holdings_show_empty
945 $scope.holdingsGridDataProvider.refresh();
949 egCore.hatch.getItem('cat.holdings_show_vols').then(function(x){
950 if (typeof x == 'undefined') x = true;
951 $scope.holdings_cb_changed('holdings_show_vols',x,true);
952 $('#holdings_show_vols').prop('checked', x);
954 egCore.hatch.getItem('cat.holdings_show_copies').then(function(x){
955 if (typeof x == 'undefined') x = true;
956 $scope.holdings_cb_changed('holdings_show_copies',x,true);
957 $('#holdings_show_copies').prop('checked', x);
959 egCore.hatch.getItem('cat.holdings_show_empty').then(function(x){
960 if (typeof x == 'undefined') x = true;
961 $scope.holdings_cb_changed('holdings_show_empty',x);
962 $('#holdings_show_empty').prop('checked', x);
967 $scope.vols_not_shown = function () {
968 return !$scope.holdings_show_vols;
971 $scope.copies_not_shown = function () {
972 return !$scope.holdings_show_copies;
975 $scope.holdings_checkbox_handler = function (item) {
976 $scope.holdings_cb_changed(item.checkbox,item.checked);
979 function gatherSelectedHoldingsIds () {
982 $scope.holdingsGridControls.selectedItems(),
983 function (item) { cp_id_list = cp_id_list.concat(item.id_list) }
988 function gatherSelectedRawCopies () {
991 $scope.holdingsGridControls.selectedItems(),
992 function (item) { if (item.raw) cp_list = cp_list.concat(item.raw) }
997 function gatherSelectedEmptyVolumeIds () {
1000 $scope.holdingsGridControls.selectedItems(),
1002 if (item.copy_count == 0)
1003 cn_id_list.push(item.call_number.id)
1009 function gatherSelectedVolumeIds () {
1010 var cn_id_list = [];
1012 $scope.holdingsGridControls.selectedItems(),
1014 if (cn_id_list.indexOf(item.call_number.id) == -1)
1015 cn_id_list.push(item.call_number.id)
1021 $scope.selectedHoldingsDelete = function (vols, copies) {
1024 var perCnCopies = {};
1030 $scope.holdingsGridControls.selectedItems(),
1032 if (vols && item.raw_call_number) {
1033 cnHash[item.call_number.id] = egCore.idl.Clone(item.raw_call_number);
1034 cnHash[item.call_number.id].isdeleted(1);
1036 } else if (copies) {
1037 angular.forEach(egCore.idl.Clone(item.raw), function (cp) {
1040 var cn_id = cp.call_number().id();
1041 if (!cnHash[cn_id]) {
1042 cnHash[cn_id] = cp.call_number();
1043 perCnCopies[cn_id] = [cp];
1045 perCnCopies[cn_id].push(cp);
1047 cp.call_number(cn_id); // prevent loops in JSON-ification
1054 angular.forEach(perCnCopies, function (v, k) {
1056 cnHash[k].isdeleted(1);
1059 cnHash[k].copies(v);
1063 angular.forEach(cnHash, function (v, k) {
1067 if (cnList.length == 0) return;
1070 if (vols && copies) flags.force_delete_copies = 1;
1072 egConfirmDialog.open(
1073 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES,
1074 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES_MESSAGE,
1075 {copies : cp_count, volumes : cn_count}
1076 ).result.then(function() {
1079 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1080 egCore.auth.token(), cnList, 1, flags
1081 ).then(function(update_count) {
1082 holdingsSvcInst.fetchAgain().then(function() {
1083 $scope.holdingsGridDataProvider.refresh();
1088 $scope.selectedHoldingsCopyDelete = function () { $scope.selectedHoldingsDelete(false,true) }
1089 $scope.selectedHoldingsVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,true) }
1090 $scope.selectedHoldingsEmptyVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,false) }
1092 spawnHoldingsAdd = function (vols,copies){
1094 if (copies) { // just a copy on existing volumes
1095 angular.forEach(gatherSelectedVolumeIds(), function (v) {
1096 raw.push( {callnumber : v} );
1099 if (typeof $scope.holdingsGridControls.selectedItems == "function" &&
1100 $scope.holdingsGridControls.selectedItems().length > 0) {
1101 angular.forEach($scope.holdingsGridControls.selectedItems(),
1104 owner : item.owner_id,
1105 label : item.call_number.label
1110 owner : egCore.auth.user().ws_ou()
1115 if (raw.length == 0) raw.push({});
1119 'open-ils.actor.anon_cache.set_value',
1120 null, 'edit-these-copies', {
1121 record_id: $scope.record_id,
1126 ).then(function(key) {
1128 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1129 $timeout(function() { $window.open(url, '_blank') });
1131 alert('Could not create anonymous cache key!');
1135 $scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,false) }
1136 $scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true) }
1138 spawnHoldingsEdit = function (hide_vols,hide_copies){
1141 'open-ils.actor.anon_cache.set_value',
1142 null, 'edit-these-copies', {
1143 record_id: $scope.record_id,
1144 copies: gatherSelectedHoldingsIds(),
1145 raw: gatherSelectedEmptyVolumeIds().map(
1146 function(v){ return { callnumber : v } }
1148 hide_vols : hide_vols,
1149 hide_copies : hide_copies
1151 ).then(function(key) {
1153 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1154 $timeout(function() { $window.open(url, '_blank') });
1156 alert('Could not create anonymous cache key!');
1160 $scope.selectedHoldingsVolCopyEdit = function () { spawnHoldingsEdit(false,false) }
1161 $scope.selectedHoldingsVolEdit = function () { spawnHoldingsEdit(false,true) }
1162 $scope.selectedHoldingsCopyEdit = function () { spawnHoldingsEdit(true,false) }
1164 $scope.selectedHoldingsItemStatus = function (){
1165 var url = egCore.env.basePath + 'cat/item/search/' + gatherSelectedHoldingsIds().join(',')
1166 $timeout(function() { $window.open(url, '_blank') });
1169 $scope.markVolAsItemTarget = function() {
1170 if ($scope.holdingsGridControls.selectedItems()[0].call_number.id) { // cn.id missing when vols are collapsed
1171 egCore.hatch.setLocalItem(
1172 'eg.cat.item_transfer_target',
1173 $scope.holdingsGridControls.selectedItems()[0].call_number.id
1175 ngToast.create(egCore.strings.MARK_ITEM_TARGET);
1179 $scope.markLibAsVolTarget = function() {
1180 return $uibModal.open({
1181 templateUrl: './cat/catalog/t_choose_vol_target_lib',
1184 ['$scope','$uibModalInstance',
1185 function($scope , $uibModalInstance) {
1187 var orgId = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target') || 1;
1188 $scope.org = egCore.org.get(orgId);
1189 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1190 $scope.ok = function(org) {
1191 egCore.hatch.setLocalItem(
1192 'eg.cat.volume_transfer_target',
1195 $uibModalInstance.close();
1197 $scope.cancel = function($event) {
1198 $uibModalInstance.dismiss();
1199 $event.preventDefault();
1204 $scope.markLibFromSelectedAsVolTarget = function() {
1205 egCore.hatch.setLocalItem(
1206 'eg.cat.volume_transfer_target',
1207 $scope.holdingsGridControls.selectedItems()[0].owner_id
1209 ngToast.create(egCore.strings.MARK_VOL_TARGET);
1212 $scope.selectedHoldingsItemStatusDetail = function (){
1214 gatherSelectedHoldingsIds(),
1216 var url = egCore.env.basePath +
1218 $timeout(function() { $window.open(url, '_blank') });
1223 $scope.transferVolumesToRecord = function (){
1224 var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
1225 if (!target_record) return;
1226 if ($scope.record_id == target_record) return;
1227 var items = $scope.holdingsGridControls.selectedItems();
1228 if (!items.length) return;
1230 var vols_to_move = {};
1231 angular.forEach(items, function(item) {
1232 if (!(item.call_number.owning_lib in vols_to_move)) {
1233 vols_to_move[item.call_number.owning_lib] = new Array;
1235 vols_to_move[item.call_number.owning_lib].push(item.call_number.id);
1239 angular.forEach(vols_to_move, function(vols, owning_lib) {
1240 promises.push(egCore.net.request(
1242 'open-ils.cat.asset.volume.batch.transfer.override',
1243 egCore.auth.token(), {
1244 docid : target_record,
1250 $q.all(promises).then(function(success) {
1252 ngToast.create(egCore.strings.VOLS_TRANSFERED);
1253 holdingsSvcInst.fetchAgain().then(function() {
1254 $scope.holdingsGridDataProvider.refresh();
1257 alert('Could not transfer volumes!');
1262 function transferVolumes(new_record){
1263 var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
1268 'open-ils.cat.asset.volume.batch.transfer.override',
1269 egCore.auth.token(), {
1270 docid : (new_record ? new_record : $scope.record_id),
1272 volumes : gatherSelectedVolumeIds()
1274 ).then(function(success) {
1276 ngToast.create(egCore.strings.VOLS_TRANSFERED);
1277 holdingsSvcInst.fetchAgain().then(function() {
1278 $scope.holdingsGridDataProvider.refresh();
1281 alert('Could not transfer volumes!');
1288 $scope.transferVolumesToLibrary = function() {
1292 $scope.transferVolumesToRecordAndLibrary = function() {
1293 var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
1294 if (!target_record) return;
1295 transferVolumes(target_record);
1298 // this "transfers" selected copies to a new owning library,
1299 // auto-creating volumes and deleting unused volumes as required.
1300 $scope.changeItemOwningLib = function() {
1301 var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
1302 var items = $scope.holdingsGridControls.selectedItems();
1303 if (!xfer_target || !items.length) {
1306 var vols_to_move = {};
1307 var copies_to_move = {};
1308 angular.forEach(items, function(item) {
1309 if (item.call_number.owning_lib != xfer_target) {
1310 if (item.call_number.id in vols_to_move) {
1311 copies_to_move[item.call_number.id].push(item.id);
1313 vols_to_move[item.call_number.id] = item.call_number;
1314 copies_to_move[item.call_number.id] = new Array;
1315 copies_to_move[item.call_number.id].push(item.id);
1321 angular.forEach(vols_to_move, function(vol) {
1322 promises.push(egCore.net.request(
1324 'open-ils.cat.call_number.find_or_create',
1325 egCore.auth.token(),
1332 ).then(function(resp) {
1333 var evt = egCore.evt.parse(resp);
1335 return egCore.net.request(
1337 'open-ils.cat.transfer_copies_to_volume',
1338 egCore.auth.token(),
1340 copies_to_move[vol.id]
1344 $q.all(promises).then(function() {
1345 ngToast.create(egCore.strings.ITEMS_TRANSFERED);
1346 holdingsSvcInst.fetchAgain().then(function() {
1347 $scope.holdingsGridDataProvider.refresh();
1352 $scope.transferItems = function (){
1353 var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
1354 var copy_ids = gatherSelectedHoldingsIds();
1355 if (xfer_target && copy_ids.length > 0) {
1358 'open-ils.cat.transfer_copies_to_volume',
1359 egCore.auth.token(),
1363 function(resp) { // oncomplete
1364 var evt = egCore.evt.parse(resp);
1366 egConfirmDialog.open(
1367 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
1368 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
1369 {'evt_desc': evt.desc}
1370 ).result.then(function() {
1373 'open-ils.cat.transfer_copies_to_volume.override',
1374 egCore.auth.token(),
1377 { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
1378 ).then(function(resp) {
1379 holdingsSvcInst.fetchAgain().then(function() {
1380 $scope.holdingsGridDataProvider.refresh();
1385 ngToast.create(egCore.strings.ITEMS_TRANSFERED);
1386 holdingsSvcInst.fetchAgain().then(function() {
1387 $scope.holdingsGridDataProvider.refresh();
1397 $scope.selectedHoldingsItemStatusTgrEvt = function (){
1399 gatherSelectedHoldingsIds(),
1401 var url = egCore.env.basePath +
1402 'cat/item/' + cid + '/triggered_events';
1403 $timeout(function() { $window.open(url, '_blank') });
1408 $scope.selectedHoldingsItemStatusHolds = function (){
1410 gatherSelectedHoldingsIds(),
1412 var url = egCore.env.basePath +
1413 'cat/item/' + cid + '/holds';
1414 $timeout(function() { $window.open(url, '_blank') });
1419 $scope.selectedHoldingsDamaged = function () {
1420 egCirc.mark_damaged(gatherSelectedHoldingsIds()).then(function() {
1421 holdingsSvcInst.fetchAgain().then(function() {
1422 $scope.holdingsGridDataProvider.refresh();
1427 $scope.selectedHoldingsMissing = function () {
1428 egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() {
1429 holdingsSvcInst.fetchAgain().then(function() {
1430 $scope.holdingsGridDataProvider.refresh();
1435 $scope.attach_to_peer_bib = function() {
1436 var copy_list = gatherSelectedHoldingsIds();
1437 if (copy_list.length == 0) return;
1439 egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
1440 if (!target_record) return;
1442 return $uibModal.open({
1443 templateUrl: './cat/catalog/t_conjoined_selector',
1446 ['$scope','$uibModalInstance',
1447 function($scope , $uibModalInstance) {
1448 $scope.update = false;
1450 $scope.peer_type = null;
1451 $scope.peer_type_list = [];
1452 conjoinedSvc.get_peer_types().then(function(list){
1453 $scope.peer_type_list = list;
1456 $scope.ok = function(type) {
1459 angular.forEach(copy_list, function (cp) {
1460 var n = new egCore.idl.bpbcm();
1462 n.peer_record(target_record);
1465 promises.push(egCore.pcrud.create(n));
1468 return $q.all(promises).then(function(){$uibModalInstance.close()});
1471 $scope.cancel = function($event) {
1472 $uibModalInstance.dismiss();
1473 $event.preventDefault();
1481 // ------------------------------------------------------------------
1483 var provider = egGridDataProvider.instance({});
1484 $scope.hold_grid_data_provider = provider;
1485 $scope.grid_actions = egHoldGridActions;
1486 $scope.grid_actions.refresh = function () { provider.refresh() };
1487 $scope.hold_grid_controls = {};
1489 var hold_ids = []; // current list of holds
1490 function fetchHolds(offset, count) {
1491 var ids = hold_ids.slice(offset, offset + count);
1493 return egHolds.fetch_holds(ids).then(null, null,
1494 function(hold_data) {
1500 provider.get = function(offset, count) {
1501 if ($scope.record_tab != 'holds') return $q.when();
1502 var deferred = $q.defer();
1503 hold_ids = []; // no caching ATM
1505 // open a determinate progress dialog, max value set below.
1506 egProgressDialog.open({max : 1, value : 0});
1511 'open-ils.circ.holds.retrieve_all_from_title',
1512 egCore.auth.token(), $scope.record_id,
1513 {pickup_lib : egCore.org.descendants($scope.pickup_ou.id(), true)}
1515 function(hold_data) {
1516 hold_ids = []; // clear the list of ids, hack to avoid dups
1517 // TODO: fix the underlying problem, which is that
1518 // this gets called twice when switching to the holds
1519 // tab; once explicitly, and once via the change handler
1520 // on the OU selector
1521 angular.forEach(hold_data, function(list, type) {
1522 hold_ids = hold_ids.concat(list);
1525 // Set the max value of the progress bar to the lesser of
1526 // the total number of holds to fetch or the page size
1528 egProgressDialog.update(
1529 {max : Math.min(hold_ids.length, count)});
1531 var holds_fetched = 0;
1532 fetchHolds(offset, count)
1533 .then(deferred.resolve, null,
1534 function(hold_data) {
1536 deferred.notify(hold_data);
1537 egProgressDialog.increment();
1539 )['finally'](egProgressDialog.close);
1543 return deferred.promise;
1546 $scope.detail_view = function(action, user_data, items) {
1548 $scope.detail_hold_id = h.hold.id();
1552 $scope.list_view = function(items) {
1553 $scope.detail_hold_id = null;
1556 // refresh the list of record holds when the pickup lib is changed.
1557 $scope.pickup_ou = egCore.org.get(egCore.auth.user().ws_ou());
1558 $scope.pickup_ou_changed = function(org) {
1559 $scope.pickup_ou = org;
1563 $scope.print_holds = function() {
1565 angular.forEach($scope.hold_grid_controls.allItems(), function(item) {
1567 hold : egCore.idl.toHash(item.hold),
1568 patron_last : item.patron_last,
1569 patron_alias : item.patron_alias,
1570 patron_barcode : item.patron_barcode,
1571 copy : egCore.idl.toHash(item.copy),
1572 volume : egCore.idl.toHash(item.volume),
1573 title : item.mvr.title(),
1574 author : item.mvr.author()
1578 egCore.print.print({
1579 context : 'receipt',
1580 template : 'holds_for_bib',
1581 scope : {holds : holds}
1585 $scope.current_hold_transfer_dest = egCore.hatch.getLocalItem ('eg.circ.hold.title_transfer_target');
1587 $scope.mark_hold_transfer_dest = function() {
1588 $scope.current_hold_transfer_dest = $scope.record_id;
1589 egCore.hatch.setLocalItem(
1590 'eg.circ.hold.title_transfer_target', $scope.record_id);
1591 ngToast.create(egCore.strings.HOLD_TRANSFER_DEST_MARKED);
1594 // UI presents this option as "all holds"
1595 $scope.transfer_holds_to_marked = function() {
1596 var hold_ids = $scope.hold_grid_controls.allItems().map(
1597 function(hold_data) {return hold_data.hold.id()});
1598 egHolds.transfer_to_marked_title(hold_ids);
1601 // ------------------------------------------------------------------
1602 // Initialize the selected tab
1604 function init_cat_url() {
1605 // Set the initial catalog URL. This only happens once.
1606 // The URL is otherwise generated through user navigation.
1607 if ($scope.catalog_url) return;
1609 var url = $location.absUrl().replace(/\/staff.*/, '/opac/advanced');
1611 // A record ID in the path indicates a request for the record-
1613 if ($routeParams.record_id) {
1614 url = url.replace(/advanced/, '/record/' + $scope.record_id);
1617 // Jumping directly to the results page by passing a search
1618 // query via the URL. Copy all URL params to the iframe url.
1619 if ($location.path().match(/catalog\/results/)) {
1620 url = url.replace(/advanced/, '/results?');
1622 angular.forEach($location.search(), function(val, key) {
1623 if (!first) url += '&';
1625 url += encodeURIComponent(key)
1626 + '=' + encodeURIComponent(val);
1630 // if we're displaying the advanced search form, select
1631 // whatever default pane the user has chosen via workstation
1633 if (url.match(/\/opac\/advanced$/)) {
1634 var adv_pane = egCore.hatch.getLocalItem('eg.search.adv_pane');
1636 url += '?pane=' + encodeURIComponent(adv_pane);
1640 $scope.catalog_url = url;
1643 function init_parts_url() {
1644 $scope.parts_url = $location
1648 '/conify/global/biblio/monograph_part?r='+$scope.record_id
1652 $scope.set_record_tab = function(tab) {
1653 $scope.record_tab = tab;
1666 $scope.detail_hold_record_id = $scope.record_id;
1667 // refresh the holds grid
1674 $scope.set_default_record_tab = function() {
1675 egCore.hatch.setLocalItem(
1676 'eg.cat.default_record_tab', $scope.record_tab);
1677 $timeout(function(){$scope.default_tab = $scope.record_tab});
1681 if ($scope.record_id) {
1682 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
1683 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
1686 tab = $routeParams.record_tab || 'catalog';
1688 $scope.set_record_tab(tab);
1692 .controller('AuthorityCtrl',
1693 ['$scope','$routeParams','$location','$window','$q','egCore',
1694 function($scope , $routeParams , $location , $window , $q , egCore) {
1696 // set record ID on page load if available...
1697 $scope.authority_id = $routeParams.authority_id;
1699 if ($routeParams.authority_id) $scope.from_route = true;
1700 else $scope.from_route = false;
1702 $scope.stop_unload = false;
1705 .controller('URLVerifyCtrl',
1706 ['$scope','$location',
1707 function($scope , $location) {
1708 $scope.verifyurls_url = $location.absUrl().replace(/\/staff.*/, '/url_verify/sessions');
1711 .controller('VandelayCtrl',
1712 ['$scope','$location',
1713 function($scope , $location) {
1714 $scope.vandelay_url = $location.absUrl().replace(/\/staff\/cat\/catalog\/vandelay/, '/vandelay/vandelay');
1717 .controller('ManageAuthoritiesCtrl',
1718 ['$scope','$location',
1719 function($scope , $location) {
1720 $scope.manageauthorities_url = $location.absUrl().replace(/\/staff.*/, '/cat/authority/list');
1723 .controller('BatchEditCtrl',
1724 ['$scope','$location','$routeParams',
1725 function($scope , $location , $routeParams) {
1726 $scope.batchedit_url = $location.absUrl().replace(/\/eg.*/, '/opac/extras/merge_template');
1727 if ($routeParams.container_type) {
1728 switch ($routeParams.container_type) {
1730 $scope.batchedit_url += '?recordSource=b&containerid=' + $routeParams.container_id;
1733 $scope.batchedit_url += '?recordSource=r&recid=' + $routeParams.container_id;
1740 .filter('boolText', function(){
1741 return function (v) {
1746 .factory('conjoinedSvc',
1748 function(egCore , $q) {
1751 items : [], // record search results
1752 index : 0, // search grid index
1759 bpbcm : ['target_copy','peer_type'],
1760 acp : ['call_number'],
1762 bre : ['simple_record']
1764 // avoid fetching the MARC blob by specifying which
1765 // fields on the bre to select. More may be needed.
1766 // note that fleshed fields are explicitly selected.
1767 select : { bre : ['id'] },
1768 order_by : { bpbcm : ['id'] },
1771 // resolved with the last received copy
1772 service.fetch = function(rid) {
1773 if (!rid && !service.rid) return $q.when();
1775 if (rid) service.rid = rid;
1779 return egCore.pcrud.search(
1781 {peer_record : service.rid},
1784 ).then( function(list) { // finished
1785 service.items = list;
1786 return service.items;
1790 // returns a promise resolved with the list of peer bib types
1791 service.get_peer_types = function() {
1793 return $q.when(egCore.env.bpt.list);
1795 return egCore.pcrud.retrieveAll('bpt', null, {atomic : true})
1796 .then(function(list) {
1797 egCore.env.absorbList(list, 'bpt');