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',
11 'egSerialsMod','egSerialsAppDep'])
13 .config(['ngToastProvider', function(ngToastProvider) {
14 ngToastProvider.configure({
15 verticalPosition: 'bottom',
20 .config(function($routeProvider, $locationProvider, $compileProvider) {
21 $locationProvider.html5Mode(true);
22 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export
24 var resolver = {delay : ['egCore','egStartup','egUser', function(egCore, egStartup, egUser) {
25 egCore.env.classLoaders.aous = function() {
26 return egCore.org.settings([
27 'cat.marc_control_number_identifier'
28 ]).then(function(settings) {
29 // local settings are cached within egOrg. Caching them
30 // again in egEnv just simplifies the syntax for access.
31 egCore.env.aous = settings;
34 egCore.env.loadClasses.push('aous');
38 $routeProvider.when('/cat/catalog/index', {
39 templateUrl: './cat/catalog/t_catalog',
40 controller: 'CatalogCtrl',
44 // Jump directly to the results page. Any URL parameter
45 // supported by the embedded catalog is supported here.
46 $routeProvider.when('/cat/catalog/results', {
47 templateUrl: './cat/catalog/t_catalog',
48 controller: 'CatalogCtrl',
52 $routeProvider.when('/cat/catalog/retrieve_by_id', {
53 templateUrl: './cat/catalog/t_retrieve_by_id',
54 controller: 'CatalogRecordRetrieve',
58 $routeProvider.when('/cat/catalog/retrieve_by_tcn', {
59 templateUrl: './cat/catalog/t_retrieve_by_tcn',
60 controller: 'CatalogRecordRetrieve',
64 $routeProvider.when('/cat/catalog/new_bib', {
65 templateUrl: './cat/catalog/t_new_bib',
66 controller: 'NewBibCtrl',
70 // create some catalog page-specific mappings
71 $routeProvider.when('/cat/catalog/record/:record_id', {
72 templateUrl: './cat/catalog/t_catalog',
73 controller: 'CatalogCtrl',
77 // create some catalog page-specific mappings
78 $routeProvider.when('/cat/catalog/record/:record_id/:record_tab', {
79 templateUrl: './cat/catalog/t_catalog',
80 controller: 'CatalogCtrl',
84 $routeProvider.when('/cat/catalog/batchEdit', {
85 templateUrl: './cat/catalog/t_batchedit',
86 controller: 'BatchEditCtrl',
90 $routeProvider.when('/cat/catalog/batchEdit/:container_type/:container_id', {
91 templateUrl: './cat/catalog/t_batchedit',
92 controller: 'BatchEditCtrl',
96 $routeProvider.when('/cat/catalog/vandelay', {
97 templateUrl: './cat/catalog/t_vandelay',
98 controller: 'VandelayCtrl',
102 $routeProvider.when('/cat/catalog/verifyURLs', {
103 templateUrl: './cat/catalog/t_verifyurls',
104 controller: 'URLVerifyCtrl',
108 $routeProvider.when('/cat/catalog/manageAuthorities', {
109 templateUrl: './cat/catalog/t_manageauthorities',
110 controller: 'ManageAuthoritiesCtrl',
114 $routeProvider.when('/cat/catalog/authority/:authority_id/marc_edit', {
115 templateUrl: './cat/catalog/t_authority',
116 controller: 'AuthorityCtrl',
120 $routeProvider.otherwise({redirectTo : '/cat/catalog/index'});
126 .controller('CatalogRecordRetrieve',
127 ['$scope','$routeParams','$location','$q','egCore',
128 function($scope , $routeParams , $location , $q , egCore ) {
130 $scope.focusMe = true;
132 // jump to the patron checkout UI
133 function loadRecord(record_id) {
135 .path('/cat/catalog/record/' + record_id);
138 $scope.submitId = function(args) {
139 $scope.recordNotFound = null;
140 if (!args.record_id) return;
142 // blur so next time it's set to true it will re-apply select()
143 $scope.selectMe = false;
145 return loadRecord(args.record_id);
148 $scope.submitTCN = function(args) {
149 $scope.recordNotFound = null;
150 $scope.moreRecordsFound = null;
151 if (!args.record_tcn) return;
153 // blur so next time it's set to true it will re-apply select()
154 $scope.selectMe = false;
159 'open-ils.search.biblio.tcn',
162 .then(function(resp) { // get_barcodes
164 if (evt = egCore.evt.parse(resp)) {
170 $scope.recordNotFound = args.record_tcn;
171 $scope.selectMe = true;
175 if (resp.count > 1) {
176 $scope.moreRecordsFound = args.record_tcn;
177 $scope.selectMe = true;
181 var record_id = resp.ids[0];
182 return loadRecord(record_id);
188 .controller('NewBibCtrl',
189 ['$scope','$routeParams','$location','$window','$q','egCore',
190 'egGridDataProvider','egHoldGridActions','$timeout','holdingsSvc',
191 function($scope , $routeParams , $location , $window , $q , egCore) {
193 $scope.have_template = false;
194 $scope.marc_template = '';
195 $scope.stop_unload = false;
196 $scope.template_list = [];
197 $scope.template_name = '';
198 $scope.new_bib_id = 0;
202 'open-ils.cat.marc_template.types.retrieve'
203 ).then(function(resp) {
204 angular.forEach(resp, function(name) {
205 $scope.template_list.push(name);
207 $scope.template_list.sort();
209 $scope.template_name = egCore.hatch.getSessionItem('eg.cat.last_bib_marc_template');
210 if (!$scope.template_name) {
211 egCore.hatch.getItem('cat.default_bib_marc_template').then(function(template) {
212 $scope.template_name = template;
216 $scope.loadTemplate = function() {
217 if ($scope.template_name) {
220 'open-ils.cat.biblio.marc_template.retrieve',
222 ).then(function(template) {
223 $scope.marc_template = template;
224 $scope.have_template = true;
225 egCore.hatch.setSessionItem('eg.cat.last_bib_marc_template', $scope.template_name);
230 $scope.setDefaultTemplate = function() {
231 var hatch_key = "cat.default_bib_marc_template";
232 if ($scope.template_name) {
233 egCore.hatch.setItem(hatch_key, $scope.template_name);
235 egCore.hatch.removeItem(hatch_key);
239 $scope.$watch('new_bib_id', function(newVal, oldVal) {
241 $location.path('/cat/catalog/record/' + $scope.new_bib_id);
247 .controller('CatalogCtrl',
248 ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast',
249 'egGridDataProvider','egHoldGridActions','egProgressDialog','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc',
250 '$cookies','egSerialsCoreSvc',
251 function($scope , $routeParams , $location , $window , $q , egCore , egHolds , egCirc , egConfirmDialog , ngToast ,
252 egGridDataProvider , egHoldGridActions , egProgressDialog , $timeout , $uibModal , holdingsSvc , egUser , conjoinedSvc,
253 $cookies , egSerialsCoreSvc
256 var holdingsSvcInst = new holdingsSvc();
258 // set record ID on page load if available...
259 $scope.record_id = $routeParams.record_id;
260 $scope.summary_pane_record;
262 if ($scope.record_id) {
263 // TODO: Apply tab-specific title contexts
264 egCore.strings.setPageTitle(
265 egCore.strings.PAGE_TITLE_BIB_DETAIL,
266 egCore.strings.PAGE_TITLE_CATALOG_CONTEXT,
267 {record_id : $scope.record_id}
270 // Default to title = Catalog
271 egCore.strings.setPageTitle(
272 egCore.strings.PAGE_TITLE_CATALOG_CONTEXT);
275 if ($routeParams.record_id) $scope.from_route = true;
276 else $scope.from_route = false;
278 // set search and preferred library cookies
279 egCore.hatch.getItem('eg.search.search_lib').then(function(val) {
280 $cookies.put('eg_search_lib', val, { path : '/' });
282 egCore.hatch.getItem('eg.search.pref_lib').then(function(val) {
283 $cookies.put('eg_pref_lib', val, { path : '/' });
286 // will hold a ref to the opac iframe
287 $scope.opac_iframe = null;
288 $scope.parts_iframe = null;
290 $scope.search_result_index = 1;
291 $scope.search_result_hit_count = 1;
294 'opac_iframe.dom.contentWindow.search_result_index',
296 if (!isNaN(parseInt(n)))
297 $scope.search_result_index = n + 1;
302 'opac_iframe.dom.contentWindow.search_result_hit_count',
304 if (!isNaN(parseInt(n)))
305 $scope.search_result_hit_count = n;
309 $scope.in_opac_call = false;
310 $scope.opac_call = function (opac_frame_function, force_opac_tab) {
311 if ($scope.opac_iframe) {
312 if (force_opac_tab) $scope.record_tab = 'catalog';
313 $scope.in_opac_call = true;
314 $scope.opac_iframe.dom.contentWindow[opac_frame_function]();
315 if (opac_frame_function == 'rdetailBackToResults') {
316 $location.update_path('/cat/catalog/index');
321 $scope.add_to_record_bucket = function() {
322 var recId = $scope.record_id;
323 return $uibModal.open({
324 templateUrl: './cat/catalog/t_add_to_bucket',
329 ['$scope','$uibModalInstance',
330 function($scope , $uibModalInstance) {
332 $scope.bucket_id = 0;
333 $scope.newBucketName = '';
334 $scope.allBuckets = [];
337 'open-ils.actor.container.retrieve_by_class.authoritative',
338 egCore.auth.token(), egCore.auth.user().id(),
339 'biblio', 'staff_client'
340 ).then(function(buckets) { $scope.allBuckets = buckets; });
342 $scope.add_to_bucket = function() {
343 var item = new egCore.idl.cbrebi();
344 item.bucket($scope.bucket_id);
345 item.target_biblio_record_entry(recId);
348 'open-ils.actor.container.item.create',
349 egCore.auth.token(), 'biblio', item
350 ).then(function(resp) {
351 $uibModalInstance.close();
355 $scope.add_to_new_bucket = function() {
356 var bucket = new egCore.idl.cbreb();
357 bucket.owner(egCore.auth.user().id());
358 bucket.name($scope.newBucketName);
359 bucket.description('');
360 bucket.btype('staff_client');
364 'open-ils.actor.container.create',
365 egCore.auth.token(), 'biblio', bucket
366 ).then(function(bucket) {
367 $scope.bucket_id = bucket;
368 $scope.add_to_bucket();
372 $scope.cancel = function() {
373 $uibModalInstance.dismiss();
379 $scope.current_overlay_target = egCore.hatch.getLocalItem('eg.cat.marked_overlay_record');
380 $scope.current_voltransfer_target = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
381 $scope.current_conjoined_target = egCore.hatch.getLocalItem('eg.cat.marked_conjoined_record');
383 $scope.quickReceive = function () {
385 var next_per_stream = {};
387 var recId = $scope.record_id;
388 return $uibModal.open({
389 templateUrl: './share/t_subscription_select_dialog',
391 controller: ['$scope', '$uibModalInstance',
392 function($scope, $uibModalInstance) {
395 $scope.rememberMe = 'eg.serials.quickreceive.last_org';
396 $scope.record_id = recId;
397 $scope.ssubId = null;
399 $scope.ok = function() { $uibModalInstance.close($scope.ssubId) }
400 $scope.cancel = function() { $uibModalInstance.dismiss(); }
403 }).result.then(function(ssubId) {
406 promises.push(egSerialsCoreSvc.fetchItemsForSub(ssubId,{status:'Expected'}).then(function(){
407 angular.forEach(egSerialsCoreSvc.itemTree, function (item) {
408 if (next_per_stream[item.stream().id()]) return;
409 if (item.status() == 'Expected') {
410 next_per_stream[item.stream().id()] = item;
411 list.push(egCore.idl.Clone(item));
416 return $q.all(promises).then(function() {
419 ngToast.warning(egCore.strings.SERIALS_NO_ITEMS);
423 return egSerialsCoreSvc.process_items(
429 false, // print by default
430 function() { $scope.holdings_record_id_changed($scope.record_id) }
434 ngToast.warning(egCore.strings.SERIALS_NO_SUBS);
440 $scope.markConjoined = function () {
441 $scope.current_conjoined_target = $scope.record_id;
442 egCore.hatch.setLocalItem('eg.cat.marked_conjoined_record',$scope.record_id);
443 ngToast.create(egCore.strings.MARK_CONJ_TARGET);
446 $scope.markVolTransfer = function () {
447 ngToast.create(egCore.strings.MARK_VOL_TARGET);
448 $scope.current_voltransfer_target = $scope.record_id;
449 egCore.hatch.setLocalItem('eg.cat.marked_volume_transfer_record',$scope.record_id);
452 $scope.markOverlay = function () {
453 $scope.current_overlay_target = $scope.record_id;
454 egCore.hatch.setLocalItem('eg.cat.marked_overlay_record',$scope.record_id);
455 ngToast.create(egCore.strings.MARK_OVERLAY_TARGET);
458 $scope.clearRecordMarks = function () {
459 $scope.current_overlay_target = null;
460 $scope.current_voltransfer_target = null;
461 $scope.current_conjoined_target = null;
462 $scope.current_hold_transfer_dest = null;
463 egCore.hatch.removeLocalItem('eg.cat.marked_volume_transfer_record');
464 egCore.hatch.removeLocalItem('eg.cat.marked_conjoined_record');
465 egCore.hatch.removeLocalItem('eg.cat.marked_overlay_record');
466 egCore.hatch.removeLocalItem('eg.circ.hold.title_transfer_target');
469 $scope.stop_unload = false;
470 $scope.$watch('stop_unload',
471 function(newVal, oldVal) {
472 if (newVal && newVal != oldVal && $scope.opac_iframe) {
473 $($scope.opac_iframe.dom.contentWindow).on('beforeunload', function(){
474 return 'There is unsaved data in this record.'
477 if ($scope.opac_iframe)
478 $($scope.opac_iframe.dom.contentWindow).off('beforeunload');
483 // Set the "last bib" cookie, if we have that
484 if ($scope.record_id)
485 egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
487 $scope.refresh_record_callback = function (record_id) {
488 egCore.pcrud.retrieve('bre', record_id, {
491 bre : ['simple_record','creator','editor']
493 }).then(function(rec) {
494 rec.owner(egCore.org.get(rec.owner()));
495 $scope.summary_pane_record = rec;
501 patron_search_dialog = function() {
502 return $uibModal.open({
503 templateUrl: './share/t_patron_selector',
508 ['$scope','$uibModalInstance','$controller',
509 function($scope , $uibModalInstance , $controller) {
510 angular.extend(this, $controller('BasePatronSearchCtrl', {$scope : $scope}));
512 $scope.need_one_selected = function() {
513 var items = $scope.gridControls.selectedItems();
514 return (items.length == 1) ? false : true
516 $scope.ok = function() {
517 var items = $scope.gridControls.selectedItems();
518 if (items.length == 1) {
519 $uibModalInstance.close(items[0].card().barcode());
521 $uibModalInstance.close()
524 $scope.cancel = function($event) {
525 $uibModalInstance.dismiss();
526 $event.preventDefault();
532 // also set it when the iframe changes to a new record
533 $scope.handle_page = function(url) {
535 if (!url || url == 'about:blank') {
536 // nothing loaded. If we already have a record ID, leave it.
540 var match = url.match(/\/+opac\/+record\/+(\d+)/);
542 $scope.record_id = match[1];
543 egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
544 $scope.holdings_record_id_changed($scope.record_id);
545 conjoinedSvc.fetch($scope.record_id).then(function(){
546 $scope.conjoinedGridDataProvider.refresh();
548 egHolds.fetch_holds(hold_ids).then($scope.hold_grid_data_provider.refresh);
550 $location.update_path('/cat/catalog/record/' + $scope.record_id);
551 // update_path() bypasses the controller for path
552 // /cat/catalog/record/:record_id. Manually set title here too.
553 egCore.strings.setPageTitle(
554 egCore.strings.PAGE_TITLE_BIB_DETAIL,
555 egCore.strings.PAGE_TITLE_CATALOG_CONTEXT,
556 {record_id : $scope.record_id}
559 delete $scope.record_id;
560 $scope.from_route = false;
563 // child scope is executing this function, so our digest doesn't fire ... thus,
566 if (!$scope.in_opac_call) {
567 if ($scope.record_id && !$scope.record_tab) {
568 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
569 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
571 tab = $routeParams.record_tab || 'catalog';
573 $scope.set_record_tab(tab);
575 $scope.in_opac_call = false;
578 if ($scope.opac_iframe && $location.path().match(/cat\/catalog/)) {
579 var doc = $scope.opac_iframe.dom.contentWindow.document;
580 $(doc).find('#hold_usr_search').show();
581 $(doc).find('#hold_usr_search').on('click', function() {
582 patron_search_dialog().result.then(function(barc) {
583 $(doc).find('#hold_usr_input').val(barc);
584 $(doc).find('#hold_usr_input').change();
591 // xulG catalog handlers
592 $scope.handlers = { }
594 // ------------------------------------------------------------------
597 $scope.conjoinedGridControls = {};
598 $scope.conjoinedGridDataProvider = egGridDataProvider.instance({
599 get : function(offset, count) {
600 return this.arrayNotifier(conjoinedSvc.items, offset, count);
604 $scope.changeConjoinedType = function () {
605 var peers = egCore.idl.Clone($scope.conjoinedGridControls.selectedItems());
606 angular.forEach(peers, function (p) {
607 p.target_copy(p.target_copy().id());
608 p.peer_type(p.peer_type().id());
611 var conjoinedGridDataProviderRef = $scope.conjoinedGridDataProvider;
613 return $uibModal.open({
614 templateUrl: './cat/catalog/t_conjoined_selector',
618 ['$scope','$uibModalInstance',
619 function($scope , $uibModalInstance) {
620 $scope.update = true;
622 $scope.peer_type = null;
623 $scope.peer_type_list = [];
624 conjoinedSvc.get_peer_types().then(function(list){
625 $scope.peer_type_list = list;
628 $scope.ok = function(type) {
631 angular.forEach(peers, function (p) {
634 promises.push(egCore.pcrud.update(p));
637 return $q.all(promises)
638 .then(function(){$uibModalInstance.close()})
639 .then(function(){return conjoinedSvc.fetch()})
640 .then(function(){conjoinedGridDataProviderRef.refresh()});
643 $scope.cancel = function($event) {
644 $uibModalInstance.dismiss();
645 $event.preventDefault();
652 $scope.refreshConjoined = function () {
653 conjoinedSvc.fetch($scope.record_id)
654 .then(function(){$scope.conjoinedGridDataProvider.refresh();});
657 $scope.deleteSelectedConjoined = function () {
658 var peers = $scope.conjoinedGridControls.selectedItems();
660 if (peers.length > 0) {
661 egConfirmDialog.open(
662 egCore.strings.CONFIRM_DELETE_PEERS,
663 egCore.strings.CONFIRM_DELETE_PEERS_MESSAGE,
664 {peers : peers.length}
665 ).result.then(function() {
666 angular.forEach(peers, function (p) {
670 egCore.pcrud.remove(peers).then(function() {
671 return conjoinedSvc.fetch();
673 $scope.conjoinedGridDataProvider.refresh();
678 if ($scope.record_id)
679 conjoinedSvc.fetch($scope.record_id);
681 // ------------------------------------------------------------------
684 $scope.holdingsGridControls = {
685 activateItem : function (item) {
686 $scope.selectedHoldingsVolCopyEdit();
689 $scope.holdingsGridDataProvider = egGridDataProvider.instance({
690 get : function(offset, count) {
691 return this.arrayNotifier(holdingsSvcInst.copies, offset, count);
695 $scope.add_copies_to_bucket = function() {
696 var copy_list = gatherSelectedHoldingsIds();
697 if (copy_list.length == 0) return;
699 return $uibModal.open({
700 templateUrl: './cat/catalog/t_add_to_bucket',
705 ['$scope','$uibModalInstance',
706 function($scope , $uibModalInstance) {
708 $scope.bucket_id = 0;
709 $scope.newBucketName = '';
710 $scope.allBuckets = [];
714 'open-ils.actor.container.retrieve_by_class.authoritative',
715 egCore.auth.token(), egCore.auth.user().id(),
716 'copy', 'staff_client'
717 ).then(function(buckets) { $scope.allBuckets = buckets; });
719 $scope.add_to_bucket = function() {
721 angular.forEach(copy_list, function (cp) {
722 var item = new egCore.idl.ccbi()
723 item.bucket($scope.bucket_id);
724 item.target_copy(cp);
728 'open-ils.actor.container.item.create',
729 egCore.auth.token(), 'copy', item
733 return $q.all(promises).then(function() {
734 $uibModalInstance.close();
739 $scope.add_to_new_bucket = function() {
740 var bucket = new egCore.idl.ccb();
741 bucket.owner(egCore.auth.user().id());
742 bucket.name($scope.newBucketName);
743 bucket.description('');
744 bucket.btype('staff_client');
746 return egCore.net.request(
748 'open-ils.actor.container.create',
749 egCore.auth.token(), 'copy', bucket
750 ).then(function(bucket) {
751 $scope.bucket_id = bucket;
752 $scope.add_to_bucket();
756 $scope.cancel = function() {
757 $uibModalInstance.dismiss();
763 // TODO: refactor common code between cat/catalog/app.js and cat/item/app.js
765 $scope.need_one_selected = function() {
766 var items = $scope.holdingsGridControls.selectedItems();
767 if (items.length == 1) return false;
771 $scope.make_copies_bookable = function() {
773 var copies_by_record = {};
774 var record_list = [];
776 $scope.holdingsGridControls.selectedItems(),
778 var record_id = item['call_number.record.id'];
779 if (typeof copies_by_record[ record_id ] == 'undefined') {
780 copies_by_record[ record_id ] = [];
781 record_list.push( record_id );
783 copies_by_record[ record_id ].push(item.id);
788 var combined_results = [];
789 angular.forEach(record_list, function(record_id) {
793 'open-ils.booking.resources.create_from_copies',
795 copies_by_record[record_id]
796 ).then(function(results) {
797 if (results && results['brsrc']) {
798 combined_results = combined_results.concat(results['brsrc']);
804 $q.all(promises).then(function() {
805 if (combined_results.length > 0) {
807 template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
812 ['$scope','$location','egCore','$uibModalInstance',
813 function($scope , $location , egCore , $uibModalInstance) {
816 ses : egCore.auth.token(),
817 resultant_brsrc : combined_results.map(function(o) { return o[0]; })
820 var booking_path = '/eg/conify/global/booking/resource';
822 $scope.booking_admin_url =
823 $location.absUrl().replace(/\/eg\/staff.*/, booking_path);
830 $scope.book_copies_now = function() {
831 var copies_by_record = {};
832 var record_list = [];
834 $scope.holdingsGridControls.selectedItems(),
836 var record_id = item['call_number.record.id'];
837 if (typeof copies_by_record[ record_id ] == 'undefined') {
838 copies_by_record[ record_id ] = [];
839 record_list.push( record_id );
841 copies_by_record[ record_id ].push(item.id);
846 var combined_brt = [];
847 var combined_brsrc = [];
848 angular.forEach(record_list, function(record_id) {
852 'open-ils.booking.resources.create_from_copies',
854 copies_by_record[record_id]
855 ).then(function(results) {
856 if (results && results['brt']) {
857 combined_brt = combined_brt.concat(results['brt']);
859 if (results && results['brsrc']) {
860 combined_brsrc = combined_brsrc.concat(results['brsrc']);
866 $q.all(promises).then(function() {
867 if (combined_brt.length > 0 || combined_brsrc.length > 0) {
869 template: '<eg-embed-frame url="booking_admin_url" handlers="funcs"></eg-embed-frame>',
874 ['$scope','$location','egCore','$uibModalInstance',
875 function($scope , $location , egCore , $uibModalInstance) {
878 ses : egCore.auth.token(),
879 bresv_interface_opts : {
882 ,brsrc : combined_brsrc
887 var booking_path = '/eg/booking/reservation';
889 $scope.booking_admin_url =
890 $location.absUrl().replace(/\/eg\/staff.*/, booking_path);
899 $scope.requestItems = function() {
900 var copy_list = gatherSelectedHoldingsIds();
901 if (copy_list.length == 0) return;
903 return $uibModal.open({
904 templateUrl: './cat/catalog/t_request_items',
907 ['$scope','$uibModalInstance',
908 function($scope , $uibModalInstance) {
910 $scope.first_user_fetch = true;
914 copy_list : copy_list,
915 pickup_lib: egCore.org.get(egCore.auth.user().ws_ou()),
916 user : egCore.auth.user().id()
919 egUser.get( $scope.hold_data.user ).then(function(u) {
921 $scope.barcode = u.card().barcode();
922 $scope.user_name = egUser.format_name(u);
923 $scope.hold_data.user = u.id();
926 $scope.user_name = '';
928 $scope.$watch('barcode', function (n) {
929 if (!$scope.first_user_fetch) {
930 egUser.getByBarcode(n).then(function(u) {
932 $scope.user_name = egUser.format_name(u);
933 $scope.hold_data.user = u.id();
936 $scope.user_name = '';
937 delete $scope.hold_data.user;
940 $scope.first_user_fetch = false;
943 $scope.ok = function(h) {
946 hold_type : h.hold_type,
947 pickup_lib: h.pickup_lib.id(),
953 'open-ils.circ.holds.test_and_create.batch.override',
954 egCore.auth.token(), args, h.copy_list
957 $uibModalInstance.close();
960 $scope.cancel = function($event) {
961 $uibModalInstance.dismiss();
962 $event.preventDefault();
968 $scope.view_place_orders = function() {
969 if (!$scope.record_id) return;
970 var url = egCore.env.basePath + 'acq/legacy/lineitem/related/' + $scope.record_id + '?target=bib';
971 $timeout(function() { $window.open(url, '_blank') });
974 $scope.replaceBarcodes = function() {
975 var copy_list = gatherSelectedRawCopies();
976 if (copy_list.length == 0) return;
978 var holdingsGridDataProviderRef = $scope.holdingsGridDataProvider;
980 angular.forEach(copy_list, function (cp) {
982 templateUrl: './cat/share/t_replace_barcode',
986 ['$scope','$uibModalInstance',
987 function($scope , $uibModalInstance) {
988 $scope.isModal = true;
989 $scope.focusBarcode = false;
990 $scope.focusBarcode2 = true;
991 $scope.barcode1 = cp.barcode();
993 $scope.updateBarcode = function() {
994 $scope.copyNotFound = false;
995 $scope.updateOK = false;
997 egCore.pcrud.search('acp',
998 {deleted : 'f', barcode : $scope.barcode1})
999 .then(function(copy) {
1002 $scope.focusBarcode = true;
1003 $scope.copyNotFound = true;
1007 $scope.copyId = copy.id();
1008 copy.barcode($scope.barcode2);
1010 egCore.pcrud.update(copy).then(function(stat) {
1011 $scope.updateOK = stat;
1012 $scope.focusBarcode = true;
1013 holdingsSvc.fetchAgain().then(function (){
1014 holdingsGridDataProviderRef.refresh();
1019 $uibModalInstance.close();
1022 $scope.cancel = function($event) {
1023 $uibModalInstance.dismiss();
1024 $event.preventDefault();
1032 // refresh the list of holdings when the record_id is changed.
1033 $scope.holdings_record_id_changed = function(id) {
1034 if ($scope.record_id != id) $scope.record_id = id;
1035 console.log('record id changed to ' + id + ', loading new holdings');
1036 holdingsSvcInst.fetch({
1037 rid : $scope.record_id,
1038 org : $scope.holdings_ou,
1039 copy: $scope.holdings_show_copies,
1040 vol : $scope.holdings_show_vols,
1041 empty: $scope.holdings_show_empty
1042 }).then(function() {
1043 $scope.holdingsGridDataProvider.refresh();
1047 // refresh the list of holdings when the filter lib is changed.
1048 $scope.holdings_ou = egCore.org.get(egCore.auth.user().ws_ou());
1049 $scope.holdings_ou_changed = function(org) {
1050 $scope.holdings_ou = org;
1051 holdingsSvcInst.fetch({
1052 rid : $scope.record_id,
1053 org : $scope.holdings_ou,
1054 copy: $scope.holdings_show_copies,
1055 vol : $scope.holdings_show_vols,
1056 empty: $scope.holdings_show_empty
1057 }).then(function() {
1058 $scope.holdingsGridDataProvider.refresh();
1062 $scope.holdings_cb_changed = function(cb,newVal,norefresh) {
1063 $scope[cb] = newVal;
1064 egCore.hatch.setItem('cat.' + cb, newVal);
1065 if (!norefresh) holdingsSvcInst.fetch({
1066 rid : $scope.record_id,
1067 org : $scope.holdings_ou,
1068 copy: $scope.holdings_show_copies,
1069 vol : $scope.holdings_show_vols,
1070 empty: $scope.holdings_show_empty
1071 }).then(function() {
1072 $scope.holdingsGridDataProvider.refresh();
1076 egCore.hatch.getItem('cat.holdings_show_vols').then(function(x){
1077 if (typeof x == 'undefined') x = true;
1078 $scope.holdings_cb_changed('holdings_show_vols',x,true);
1079 $('#holdings_show_vols').prop('checked', x);
1081 egCore.hatch.getItem('cat.holdings_show_copies').then(function(x){
1082 if (typeof x == 'undefined') x = true;
1083 $scope.holdings_cb_changed('holdings_show_copies',x,true);
1084 $('#holdings_show_copies').prop('checked', x);
1086 egCore.hatch.getItem('cat.holdings_show_empty').then(function(x){
1087 if (typeof x == 'undefined') x = true;
1088 $scope.holdings_cb_changed('holdings_show_empty',x);
1089 $('#holdings_show_empty').prop('checked', x);
1094 $scope.vols_not_shown = function () {
1095 return !$scope.holdings_show_vols;
1098 $scope.copies_not_shown = function () {
1099 return !$scope.holdings_show_copies;
1102 $scope.holdings_checkbox_handler = function (item) {
1103 $scope.holdings_cb_changed(item.checkbox,item.checked);
1106 function gatherSelectedHoldingsIds () {
1107 var cp_id_list = [];
1109 $scope.holdingsGridControls.selectedItems(),
1110 function (item) { cp_id_list = cp_id_list.concat(item.id_list) }
1115 function gatherSelectedRawCopies () {
1118 $scope.holdingsGridControls.selectedItems(),
1119 function (item) { if (item.raw) cp_list = cp_list.concat(item.raw) }
1124 function gatherSelectedEmptyVolumeIds () {
1125 var cn_id_list = [];
1127 $scope.holdingsGridControls.selectedItems(),
1129 if (item.copy_count == 0)
1130 cn_id_list.push(item.call_number.id)
1136 function gatherSelectedVolumeIds () {
1137 var cn_id_list = [];
1139 $scope.holdingsGridControls.selectedItems(),
1141 if (cn_id_list.indexOf(item.call_number.id) == -1)
1142 cn_id_list.push(item.call_number.id)
1148 $scope.selectedHoldingsDelete = function (vols, copies) {
1151 var perCnCopies = {};
1157 $scope.holdingsGridControls.selectedItems(),
1159 if (vols && item.raw_call_number) {
1160 cnHash[item.call_number.id] = egCore.idl.Clone(item.raw_call_number);
1161 cnHash[item.call_number.id].isdeleted(1);
1163 } else if (copies) {
1164 angular.forEach(egCore.idl.Clone(item.raw), function (cp) {
1167 var cn_id = cp.call_number().id();
1168 if (!cnHash[cn_id]) {
1169 cnHash[cn_id] = cp.call_number();
1170 perCnCopies[cn_id] = [cp];
1172 perCnCopies[cn_id].push(cp);
1174 cp.call_number(cn_id); // prevent loops in JSON-ification
1181 angular.forEach(perCnCopies, function (v, k) {
1183 cnHash[k].isdeleted(1);
1186 cnHash[k].copies(v);
1190 angular.forEach(cnHash, function (v, k) {
1194 if (cnList.length == 0) return;
1197 if (vols && copies) flags.force_delete_copies = 1;
1199 egConfirmDialog.open(
1200 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES,
1201 egCore.strings.CONFIRM_DELETE_COPIES_VOLUMES_MESSAGE,
1202 {copies : cp_count, volumes : cn_count}
1203 ).result.then(function() {
1206 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1207 egCore.auth.token(), cnList, 1, flags
1208 ).then(function(update_count) {
1209 holdingsSvcInst.fetchAgain().then(function() {
1210 $scope.holdingsGridDataProvider.refresh();
1215 $scope.selectedHoldingsCopyDelete = function () { $scope.selectedHoldingsDelete(false,true) }
1216 $scope.selectedHoldingsVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,true) }
1217 $scope.selectedHoldingsEmptyVolCopyDelete = function () { $scope.selectedHoldingsDelete(true,false) }
1219 spawnHoldingsAdd = function (vols,copies){
1221 if (copies) { // just a copy on existing volumes
1222 angular.forEach(gatherSelectedVolumeIds(), function (v) {
1223 raw.push( {callnumber : v} );
1226 if (typeof $scope.holdingsGridControls.selectedItems == "function" &&
1227 $scope.holdingsGridControls.selectedItems().length > 0) {
1228 angular.forEach($scope.holdingsGridControls.selectedItems(),
1231 owner : item.owner_id,
1232 label : item.call_number.label
1237 owner : egCore.auth.user().ws_ou()
1242 if (raw.length == 0) raw.push({});
1246 'open-ils.actor.anon_cache.set_value',
1247 null, 'edit-these-copies', {
1248 record_id: $scope.record_id,
1253 ).then(function(key) {
1255 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1256 $timeout(function() { $window.open(url, '_blank') });
1258 alert('Could not create anonymous cache key!');
1262 $scope.selectedHoldingsVolCopyAdd = function () { spawnHoldingsAdd(true,false) }
1263 $scope.selectedHoldingsCopyAdd = function () { spawnHoldingsAdd(false,true) }
1265 spawnHoldingsEdit = function (hide_vols,hide_copies){
1268 'open-ils.actor.anon_cache.set_value',
1269 null, 'edit-these-copies', {
1270 record_id: $scope.record_id,
1271 copies: gatherSelectedHoldingsIds(),
1272 raw: gatherSelectedEmptyVolumeIds().map(
1273 function(v){ return { callnumber : v } }
1275 hide_vols : hide_vols,
1276 hide_copies : hide_copies
1278 ).then(function(key) {
1280 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1281 $timeout(function() { $window.open(url, '_blank') });
1283 alert('Could not create anonymous cache key!');
1287 $scope.selectedHoldingsVolCopyEdit = function () { spawnHoldingsEdit(false,false) }
1288 $scope.selectedHoldingsVolEdit = function () { spawnHoldingsEdit(false,true) }
1289 $scope.selectedHoldingsCopyEdit = function () { spawnHoldingsEdit(true,false) }
1291 $scope.selectedHoldingsItemStatus = function (){
1292 var url = egCore.env.basePath + 'cat/item/search/' + gatherSelectedHoldingsIds().join(',')
1293 $timeout(function() { $window.open(url, '_blank') });
1296 $scope.markVolAsItemTarget = function() {
1297 if ($scope.holdingsGridControls.selectedItems()[0].call_number.id) { // cn.id missing when vols are collapsed
1298 egCore.hatch.setLocalItem(
1299 'eg.cat.item_transfer_target',
1300 $scope.holdingsGridControls.selectedItems()[0].call_number.id
1302 ngToast.create(egCore.strings.MARK_ITEM_TARGET);
1306 $scope.markLibAsVolTarget = function() {
1307 return $uibModal.open({
1308 templateUrl: './cat/catalog/t_choose_vol_target_lib',
1312 ['$scope','$uibModalInstance',
1313 function($scope , $uibModalInstance) {
1315 var orgId = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target') || 1;
1316 $scope.org = egCore.org.get(orgId);
1317 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1318 $scope.ok = function(org) {
1319 egCore.hatch.setLocalItem(
1320 'eg.cat.volume_transfer_target',
1323 $uibModalInstance.close();
1325 $scope.cancel = function($event) {
1326 $uibModalInstance.dismiss();
1327 $event.preventDefault();
1332 $scope.markLibFromSelectedAsVolTarget = function() {
1333 egCore.hatch.setLocalItem(
1334 'eg.cat.volume_transfer_target',
1335 $scope.holdingsGridControls.selectedItems()[0].owner_id
1337 ngToast.create(egCore.strings.MARK_VOL_TARGET);
1340 $scope.selectedHoldingsItemStatusDetail = function (){
1342 gatherSelectedHoldingsIds(),
1344 var url = egCore.env.basePath +
1346 $timeout(function() { $window.open(url, '_blank') });
1351 $scope.transferVolumesToRecord = function (){
1352 var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
1353 if (!target_record) return;
1354 if ($scope.record_id == target_record) return;
1355 var items = $scope.holdingsGridControls.selectedItems();
1356 if (!items.length) return;
1358 var vols_to_move = {};
1359 angular.forEach(items, function(item) {
1360 if (!(item.call_number.owning_lib in vols_to_move)) {
1361 vols_to_move[item.call_number.owning_lib] = new Array;
1363 vols_to_move[item.call_number.owning_lib].push(item.call_number.id);
1367 angular.forEach(vols_to_move, function(vols, owning_lib) {
1368 promises.push(egCore.net.request(
1370 'open-ils.cat.asset.volume.batch.transfer.override',
1371 egCore.auth.token(), {
1372 docid : target_record,
1378 $q.all(promises).then(function(success) {
1380 ngToast.create(egCore.strings.VOLS_TRANSFERED);
1381 holdingsSvcInst.fetchAgain().then(function() {
1382 $scope.holdingsGridDataProvider.refresh();
1385 alert('Could not transfer volumes!');
1390 function transferVolumes(new_record){
1391 var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
1396 'open-ils.cat.asset.volume.batch.transfer.override',
1397 egCore.auth.token(), {
1398 docid : (new_record ? new_record : $scope.record_id),
1400 volumes : gatherSelectedVolumeIds()
1402 ).then(function(success) {
1404 ngToast.create(egCore.strings.VOLS_TRANSFERED);
1405 holdingsSvcInst.fetchAgain().then(function() {
1406 $scope.holdingsGridDataProvider.refresh();
1409 alert('Could not transfer volumes!');
1416 $scope.transferVolumesToLibrary = function() {
1420 $scope.transferVolumesToRecordAndLibrary = function() {
1421 var target_record = egCore.hatch.getLocalItem('eg.cat.marked_volume_transfer_record');
1422 if (!target_record) return;
1423 transferVolumes(target_record);
1426 // this "transfers" selected copies to a new owning library,
1427 // auto-creating volumes and deleting unused volumes as required.
1428 $scope.changeItemOwningLib = function() {
1429 var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
1430 var items = $scope.holdingsGridControls.selectedItems();
1431 if (!xfer_target || !items.length) {
1434 var vols_to_move = {};
1435 var copies_to_move = {};
1436 angular.forEach(items, function(item) {
1437 if (item.call_number.owning_lib != xfer_target) {
1438 if (item.call_number.id in vols_to_move) {
1439 copies_to_move[item.call_number.id].push(item.id);
1441 vols_to_move[item.call_number.id] = item.call_number;
1442 copies_to_move[item.call_number.id] = new Array;
1443 copies_to_move[item.call_number.id].push(item.id);
1449 angular.forEach(vols_to_move, function(vol) {
1450 promises.push(egCore.net.request(
1452 'open-ils.cat.call_number.find_or_create',
1453 egCore.auth.token(),
1460 ).then(function(resp) {
1461 var evt = egCore.evt.parse(resp);
1463 return egCore.net.request(
1465 'open-ils.cat.transfer_copies_to_volume',
1466 egCore.auth.token(),
1468 copies_to_move[vol.id]
1472 $q.all(promises).then(function() {
1473 ngToast.create(egCore.strings.ITEMS_TRANSFERED);
1474 holdingsSvcInst.fetchAgain().then(function() {
1475 $scope.holdingsGridDataProvider.refresh();
1480 $scope.transferItems = function (){
1481 var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
1482 var copy_ids = gatherSelectedHoldingsIds();
1483 if (xfer_target && copy_ids.length > 0) {
1486 'open-ils.cat.transfer_copies_to_volume',
1487 egCore.auth.token(),
1491 function(resp) { // oncomplete
1492 var evt = egCore.evt.parse(resp);
1494 egConfirmDialog.open(
1495 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_TITLE,
1496 egCore.strings.OVERRIDE_TRANSFER_COPIES_TO_MARKED_VOLUME_BODY,
1497 {'evt_desc': evt.desc}
1498 ).result.then(function() {
1501 'open-ils.cat.transfer_copies_to_volume.override',
1502 egCore.auth.token(),
1505 { events: ['TITLE_LAST_COPY', 'COPY_DELETE_WARNING'] }
1506 ).then(function(resp) {
1507 holdingsSvcInst.fetchAgain().then(function() {
1508 $scope.holdingsGridDataProvider.refresh();
1513 ngToast.create(egCore.strings.ITEMS_TRANSFERED);
1514 holdingsSvcInst.fetchAgain().then(function() {
1515 $scope.holdingsGridDataProvider.refresh();
1525 $scope.selectedHoldingsItemStatusTgrEvt = function (){
1527 gatherSelectedHoldingsIds(),
1529 var url = egCore.env.basePath +
1530 'cat/item/' + cid + '/triggered_events';
1531 $timeout(function() { $window.open(url, '_blank') });
1536 $scope.selectedHoldingsItemStatusHolds = function (){
1538 gatherSelectedHoldingsIds(),
1540 var url = egCore.env.basePath +
1541 'cat/item/' + cid + '/holds';
1542 $timeout(function() { $window.open(url, '_blank') });
1547 $scope.selectedHoldingsPrintLabels = function() {
1550 'open-ils.actor.anon_cache.set_value',
1551 null, 'print-labels-these-copies', {
1552 copies : gatherSelectedHoldingsIds()
1554 ).then(function(key) {
1556 var url = egCore.env.basePath + 'cat/printlabels/' + key;
1557 $timeout(function() { $window.open(url, '_blank') });
1559 alert('Could not create anonymous cache key!');
1564 $scope.selectedHoldingsDamaged = function () {
1565 var copy_list = gatherSelectedRawCopies();
1566 if (copy_list.length == 0) return;
1568 angular.forEach(copy_list, function(cp) {
1569 egCirc.mark_damaged({
1571 barcode: cp.barcode(),
1572 circ_lib: cp.circ_lib().id()
1573 }).then(function() {
1574 holdingsSvcInst.fetchAgain().then(function() {
1575 $scope.holdingsGridDataProvider.refresh();
1581 $scope.selectedHoldingsMissing = function () {
1582 egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() {
1583 holdingsSvcInst.fetchAgain().then(function() {
1584 $scope.holdingsGridDataProvider.refresh();
1589 $scope.attach_to_peer_bib = function() {
1590 var copy_list = gatherSelectedHoldingsIds();
1591 if (copy_list.length == 0) return;
1593 egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
1594 if (!target_record) return;
1596 return $uibModal.open({
1597 templateUrl: './cat/catalog/t_conjoined_selector',
1601 ['$scope','$uibModalInstance',
1602 function($scope , $uibModalInstance) {
1603 $scope.update = false;
1605 $scope.peer_type = null;
1606 $scope.peer_type_list = [];
1607 conjoinedSvc.get_peer_types().then(function(list){
1608 $scope.peer_type_list = list;
1611 $scope.ok = function(type) {
1614 angular.forEach(copy_list, function (cp) {
1615 var n = new egCore.idl.bpbcm();
1617 n.peer_record(target_record);
1620 promises.push(egCore.pcrud.create(n));
1623 return $q.all(promises).then(function(){$uibModalInstance.close()});
1626 $scope.cancel = function($event) {
1627 $uibModalInstance.dismiss();
1628 $event.preventDefault();
1636 // ------------------------------------------------------------------
1638 var provider = egGridDataProvider.instance({});
1639 $scope.hold_grid_data_provider = provider;
1640 $scope.grid_actions = egHoldGridActions;
1641 $scope.grid_actions.refresh = function () { provider.refresh() };
1642 $scope.hold_grid_controls = {};
1644 var hold_ids = []; // current list of holds
1645 function fetchHolds(offset, count) {
1646 var ids = hold_ids.slice(offset, offset + count);
1648 return egHolds.fetch_holds(ids).then(null, null,
1649 function(hold_data) {
1655 provider.get = function(offset, count) {
1656 if ($scope.record_tab != 'holds') return $q.when();
1657 var deferred = $q.defer();
1658 hold_ids = []; // no caching ATM
1660 // open a determinate progress dialog, max value set below.
1661 egProgressDialog.open({max : 1, value : 0});
1666 'open-ils.circ.holds.retrieve_all_from_title',
1667 egCore.auth.token(), $scope.record_id,
1668 {pickup_lib : egCore.org.descendants($scope.pickup_ou.id(), true)}
1670 function(hold_data) {
1671 hold_ids = []; // clear the list of ids, hack to avoid dups
1672 // TODO: fix the underlying problem, which is that
1673 // this gets called twice when switching to the holds
1674 // tab; once explicitly, and once via the change handler
1675 // on the OU selector
1676 angular.forEach(hold_data, function(list, type) {
1677 hold_ids = hold_ids.concat(list);
1680 // Set the max value of the progress bar to the lesser of
1681 // the total number of holds to fetch or the page size
1683 egProgressDialog.update(
1684 {max : Math.min(hold_ids.length, count)});
1686 var holds_fetched = 0;
1687 fetchHolds(offset, count)
1688 .then(deferred.resolve, null,
1689 function(hold_data) {
1691 deferred.notify(hold_data);
1692 egProgressDialog.increment();
1694 )['finally'](egProgressDialog.close);
1698 return deferred.promise;
1701 $scope.detail_view = function(action, user_data, items) {
1703 $scope.detail_hold_id = h.hold.id();
1707 $scope.list_view = function(items) {
1708 $scope.detail_hold_id = null;
1711 // refresh the list of record holds when the pickup lib is changed.
1712 $scope.pickup_ou = egCore.org.get(egCore.auth.user().ws_ou());
1713 $scope.pickup_ou_changed = function(org) {
1714 $scope.pickup_ou = org;
1718 $scope.print_holds = function() {
1720 angular.forEach($scope.hold_grid_controls.allItems(), function(item) {
1722 hold : egCore.idl.toHash(item.hold),
1723 patron_last : item.patron_last,
1724 patron_alias : item.patron_alias,
1725 patron_barcode : item.patron_barcode,
1726 copy : egCore.idl.toHash(item.copy),
1727 volume : egCore.idl.toHash(item.volume),
1728 title : item.mvr.title(),
1729 author : item.mvr.author()
1733 egCore.print.print({
1734 context : 'receipt',
1735 template : 'holds_for_bib',
1736 scope : {holds : holds}
1740 $scope.current_hold_transfer_dest = egCore.hatch.getLocalItem ('eg.circ.hold.title_transfer_target');
1742 $scope.mark_hold_transfer_dest = function() {
1743 $scope.current_hold_transfer_dest = $scope.record_id;
1744 egCore.hatch.setLocalItem(
1745 'eg.circ.hold.title_transfer_target', $scope.record_id);
1746 ngToast.create(egCore.strings.HOLD_TRANSFER_DEST_MARKED);
1749 // UI presents this option as "all holds"
1750 $scope.transfer_holds_to_marked = function() {
1751 var hold_ids = $scope.hold_grid_controls.allItems().map(
1752 function(hold_data) {return hold_data.hold.id()});
1753 egHolds.transfer_to_marked_title(hold_ids);
1756 // ------------------------------------------------------------------
1757 // Initialize the selected tab
1759 // we explicitly initialize catalog_url because otherwise Firefox
1760 // ends up setting it to $BASE_URL/{{url}}, which then messes
1761 // things up. See LP#1708951
1762 $scope.catalog_url = '';
1764 function init_cat_url() {
1765 // Set the initial catalog URL. This only happens once.
1766 // The URL is otherwise generated through user navigation.
1767 if ($scope.catalog_url) return;
1769 var url = $location.absUrl().replace(/\/staff.*/, '/opac/advanced');
1771 // A record ID in the path indicates a request for the record-
1773 if ($routeParams.record_id) {
1774 url = url.replace(/advanced/, '/record/' + $scope.record_id);
1777 // Jumping directly to the results page by passing a search
1778 // query via the URL. Copy all URL params to the iframe url.
1779 if ($location.path().match(/catalog\/results/)) {
1780 url = url.replace(/advanced/, '/results?');
1782 angular.forEach($location.search(), function(val, key) {
1783 if (!first) url += '&';
1785 url += encodeURIComponent(key)
1786 + '=' + encodeURIComponent(val);
1790 // if we're displaying the advanced search form, select
1791 // whatever default pane the user has chosen via workstation
1793 if (url.match(/\/opac\/advanced$/)) {
1794 var adv_pane = egCore.hatch.getLocalItem('eg.search.adv_pane');
1796 url += '?pane=' + encodeURIComponent(adv_pane);
1800 $scope.catalog_url = url;
1803 function init_parts_url() {
1804 $scope.parts_url = $location
1808 '/conify/global/biblio/monograph_part?r='+$scope.record_id
1812 $scope.set_record_tab = function(tab) {
1813 $scope.record_tab = tab;
1826 $scope.detail_hold_record_id = $scope.record_id;
1827 // refresh the holds grid
1834 $scope.set_default_record_tab = function() {
1835 egCore.hatch.setLocalItem(
1836 'eg.cat.default_record_tab', $scope.record_tab);
1837 $timeout(function(){$scope.default_tab = $scope.record_tab});
1841 if ($scope.record_id) {
1842 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
1843 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
1846 tab = $routeParams.record_tab || 'catalog';
1848 $scope.set_record_tab(tab);
1852 .controller('AuthorityCtrl',
1853 ['$scope','$routeParams','$location','$window','$q','egCore',
1854 function($scope , $routeParams , $location , $window , $q , egCore) {
1856 // set record ID on page load if available...
1857 $scope.authority_id = $routeParams.authority_id;
1859 if ($routeParams.authority_id) $scope.from_route = true;
1860 else $scope.from_route = false;
1862 $scope.stop_unload = false;
1865 .controller('URLVerifyCtrl',
1866 ['$scope','$location',
1867 function($scope , $location) {
1868 $scope.verifyurls_url = $location.absUrl().replace(/\/staff.*/, '/url_verify/sessions');
1871 .controller('VandelayCtrl',
1872 ['$scope','$location', 'egCore', '$uibModal',
1873 function($scope , $location, egCore, $uibModal) {
1874 $scope.vandelay_url = $location.absUrl().replace(/\/staff\/cat\/catalog\/vandelay/, '/vandelay/vandelay');
1876 $scope.funcs.edit_marc_modal = function(bre, callback){
1877 var marcArgs = { 'marc_xml': bre.marc() };
1878 var vqbibrecId = bre.id();
1880 templateUrl: './cat/catalog/t_edit_marc_modal',
1883 controller: ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) {
1884 $scope.focusMe = true;
1885 $scope.recordId = vqbibrecId;
1886 $scope.args = marcArgs;
1887 $scope.dirty_flag = false;
1888 $scope.ok = function(marg){
1889 $uibModalInstance.close(marg);
1891 $scope.cancel = function(){ $uibModalInstance.dismiss() }
1893 }).result.then(function(res){
1894 var new_xml = res.marc_xml;
1895 egCore.pcrud.retrieve('vqbr', vqbibrecId).then(function(vqbib){
1896 vqbib.marc(new_xml);
1897 egCore.pcrud.update(vqbib).then( function(){ callback(vqbibrecId); });
1903 .controller('ManageAuthoritiesCtrl',
1904 ['$scope','$location',
1905 function($scope , $location) {
1906 $scope.manageauthorities_url = $location.absUrl().replace(/\/staff.*/, '/cat/authority/list');
1909 .controller('BatchEditCtrl',
1910 ['$scope','$location','$routeParams',
1911 function($scope , $location , $routeParams) {
1912 $scope.batchedit_url = $location.absUrl().replace(/\/eg.*/, '/opac/extras/merge_template');
1913 if ($routeParams.container_type) {
1914 switch ($routeParams.container_type) {
1916 $scope.batchedit_url += '?recordSource=b&containerid=' + $routeParams.container_id;
1919 $scope.batchedit_url += '?recordSource=r&recid=' + $routeParams.container_id;
1926 .filter('boolText', function(){
1927 return function (v) {
1932 .factory('conjoinedSvc',
1934 function(egCore , $q) {
1937 items : [], // record search results
1938 index : 0, // search grid index
1945 bpbcm : ['target_copy','peer_type'],
1946 acp : ['call_number'],
1948 bre : ['simple_record']
1950 // avoid fetching the MARC blob by specifying which
1951 // fields on the bre to select. More may be needed.
1952 // note that fleshed fields are explicitly selected.
1953 select : { bre : ['id'] },
1954 order_by : { bpbcm : ['id'] },
1957 // resolved with the last received copy
1958 service.fetch = function(rid) {
1959 if (!rid && !service.rid) return $q.when();
1961 if (rid) service.rid = rid;
1965 return egCore.pcrud.search(
1967 {peer_record : service.rid},
1970 ).then( function(list) { // finished
1971 service.items = list;
1972 return service.items;
1976 // returns a promise resolved with the list of peer bib types
1977 service.get_peer_types = function() {
1979 return $q.when(egCore.env.bpt.list);
1981 return egCore.pcrud.retrieveAll('bpt', null, {atomic : true})
1982 .then(function(list) {
1983 egCore.env.absorbList(list, 'bpt');