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','egPatronSearchMod'])
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 patron_search_dialog = function() {
430 return $uibModal.open({
431 templateUrl: './share/t_patron_selector',
435 ['$scope','$uibModalInstance','$controller',
436 function($scope , $uibModalInstance , $controller) {
437 angular.extend(this, $controller('BasePatronSearchCtrl', {$scope : $scope}));
439 $scope.need_one_selected = function() {
440 var items = $scope.gridControls.selectedItems();
441 return (items.length == 1) ? false : true
443 $scope.ok = function() {
444 var items = $scope.gridControls.selectedItems();
445 if (items.length == 1) {
446 $uibModalInstance.close(items[0].card().barcode());
448 $uibModalInstance.close()
451 $scope.cancel = function($event) {
452 $uibModalInstance.dismiss();
453 $event.preventDefault();
459 // also set it when the iframe changes to a new record
460 $scope.handle_page = function(url) {
462 if (!url || url == 'about:blank') {
463 // nothing loaded. If we already have a record ID, leave it.
467 var match = url.match(/\/+opac\/+record\/+(\d+)/);
469 $scope.record_id = match[1];
470 egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
471 $scope.holdings_record_id_changed($scope.record_id);
472 conjoinedSvc.fetch($scope.record_id).then(function(){
473 $scope.conjoinedGridDataProvider.refresh();
475 egHolds.fetch_holds(hold_ids).then($scope.hold_grid_data_provider.refresh);
477 $location.update_path('/cat/catalog/record/' + $scope.record_id);
479 delete $scope.record_id;
480 $scope.from_route = false;
483 // child scope is executing this function, so our digest doesn't fire ... thus,
486 if (!$scope.in_opac_call) {
487 if ($scope.record_id) {
488 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
489 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
491 tab = $routeParams.record_tab || 'catalog';
493 $scope.set_record_tab(tab);
495 $scope.in_opac_call = false;
498 if ($scope.opac_iframe && $location.path().match(/cat\/catalog/)) {
499 var doc = $scope.opac_iframe.dom.contentWindow.document;
500 $(doc).find('#hold_usr_search').show();
501 $(doc).find('#hold_usr_search').on('click', function() {
502 patron_search_dialog().result.then(function(barc) {
503 $(doc).find('#hold_usr_input').val(barc);
504 $(doc).find('#hold_usr_input').change();
511 // xulG catalog handlers
512 $scope.handlers = { }
514 // ------------------------------------------------------------------
517 $scope.conjoinedGridControls = {};
518 $scope.conjoinedGridDataProvider = egGridDataProvider.instance({
519 get : function(offset, count) {
520 return this.arrayNotifier(conjoinedSvc.items, offset, count);
524 $scope.changeConjoinedType = function () {
525 var peers = egCore.idl.Clone($scope.conjoinedGridControls.selectedItems());
526 angular.forEach(peers, function (p) {
527 p.target_copy(p.target_copy().id());
528 p.peer_type(p.peer_type().id());
531 var conjoinedGridDataProviderRef = $scope.conjoinedGridDataProvider;
533 return $uibModal.open({
534 templateUrl: './cat/catalog/t_conjoined_selector',
537 ['$scope','$uibModalInstance',
538 function($scope , $uibModalInstance) {
539 $scope.update = true;
541 $scope.peer_type = null;
542 $scope.peer_type_list = [];
543 conjoinedSvc.get_peer_types().then(function(list){
544 $scope.peer_type_list = list;
547 $scope.ok = function(type) {
550 angular.forEach(peers, function (p) {
553 promises.push(egCore.pcrud.update(p));
556 return $q.all(promises)
557 .then(function(){$uibModalInstance.close()})
558 .then(function(){return conjoinedSvc.fetch()})
559 .then(function(){conjoinedGridDataProviderRef.refresh()});
562 $scope.cancel = function($event) {
563 $uibModalInstance.dismiss();
564 $event.preventDefault();
571 $scope.refreshConjoined = function () {
572 conjoinedSvc.fetch($scope.record_id)
573 .then(function(){$scope.conjoinedGridDataProvider.refresh();});
576 $scope.deleteSelectedConjoined = function () {
577 var peers = $scope.conjoinedGridControls.selectedItems();
579 if (peers.length > 0) {
580 egConfirmDialog.open(
581 egCore.strings.CONFIRM_DELETE_PEERS,
582 egCore.strings.CONFIRM_DELETE_PEERS_MESSAGE,
583 {peers : peers.length}
584 ).result.then(function() {
585 angular.forEach(peers, function (p) {
589 egCore.pcrud.remove(peers).then(function() {
590 return conjoinedSvc.fetch();
592 $scope.conjoinedGridDataProvider.refresh();
597 if ($scope.record_id)
598 conjoinedSvc.fetch($scope.record_id);
600 // ------------------------------------------------------------------
603 $scope.holdingsGridControls = {
604 activateItem : function (item) {
605 $scope.selectedHoldingsVolCopyEdit();
608 $scope.holdingsGridDataProvider = egGridDataProvider.instance({
609 get : function(offset, count) {
610 return this.arrayNotifier(holdingsSvcInst.copies, offset, count);
614 $scope.add_copies_to_bucket = function() {
615 var copy_list = gatherSelectedHoldingsIds();
616 if (copy_list.length == 0) return;
618 return $uibModal.open({
619 templateUrl: './cat/catalog/t_add_to_bucket',
623 ['$scope','$uibModalInstance',
624 function($scope , $uibModalInstance) {
626 $scope.bucket_id = 0;
627 $scope.newBucketName = '';
628 $scope.allBuckets = [];
632 'open-ils.actor.container.retrieve_by_class.authoritative',
633 egCore.auth.token(), egCore.auth.user().id(),
634 'copy', 'staff_client'
635 ).then(function(buckets) { $scope.allBuckets = buckets; });
637 $scope.add_to_bucket = function() {
639 angular.forEach(copy_list, function (cp) {
640 var item = new egCore.idl.ccbi()
641 item.bucket($scope.bucket_id);
642 item.target_copy(cp);
646 'open-ils.actor.container.item.create',
647 egCore.auth.token(), 'copy', item
651 return $q.all(promises).then(function() {
652 $uibModalInstance.close();
657 $scope.add_to_new_bucket = function() {
658 var bucket = new egCore.idl.ccb();
659 bucket.owner(egCore.auth.user().id());
660 bucket.name($scope.newBucketName);
661 bucket.description('');
662 bucket.btype('staff_client');
664 return egCore.net.request(
666 'open-ils.actor.container.create',
667 egCore.auth.token(), 'copy', bucket
668 ).then(function(bucket) {
669 $scope.bucket_id = bucket;
670 $scope.add_to_bucket();
674 $scope.cancel = function() {
675 $uibModalInstance.dismiss();
681 // TODO: refactor common code between cat/catalog/app.js and cat/item/app.js
683 $scope.need_one_selected = function() {
684 var items = $scope.holdingsGridControls.selectedItems();
685 if (items.length == 1) return false;
689 $scope.make_copies_bookable = function() {
691 var copies_by_record = {};
692 var record_list = [];
694 $scope.holdingsGridControls.selectedItems(),
696 var record_id = item['call_number.record.id'];
697 if (typeof copies_by_record[ record_id ] == 'undefined') {
698 copies_by_record[ record_id ] = [];
699 record_list.push( record_id );
701 copies_by_record[ record_id ].push(item.id);
706 var combined_results = [];
707 angular.forEach(record_list, function(record_id) {
711 'open-ils.booking.resources.create_from_copies',
713 copies_by_record[record_id]
714 ).then(function(results) {
715 if (results && results['brsrc']) {
716 combined_results = combined_results.concat(results['brsrc']);
722 $q.all(promises).then(function() {
723 if (combined_results.length > 0) {
725 template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
729 ['$scope','$location','egCore','$uibModalInstance',
730 function($scope , $location , egCore , $uibModalInstance) {
733 ses : egCore.auth.token(),
734 resultant_brsrc : combined_results.map(function(o) { return o[0]; })
737 var booking_path = '/eg/conify/global/booking/resource';
739 $scope.booking_admin_url =
740 $location.absUrl().replace(/\/eg\/staff.*/, booking_path);
747 $scope.book_copies_now = function() {
748 var copies_by_record = {};
749 var record_list = [];
751 $scope.holdingsGridControls.selectedItems(),
753 var record_id = item['call_number.record.id'];
754 if (typeof copies_by_record[ record_id ] == 'undefined') {
755 copies_by_record[ record_id ] = [];
756 record_list.push( record_id );
758 copies_by_record[ record_id ].push(item.id);
763 var combined_brt = [];
764 var combined_brsrc = [];
765 angular.forEach(record_list, function(record_id) {
769 'open-ils.booking.resources.create_from_copies',
771 copies_by_record[record_id]
772 ).then(function(results) {
773 if (results && results['brt']) {
774 combined_brt = combined_brt.concat(results['brt']);
776 if (results && results['brsrc']) {
777 combined_brsrc = combined_brsrc.concat(results['brsrc']);
783 $q.all(promises).then(function() {
784 if (combined_brt.length > 0 || combined_brsrc.length > 0) {
786 template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
790 ['$scope','$location','egCore','$uibModalInstance',
791 function($scope , $location , egCore , $uibModalInstance) {
794 ses : egCore.auth.token(),
795 bresv_interface_opts : {
798 ,brsrc : combined_brsrc
803 var booking_path = '/eg/booking/reservation';
805 $scope.booking_admin_url =
806 $location.absUrl().replace(/\/eg\/staff.*/, booking_path);
815 $scope.requestItems = function() {
816 var copy_list = gatherSelectedHoldingsIds();
817 if (copy_list.length == 0) return;
819 return $uibModal.open({
820 templateUrl: './cat/catalog/t_request_items',
823 ['$scope','$uibModalInstance',
824 function($scope , $uibModalInstance) {
826 $scope.first_user_fetch = true;
830 copy_list : copy_list,
831 pickup_lib: egCore.org.get(egCore.auth.user().ws_ou()),
832 user : egCore.auth.user().id()
835 egUser.get( $scope.hold_data.user ).then(function(u) {
837 $scope.barcode = u.card().barcode();
838 $scope.user_name = egUser.format_name(u);
839 $scope.hold_data.user = u.id();
842 $scope.user_name = '';
844 $scope.$watch('barcode', function (n) {
845 if (!$scope.first_user_fetch) {
846 egUser.getByBarcode(n).then(function(u) {
848 $scope.user_name = egUser.format_name(u);
849 $scope.hold_data.user = u.id();
852 $scope.user_name = '';
853 delete $scope.hold_data.user;
856 $scope.first_user_fetch = false;
859 $scope.ok = function(h) {
862 hold_type : h.hold_type,
863 pickup_lib: h.pickup_lib.id(),
869 'open-ils.circ.holds.test_and_create.batch.override',
870 egCore.auth.token(), args, h.copy_list
873 $uibModalInstance.close();
876 $scope.cancel = function($event) {
877 $uibModalInstance.dismiss();
878 $event.preventDefault();
884 $scope.view_place_orders = function() {
885 if (!$scope.record_id) return;
886 var url = egCore.env.basePath + 'acq/legacy/lineitem/related/' + $scope.record_id + '?target=bib';
887 $timeout(function() { $window.open(url, '_blank') });
890 $scope.replaceBarcodes = function() {
891 var copy_list = gatherSelectedRawCopies();
892 if (copy_list.length == 0) return;
894 var holdingsGridDataProviderRef = $scope.holdingsGridDataProvider;
896 angular.forEach(copy_list, function (cp) {
898 templateUrl: './cat/share/t_replace_barcode',
901 ['$scope','$uibModalInstance',
902 function($scope , $uibModalInstance) {
903 $scope.isModal = true;
904 $scope.focusBarcode = false;
905 $scope.focusBarcode2 = true;
906 $scope.barcode1 = cp.barcode();
908 $scope.updateBarcode = function() {
909 $scope.copyNotFound = false;
910 $scope.updateOK = false;
912 egCore.pcrud.search('acp',
913 {deleted : 'f', barcode : $scope.barcode1})
914 .then(function(copy) {
917 $scope.focusBarcode = true;
918 $scope.copyNotFound = true;
922 $scope.copyId = copy.id();
923 copy.barcode($scope.barcode2);
925 egCore.pcrud.update(copy).then(function(stat) {
926 $scope.updateOK = stat;
927 $scope.focusBarcode = true;
928 holdingsSvc.fetchAgain().then(function (){
929 holdingsGridDataProviderRef.refresh();
934 $uibModalInstance.close();
937 $scope.cancel = function($event) {
938 $uibModalInstance.dismiss();
939 $event.preventDefault();
947 // refresh the list of holdings when the record_id is changed.
948 $scope.holdings_record_id_changed = function(id) {
949 if ($scope.record_id != id) $scope.record_id = id;
950 console.log('record id changed to ' + id + ', loading new holdings');
951 holdingsSvcInst.fetch({
952 rid : $scope.record_id,
953 org : $scope.holdings_ou,
954 copy: $scope.holdings_show_copies,
955 vol : $scope.holdings_show_vols,
956 empty: $scope.holdings_show_empty
958 $scope.holdingsGridDataProvider.refresh();
962 // refresh the list of holdings when the filter lib is changed.
963 $scope.holdings_ou = egCore.org.get(egCore.auth.user().ws_ou());
964 $scope.holdings_ou_changed = function(org) {
965 $scope.holdings_ou = org;
966 holdingsSvcInst.fetch({
967 rid : $scope.record_id,
968 org : $scope.holdings_ou,
969 copy: $scope.holdings_show_copies,
970 vol : $scope.holdings_show_vols,
971 empty: $scope.holdings_show_empty
973 $scope.holdingsGridDataProvider.refresh();
977 $scope.holdings_cb_changed = function(cb,newVal,norefresh) {
979 egCore.hatch.setItem('cat.' + cb, newVal);
980 if (!norefresh) holdingsSvcInst.fetch({
981 rid : $scope.record_id,
982 org : $scope.holdings_ou,
983 copy: $scope.holdings_show_copies,
984 vol : $scope.holdings_show_vols,
985 empty: $scope.holdings_show_empty
987 $scope.holdingsGridDataProvider.refresh();
991 egCore.hatch.getItem('cat.holdings_show_vols').then(function(x){
992 if (typeof x == 'undefined') x = true;
993 $scope.holdings_cb_changed('holdings_show_vols',x,true);
994 $('#holdings_show_vols').prop('checked', x);
996 egCore.hatch.getItem('cat.holdings_show_copies').then(function(x){
997 if (typeof x == 'undefined') x = true;
998 $scope.holdings_cb_changed('holdings_show_copies',x,true);
999 $('#holdings_show_copies').prop('checked', x);
1001 egCore.hatch.getItem('cat.holdings_show_empty').then(function(x){
1002 if (typeof x == 'undefined') x = true;
1003 $scope.holdings_cb_changed('holdings_show_empty',x);
1004 $('#holdings_show_empty').prop('checked', x);
1009 $scope.vols_not_shown = function () {
1010 return !$scope.holdings_show_vols;
1013 $scope.copies_not_shown = function () {
1014 return !$scope.holdings_show_copies;
1017 $scope.holdings_checkbox_handler = function (item) {
1018 $scope.holdings_cb_changed(item.checkbox,item.checked);
1021 function gatherSelectedHoldingsIds () {
1022 var cp_id_list = [];
1024 $scope.holdingsGridControls.selectedItems(),
1025 function (item) { cp_id_list = cp_id_list.concat(item.id_list) }
1030 function gatherSelectedRawCopies () {
1033 $scope.holdingsGridControls.selectedItems(),
1034 function (item) { if (item.raw) cp_list = cp_list.concat(item.raw) }
1039 function gatherSelectedEmptyVolumeIds () {
1040 var cn_id_list = [];
1042 $scope.holdingsGridControls.selectedItems(),
1044 if (item.copy_count == 0)
1045 cn_id_list.push(item.call_number.id)
1051 function gatherSelectedVolumeIds () {
1052 var cn_id_list = [];
1054 $scope.holdingsGridControls.selectedItems(),
1056 if (cn_id_list.indexOf(item.call_number.id) == -1)
1057 cn_id_list.push(item.call_number.id)
1063 $scope.selectedHoldingsDelete = function (vols, copies) {
1066 var perCnCopies = {};
1072 $scope.holdingsGridControls.selectedItems(),
1074 if (vols && item.raw_call_number) {
1075 cnHash[item.call_number.id] = egCore.idl.Clone(item.raw_call_number);
1076 cnHash[item.call_number.id].isdeleted(1);
1078 } else if (copies) {
1079 angular.forEach(egCore.idl.Clone(item.raw), function (cp) {
1082 var cn_id = cp.call_number().id();
1083 if (!cnHash[cn_id]) {
1084 cnHash[cn_id] = cp.call_number();
1085 perCnCopies[cn_id] = [cp];
1087 perCnCopies[cn_id].push(cp);
1089 cp.call_number(cn_id); // prevent loops in JSON-ification
1096 angular.forEach(perCnCopies, function (v, k) {
1098 cnHash[k].isdeleted(1);
1101 cnHash[k].copies(v);
1105 angular.forEach(cnHash, function (v, k) {
1109 if (cnList.length == 0) return;
1112 if (vols && copies) flags.force_delete_copies = 1;
1114 egConfirmDialog.open(
1115 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES,
1116 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES_MESSAGE,
1117 {copies : cp_count, volumes : cn_count}
1118 ).result.then(function() {
1121 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1122 egCore.auth.token(), cnList, 1, flags
1123 ).then(function(update_count) {
1124 holdingsSvcInst.fetchAgain().then(function() {
1125 $scope.holdingsGridDataProvider.refresh();
1130 $scope.selectedHoldingsCopyDelete = function () { $scope.selectedHoldingsDelete(false,true) }
1131 $scope.selectedHoldingsVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,true) }
1132 $scope.selectedHoldingsEmptyVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,false) }
1134 spawnHoldingsAdd = function (vols,copies){
1136 if (copies) { // just a copy on existing volumes
1137 angular.forEach(gatherSelectedVolumeIds(), function (v) {
1138 raw.push( {callnumber : v} );
1141 if (typeof $scope.holdingsGridControls.selectedItems == "function" &&
1142 $scope.holdingsGridControls.selectedItems().length > 0) {
1143 angular.forEach($scope.holdingsGridControls.selectedItems(),
1146 owner : item.owner_id,
1147 label : item.call_number.label
1152 owner : egCore.auth.user().ws_ou()
1157 if (raw.length == 0) raw.push({});
1161 'open-ils.actor.anon_cache.set_value',
1162 null, 'edit-these-copies', {
1163 record_id: $scope.record_id,
1168 ).then(function(key) {
1170 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1171 $timeout(function() { $window.open(url, '_blank') });
1173 alert('Could not create anonymous cache key!');
1177 $scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,false) }
1178 $scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true) }
1180 spawnHoldingsEdit = function (hide_vols,hide_copies){
1183 'open-ils.actor.anon_cache.set_value',
1184 null, 'edit-these-copies', {
1185 record_id: $scope.record_id,
1186 copies: gatherSelectedHoldingsIds(),
1187 raw: gatherSelectedEmptyVolumeIds().map(
1188 function(v){ return { callnumber : v } }
1190 hide_vols : hide_vols,
1191 hide_copies : hide_copies
1193 ).then(function(key) {
1195 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1196 $timeout(function() { $window.open(url, '_blank') });
1198 alert('Could not create anonymous cache key!');
1202 $scope.selectedHoldingsVolCopyEdit = function () { spawnHoldingsEdit(false,false) }
1203 $scope.selectedHoldingsVolEdit = function () { spawnHoldingsEdit(false,true) }
1204 $scope.selectedHoldingsCopyEdit = function () { spawnHoldingsEdit(true,false) }
1206 $scope.selectedHoldingsItemStatus = function (){
1207 var url = egCore.env.basePath + 'cat/item/search/' + gatherSelectedHoldingsIds().join(',')
1208 $timeout(function() { $window.open(url, '_blank') });
1211 $scope.markVolAsItemTarget = function() {
1212 if ($scope.holdingsGridControls.selectedItems()[0].call_number.id) { // cn.id missing when vols are collapsed
1213 egCore.hatch.setLocalItem(
1214 'eg.cat.item_transfer_target',
1215 $scope.holdingsGridControls.selectedItems()[0].call_number.id
1217 ngToast.create(egCore.strings.MARK_ITEM_TARGET);
1221 $scope.markLibAsVolTarget = function() {
1222 return $uibModal.open({
1223 templateUrl: './cat/catalog/t_choose_vol_target_lib',
1226 ['$scope','$uibModalInstance',
1227 function($scope , $uibModalInstance) {
1229 var orgId = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target') || 1;
1230 $scope.org = egCore.org.get(orgId);
1231 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1232 $scope.ok = function(org) {
1233 egCore.hatch.setLocalItem(
1234 'eg.cat.volume_transfer_target',
1237 $uibModalInstance.close();
1239 $scope.cancel = function($event) {
1240 $uibModalInstance.dismiss();
1241 $event.preventDefault();
1246 $scope.markLibFromSelectedAsVolTarget = function() {
1247 egCore.hatch.setLocalItem(
1248 'eg.cat.volume_transfer_target',
1249 $scope.holdingsGridControls.selectedItems()[0].owner_id
1251 ngToast.create(egCore.strings.MARK_VOL_TARGET);
1254 $scope.selectedHoldingsItemStatusDetail = function (){
1256 gatherSelectedHoldingsIds(),
1258 var url = egCore.env.basePath +
1260 $timeout(function() { $window.open(url, '_blank') });
1265 $scope.transferVolumesToRecord = function (){
1266 var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
1267 if (!target_record) return;
1268 if ($scope.record_id == target_record) return;
1269 var items = $scope.holdingsGridControls.selectedItems();
1270 if (!items.length) return;
1272 var vols_to_move = {};
1273 angular.forEach(items, function(item) {
1274 if (!(item.call_number.owning_lib in vols_to_move)) {
1275 vols_to_move[item.call_number.owning_lib] = new Array;
1277 vols_to_move[item.call_number.owning_lib].push(item.call_number.id);
1281 angular.forEach(vols_to_move, function(vols, owning_lib) {
1282 promises.push(egCore.net.request(
1284 'open-ils.cat.asset.volume.batch.transfer.override',
1285 egCore.auth.token(), {
1286 docid : target_record,
1292 $q.all(promises).then(function(success) {
1294 ngToast.create(egCore.strings.VOLS_TRANSFERED);
1295 holdingsSvcInst.fetchAgain().then(function() {
1296 $scope.holdingsGridDataProvider.refresh();
1299 alert('Could not transfer volumes!');
1304 function transferVolumes(new_record){
1305 var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
1310 'open-ils.cat.asset.volume.batch.transfer.override',
1311 egCore.auth.token(), {
1312 docid : (new_record ? new_record : $scope.record_id),
1314 volumes : gatherSelectedVolumeIds()
1316 ).then(function(success) {
1318 ngToast.create(egCore.strings.VOLS_TRANSFERED);
1319 holdingsSvcInst.fetchAgain().then(function() {
1320 $scope.holdingsGridDataProvider.refresh();
1323 alert('Could not transfer volumes!');
1330 $scope.transferVolumesToLibrary = function() {
1334 $scope.transferVolumesToRecordAndLibrary = function() {
1335 var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
1336 if (!target_record) return;
1337 transferVolumes(target_record);
1340 // this "transfers" selected copies to a new owning library,
1341 // auto-creating volumes and deleting unused volumes as required.
1342 $scope.changeItemOwningLib = function() {
1343 var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
1344 var items = $scope.holdingsGridControls.selectedItems();
1345 if (!xfer_target || !items.length) {
1348 var vols_to_move = {};
1349 var copies_to_move = {};
1350 angular.forEach(items, function(item) {
1351 if (item.call_number.owning_lib != xfer_target) {
1352 if (item.call_number.id in vols_to_move) {
1353 copies_to_move[item.call_number.id].push(item.id);
1355 vols_to_move[item.call_number.id] = item.call_number;
1356 copies_to_move[item.call_number.id] = new Array;
1357 copies_to_move[item.call_number.id].push(item.id);
1363 angular.forEach(vols_to_move, function(vol) {
1364 promises.push(egCore.net.request(
1366 'open-ils.cat.call_number.find_or_create',
1367 egCore.auth.token(),
1374 ).then(function(resp) {
1375 var evt = egCore.evt.parse(resp);
1377 return egCore.net.request(
1379 'open-ils.cat.transfer_copies_to_volume',
1380 egCore.auth.token(),
1382 copies_to_move[vol.id]
1386 $q.all(promises).then(function() {
1387 ngToast.create(egCore.strings.ITEMS_TRANSFERED);
1388 holdingsSvcInst.fetchAgain().then(function() {
1389 $scope.holdingsGridDataProvider.refresh();
1394 $scope.transferItems = function (){
1395 var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
1396 var copy_ids = gatherSelectedHoldingsIds();
1397 if (xfer_target && copy_ids.length > 0) {
1400 'open-ils.cat.transfer_copies_to_volume',
1401 egCore.auth.token(),
1405 function(resp) { // oncomplete
1406 var evt = egCore.evt.parse(resp);
1408 egConfirmDialog.open(
1409 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
1410 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
1411 {'evt_desc': evt.desc}
1412 ).result.then(function() {
1415 'open-ils.cat.transfer_copies_to_volume.override',
1416 egCore.auth.token(),
1419 { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
1420 ).then(function(resp) {
1421 holdingsSvcInst.fetchAgain().then(function() {
1422 $scope.holdingsGridDataProvider.refresh();
1427 ngToast.create(egCore.strings.ITEMS_TRANSFERED);
1428 holdingsSvcInst.fetchAgain().then(function() {
1429 $scope.holdingsGridDataProvider.refresh();
1439 $scope.selectedHoldingsItemStatusTgrEvt = function (){
1441 gatherSelectedHoldingsIds(),
1443 var url = egCore.env.basePath +
1444 'cat/item/' + cid + '/triggered_events';
1445 $timeout(function() { $window.open(url, '_blank') });
1450 $scope.selectedHoldingsItemStatusHolds = function (){
1452 gatherSelectedHoldingsIds(),
1454 var url = egCore.env.basePath +
1455 'cat/item/' + cid + '/holds';
1456 $timeout(function() { $window.open(url, '_blank') });
1461 $scope.selectedHoldingsPrintLabels = function() {
1464 'open-ils.actor.anon_cache.set_value',
1465 null, 'print-labels-these-copies', {
1466 copies : gatherSelectedHoldingsIds()
1468 ).then(function(key) {
1470 var url = egCore.env.basePath + 'cat/printlabels/' + key;
1471 $timeout(function() { $window.open(url, '_blank') });
1473 alert('Could not create anonymous cache key!');
1478 $scope.selectedHoldingsDamaged = function () {
1479 egCirc.mark_damaged(gatherSelectedHoldingsIds()).then(function() {
1480 holdingsSvcInst.fetchAgain().then(function() {
1481 $scope.holdingsGridDataProvider.refresh();
1486 $scope.selectedHoldingsMissing = function () {
1487 egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() {
1488 holdingsSvcInst.fetchAgain().then(function() {
1489 $scope.holdingsGridDataProvider.refresh();
1494 $scope.attach_to_peer_bib = function() {
1495 var copy_list = gatherSelectedHoldingsIds();
1496 if (copy_list.length == 0) return;
1498 egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
1499 if (!target_record) return;
1501 return $uibModal.open({
1502 templateUrl: './cat/catalog/t_conjoined_selector',
1505 ['$scope','$uibModalInstance',
1506 function($scope , $uibModalInstance) {
1507 $scope.update = false;
1509 $scope.peer_type = null;
1510 $scope.peer_type_list = [];
1511 conjoinedSvc.get_peer_types().then(function(list){
1512 $scope.peer_type_list = list;
1515 $scope.ok = function(type) {
1518 angular.forEach(copy_list, function (cp) {
1519 var n = new egCore.idl.bpbcm();
1521 n.peer_record(target_record);
1524 promises.push(egCore.pcrud.create(n));
1527 return $q.all(promises).then(function(){$uibModalInstance.close()});
1530 $scope.cancel = function($event) {
1531 $uibModalInstance.dismiss();
1532 $event.preventDefault();
1540 // ------------------------------------------------------------------
1542 var provider = egGridDataProvider.instance({});
1543 $scope.hold_grid_data_provider = provider;
1544 $scope.grid_actions = egHoldGridActions;
1545 $scope.grid_actions.refresh = function () { provider.refresh() };
1546 $scope.hold_grid_controls = {};
1548 var hold_ids = []; // current list of holds
1549 function fetchHolds(offset, count) {
1550 var ids = hold_ids.slice(offset, offset + count);
1552 return egHolds.fetch_holds(ids).then(null, null,
1553 function(hold_data) {
1559 provider.get = function(offset, count) {
1560 if ($scope.record_tab != 'holds') return $q.when();
1561 var deferred = $q.defer();
1562 hold_ids = []; // no caching ATM
1564 // open a determinate progress dialog, max value set below.
1565 egProgressDialog.open({max : 1, value : 0});
1570 'open-ils.circ.holds.retrieve_all_from_title',
1571 egCore.auth.token(), $scope.record_id,
1572 {pickup_lib : egCore.org.descendants($scope.pickup_ou.id(), true)}
1574 function(hold_data) {
1575 hold_ids = []; // clear the list of ids, hack to avoid dups
1576 // TODO: fix the underlying problem, which is that
1577 // this gets called twice when switching to the holds
1578 // tab; once explicitly, and once via the change handler
1579 // on the OU selector
1580 angular.forEach(hold_data, function(list, type) {
1581 hold_ids = hold_ids.concat(list);
1584 // Set the max value of the progress bar to the lesser of
1585 // the total number of holds to fetch or the page size
1587 egProgressDialog.update(
1588 {max : Math.min(hold_ids.length, count)});
1590 var holds_fetched = 0;
1591 fetchHolds(offset, count)
1592 .then(deferred.resolve, null,
1593 function(hold_data) {
1595 deferred.notify(hold_data);
1596 egProgressDialog.increment();
1598 )['finally'](egProgressDialog.close);
1602 return deferred.promise;
1605 $scope.detail_view = function(action, user_data, items) {
1607 $scope.detail_hold_id = h.hold.id();
1611 $scope.list_view = function(items) {
1612 $scope.detail_hold_id = null;
1615 // refresh the list of record holds when the pickup lib is changed.
1616 $scope.pickup_ou = egCore.org.get(egCore.auth.user().ws_ou());
1617 $scope.pickup_ou_changed = function(org) {
1618 $scope.pickup_ou = org;
1622 $scope.print_holds = function() {
1624 angular.forEach($scope.hold_grid_controls.allItems(), function(item) {
1626 hold : egCore.idl.toHash(item.hold),
1627 patron_last : item.patron_last,
1628 patron_alias : item.patron_alias,
1629 patron_barcode : item.patron_barcode,
1630 copy : egCore.idl.toHash(item.copy),
1631 volume : egCore.idl.toHash(item.volume),
1632 title : item.mvr.title(),
1633 author : item.mvr.author()
1637 egCore.print.print({
1638 context : 'receipt',
1639 template : 'holds_for_bib',
1640 scope : {holds : holds}
1644 $scope.current_hold_transfer_dest = egCore.hatch.getLocalItem ('eg.circ.hold.title_transfer_target');
1646 $scope.mark_hold_transfer_dest = function() {
1647 $scope.current_hold_transfer_dest = $scope.record_id;
1648 egCore.hatch.setLocalItem(
1649 'eg.circ.hold.title_transfer_target', $scope.record_id);
1650 ngToast.create(egCore.strings.HOLD_TRANSFER_DEST_MARKED);
1653 // UI presents this option as "all holds"
1654 $scope.transfer_holds_to_marked = function() {
1655 var hold_ids = $scope.hold_grid_controls.allItems().map(
1656 function(hold_data) {return hold_data.hold.id()});
1657 egHolds.transfer_to_marked_title(hold_ids);
1660 // ------------------------------------------------------------------
1661 // Initialize the selected tab
1663 function init_cat_url() {
1664 // Set the initial catalog URL. This only happens once.
1665 // The URL is otherwise generated through user navigation.
1666 if ($scope.catalog_url) return;
1668 var url = $location.absUrl().replace(/\/staff.*/, '/opac/advanced');
1670 // A record ID in the path indicates a request for the record-
1672 if ($routeParams.record_id) {
1673 url = url.replace(/advanced/, '/record/' + $scope.record_id);
1676 // Jumping directly to the results page by passing a search
1677 // query via the URL. Copy all URL params to the iframe url.
1678 if ($location.path().match(/catalog\/results/)) {
1679 url = url.replace(/advanced/, '/results?');
1681 angular.forEach($location.search(), function(val, key) {
1682 if (!first) url += '&';
1684 url += encodeURIComponent(key)
1685 + '=' + encodeURIComponent(val);
1689 // if we're displaying the advanced search form, select
1690 // whatever default pane the user has chosen via workstation
1692 if (url.match(/\/opac\/advanced$/)) {
1693 var adv_pane = egCore.hatch.getLocalItem('eg.search.adv_pane');
1695 url += '?pane=' + encodeURIComponent(adv_pane);
1699 $scope.catalog_url = url;
1702 function init_parts_url() {
1703 $scope.parts_url = $location
1707 '/conify/global/biblio/monograph_part?r='+$scope.record_id
1711 $scope.set_record_tab = function(tab) {
1712 $scope.record_tab = tab;
1725 $scope.detail_hold_record_id = $scope.record_id;
1726 // refresh the holds grid
1733 $scope.set_default_record_tab = function() {
1734 egCore.hatch.setLocalItem(
1735 'eg.cat.default_record_tab', $scope.record_tab);
1736 $timeout(function(){$scope.default_tab = $scope.record_tab});
1740 if ($scope.record_id) {
1741 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
1742 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
1745 tab = $routeParams.record_tab || 'catalog';
1747 $scope.set_record_tab(tab);
1751 .controller('AuthorityCtrl',
1752 ['$scope','$routeParams','$location','$window','$q','egCore',
1753 function($scope , $routeParams , $location , $window , $q , egCore) {
1755 // set record ID on page load if available...
1756 $scope.authority_id = $routeParams.authority_id;
1758 if ($routeParams.authority_id) $scope.from_route = true;
1759 else $scope.from_route = false;
1761 $scope.stop_unload = false;
1764 .controller('URLVerifyCtrl',
1765 ['$scope','$location',
1766 function($scope , $location) {
1767 $scope.verifyurls_url = $location.absUrl().replace(/\/staff.*/, '/url_verify/sessions');
1770 .controller('VandelayCtrl',
1771 ['$scope','$location',
1772 function($scope , $location) {
1773 $scope.vandelay_url = $location.absUrl().replace(/\/staff\/cat\/catalog\/vandelay/, '/vandelay/vandelay');
1776 .controller('ManageAuthoritiesCtrl',
1777 ['$scope','$location',
1778 function($scope , $location) {
1779 $scope.manageauthorities_url = $location.absUrl().replace(/\/staff.*/, '/cat/authority/list');
1782 .controller('BatchEditCtrl',
1783 ['$scope','$location','$routeParams',
1784 function($scope , $location , $routeParams) {
1785 $scope.batchedit_url = $location.absUrl().replace(/\/eg.*/, '/opac/extras/merge_template');
1786 if ($routeParams.container_type) {
1787 switch ($routeParams.container_type) {
1789 $scope.batchedit_url += '?recordSource=b&containerid=' + $routeParams.container_id;
1792 $scope.batchedit_url += '?recordSource=r&recid=' + $routeParams.container_id;
1799 .filter('boolText', function(){
1800 return function (v) {
1805 .factory('conjoinedSvc',
1807 function(egCore , $q) {
1810 items : [], // record search results
1811 index : 0, // search grid index
1818 bpbcm : ['target_copy','peer_type'],
1819 acp : ['call_number'],
1821 bre : ['simple_record']
1823 // avoid fetching the MARC blob by specifying which
1824 // fields on the bre to select. More may be needed.
1825 // note that fleshed fields are explicitly selected.
1826 select : { bre : ['id'] },
1827 order_by : { bpbcm : ['id'] },
1830 // resolved with the last received copy
1831 service.fetch = function(rid) {
1832 if (!rid && !service.rid) return $q.when();
1834 if (rid) service.rid = rid;
1838 return egCore.pcrud.search(
1840 {peer_record : service.rid},
1843 ).then( function(list) { // finished
1844 service.items = list;
1845 return service.items;
1849 // returns a promise resolved with the list of peer bib types
1850 service.get_peer_types = function() {
1852 return $q.when(egCore.env.bpt.list);
1854 return egCore.pcrud.retrieveAll('bpt', null, {atomic : true})
1855 .then(function(list) {
1856 egCore.env.absorbList(list, 'bpt');