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','egCoreMod','egGridMod', 'egMarcMod'])
12 .config(function($routeProvider, $locationProvider, $compileProvider) {
13 $locationProvider.html5Mode(true);
14 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export
16 var resolver = {delay : ['egCore','egStartup', function(egCore, egStartup) {
17 egCore.env.classLoaders.aous = function() {
18 return egCore.org.settings([
19 'cat.marc_control_number_identifier'
20 ]).then(function(settings) {
21 // local settings are cached within egOrg. Caching them
22 // again in egEnv just simplifies the syntax for access.
23 egCore.env.aous = settings;
26 egCore.env.loadClasses.push('aous');
30 $routeProvider.when('/cat/catalog/index', {
31 templateUrl: './cat/catalog/t_catalog',
32 controller: 'CatalogCtrl',
36 $routeProvider.when('/cat/catalog/retrieve_by_id', {
37 templateUrl: './cat/catalog/t_retrieve_by_id',
38 controller: 'CatalogRecordRetrieve',
42 $routeProvider.when('/cat/catalog/retrieve_by_tcn', {
43 templateUrl: './cat/catalog/t_retrieve_by_tcn',
44 controller: 'CatalogRecordRetrieve',
48 // create some catalog page-specific mappings
49 $routeProvider.when('/cat/catalog/record/:record_id', {
50 templateUrl: './cat/catalog/t_catalog',
51 controller: 'CatalogCtrl',
55 // create some catalog page-specific mappings
56 $routeProvider.when('/cat/catalog/record/:record_id/:record_tab', {
57 templateUrl: './cat/catalog/t_catalog',
58 controller: 'CatalogCtrl',
62 $routeProvider.when('/cat/catalog/batchEdit', {
63 templateUrl: './cat/catalog/t_batchedit',
64 controller: 'BatchEditCtrl',
68 $routeProvider.when('/cat/catalog/batchEdit/:container_type/:container_id', {
69 templateUrl: './cat/catalog/t_batchedit',
70 controller: 'BatchEditCtrl',
74 $routeProvider.when('/cat/catalog/vandelay', {
75 templateUrl: './cat/catalog/t_vandelay',
76 controller: 'VandelayCtrl',
80 $routeProvider.when('/cat/catalog/verifyURLs', {
81 templateUrl: './cat/catalog/t_verifyurls',
82 controller: 'URLVerifyCtrl',
86 $routeProvider.when('/cat/catalog/manageAuthorities', {
87 templateUrl: './cat/catalog/t_manageauthorities',
88 controller: 'ManageAuthoritiesCtrl',
92 $routeProvider.when('/cat/catalog/authority/:authority_id/marc_edit', {
93 templateUrl: './cat/catalog/t_authority',
94 controller: 'AuthorityCtrl',
98 $routeProvider.otherwise({redirectTo : '/cat/catalog/index'});
104 .controller('CatalogRecordRetrieve',
105 ['$scope','$routeParams','$location','$q','egCore',
106 function($scope , $routeParams , $location , $q , egCore ) {
108 $scope.focusMe = true;
110 // jump to the patron checkout UI
111 function loadRecord(record_id) {
113 .path('/cat/catalog/record/' + record_id);
116 $scope.submitId = function(args) {
117 $scope.recordNotFound = null;
118 if (!args.record_id) return;
120 // blur so next time it's set to true it will re-apply select()
121 $scope.selectMe = false;
123 return loadRecord(args.record_id);
126 $scope.submitTCN = function(args) {
127 $scope.recordNotFound = null;
128 $scope.moreRecordsFound = null;
129 if (!args.record_tcn) return;
131 // blur so next time it's set to true it will re-apply select()
132 $scope.selectMe = false;
137 'open-ils.search.biblio.tcn',
140 .then(function(resp) { // get_barcodes
142 if (evt = egCore.evt.parse(resp)) {
148 $scope.recordNotFound = args.record_tcn;
149 $scope.selectMe = true;
153 if (resp.count > 1) {
154 $scope.moreRecordsFound = args.record_tcn;
155 $scope.selectMe = true;
159 var record_id = resp.ids[0];
160 return loadRecord(record_id);
166 .controller('CatalogCtrl',
167 ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc',
168 'egGridDataProvider','egHoldGridActions','$timeout','holdingsSvc',
169 function($scope , $routeParams , $location , $window , $q , egCore , egHolds , egCirc,
170 egGridDataProvider , egHoldGridActions , $timeout , holdingsSvc) {
172 // set record ID on page load if available...
173 $scope.record_id = $routeParams.record_id;
175 if ($routeParams.record_id) $scope.from_route = true;
176 else $scope.from_route = false;
178 // will hold a ref to the opac iframe
179 $scope.opac_iframe = null;
180 $scope.parts_iframe = null;
182 $scope.in_opac_call = false;
183 $scope.opac_call = function (opac_frame_function, force_opac_tab) {
184 if ($scope.opac_iframe) {
185 if (force_opac_tab) $scope.record_tab = 'catalog';
186 $scope.in_opac_call = true;
187 $scope.opac_iframe.dom.contentWindow[opac_frame_function]();
191 $scope.stop_unload = false;
192 $scope.$watch('stop_unload',
193 function(newVal, oldVal) {
194 if (newVal && newVal != oldVal && $scope.opac_iframe) {
195 $($scope.opac_iframe.dom.contentWindow).on('beforeunload', function(){
196 return 'There is unsaved data in this record.'
199 if ($scope.opac_iframe)
200 $($scope.opac_iframe.dom.contentWindow).off('beforeunload');
205 // Set the "last bib" cookie, if we have that
206 if ($scope.record_id)
207 egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
209 // also set it when the iframe changes to a new record
210 $scope.handle_page = function(url) {
212 if (!url || url == 'about:blank') {
213 // nothing loaded. If we already have a record ID, leave it.
217 var match = url.match(/\/+opac\/+record\/+(\d+)/);
219 $scope.record_id = match[1];
220 egCore.hatch.setLocalItem("eg.cat.last_record_retrieved", $scope.record_id);
221 $scope.holdings_record_id_changed($scope.record_id);
224 delete $scope.record_id;
225 $scope.from_route = false;
228 // child scope is executing this function, so our digest doesn't fire ... thus,
231 if (!$scope.in_opac_call) {
232 if ($scope.record_id) {
233 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
234 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
236 tab = $routeParams.record_tab || 'catalog';
238 $scope.set_record_tab(tab);
240 $scope.in_opac_call = false;
244 // xulG catalog handlers
245 $scope.handlers = { }
247 // ------------------------------------------------------------------
250 $scope.holdingsGridControls = {};
251 $scope.holdingsGridDataProvider = egGridDataProvider.instance({
252 get : function(offset, count) {
253 return this.arrayNotifier(holdingsSvc.copies, offset, count);
257 // refresh the list of holdings when the record_id is changed.
258 $scope.holdings_record_id_changed = function(id) {
259 if ($scope.record_id != id) $scope.record_id = id;
260 console.log('record id changed to ' + id + ', loading new holdings');
262 rid : $scope.record_id,
263 org : $scope.holdings_ou,
264 copy: $scope.holdings_show_copies,
265 vol : $scope.holdings_show_vols,
266 empty: $scope.holdings_show_empty
268 $scope.holdingsGridDataProvider.refresh();
272 // refresh the list of holdings when the filter lib is changed.
273 $scope.holdings_ou = egCore.org.get(egCore.auth.user().ws_ou());
274 $scope.holdings_ou_changed = function(org) {
275 $scope.holdings_ou = org;
277 rid : $scope.record_id,
278 org : $scope.holdings_ou,
279 copy: $scope.holdings_show_copies,
280 vol : $scope.holdings_show_vols,
281 empty: $scope.holdings_show_empty
283 $scope.holdingsGridDataProvider.refresh();
287 $scope.holdings_cb_changed = function(cb,newVal,norefresh) {
289 egCore.hatch.setItem('cat.' + cb, newVal);
290 if (!norefresh) holdingsSvc.fetch({
291 rid : $scope.record_id,
292 org : $scope.holdings_ou,
293 copy: $scope.holdings_show_copies,
294 vol : $scope.holdings_show_vols,
295 empty: $scope.holdings_show_empty
297 $scope.holdingsGridDataProvider.refresh();
301 egCore.hatch.getItem('cat.holdings_show_vols').then(function(x){
302 if (typeof x == 'undefined') x = true;
303 $scope.holdings_cb_changed('holdings_show_vols',x,true);
304 $('#holdings_show_vols').prop('checked', x);
306 egCore.hatch.getItem('cat.holdings_show_copies').then(function(x){
307 if (typeof x == 'undefined') x = true;
308 $scope.holdings_cb_changed('holdings_show_copies',x,true);
309 $('#holdings_show_copies').prop('checked', x);
311 egCore.hatch.getItem('cat.holdings_show_empty').then(function(x){
312 if (typeof x == 'undefined') x = true;
313 $scope.holdings_cb_changed('holdings_show_empty',x);
314 $('#holdings_show_empty').prop('checked', x);
319 $scope.vols_not_shown = function () {
320 return !$scope.holdings_show_vols;
323 $scope.holdings_checkbox_handler = function (item) {
324 $scope.holdings_cb_changed(item.checkbox,item.checked);
327 function gatherSelectedHoldingsIds () {
330 $scope.holdingsGridControls.selectedItems(),
331 function (item) { cp_id_list = cp_id_list.concat(item.id_list) }
336 function gatherSelectedRawCopies () {
339 $scope.holdingsGridControls.selectedItems(),
340 function (item) { cp_list = cp_list.concat(item.raw) }
345 function gatherSelectedVolumeIds () {
348 $scope.holdingsGridControls.selectedItems(),
350 if (cn_id_list.indexOf(item.call_number.id) == -1)
351 cn_id_list.push(item.call_number.id)
357 spawnHoldingsEdit = function (hide_vols,hide_copies){
360 'open-ils.actor.anon_cache.set_value',
361 null, 'edit-these-copies', {
362 record_id: $scope.record_id,
363 copies: gatherSelectedHoldingsIds(),
364 hide_vols : hide_vols,
365 hide_copies : hide_copies
367 ).then(function(key) {
369 var url = egCore.env.basePath + 'cat/volcopy/' + key;
370 $timeout(function() { $window.open(url, '_blank') });
372 alert('Could not create anonymous cache key!');
376 $scope.selectedHoldingsVolCopyEdit = function () { spawnHoldingsEdit(false,false) }
377 $scope.selectedHoldingsVolEdit = function () { spawnHoldingsEdit(false,true) }
378 $scope.selectedHoldingsCopyEdit = function () { spawnHoldingsEdit(true,false) }
380 $scope.selectedHoldingsItemStatus = function (){
381 var url = egCore.env.basePath + 'cat/item/search/' + gatherSelectedHoldingsIds().join(',')
382 $timeout(function() { $window.open(url, '_blank') });
385 $scope.markVolAsItemTarget = function() {
386 if ($scope.holdingsGridControls.selectedItems()[0].call_number.id) { // cn.id missing when vols are collapsed
387 egCore.hatch.setLocalItem(
388 'eg.cat.item_transfer_target',
389 $scope.holdingsGridControls.selectedItems()[0].call_number.id
391 console.log('item_transfer_dest: '+$scope.holdingsGridControls.selectedItems()[0].call_number.id);
395 $scope.markLibAsVolTarget = function() {
396 egCore.hatch.setLocalItem(
397 'eg.cat.volume_transfer_target',
398 $scope.holdingsGridControls.selectedItems()[0].owner_id
400 console.log('vol_transfer_dest: '+$scope.holdingsGridControls.selectedItems()[0].owner_id);
403 $scope.selectedHoldingsItemStatusDetail = function (){
405 gatherSelectedHoldingsIds(),
407 var url = egCore.env.basePath +
409 $timeout(function() { $window.open(url, '_blank') });
414 $scope.transferVolumes = function (){
415 var xfer_target = egCore.hatch.getLocalItem('eg.cat.volume_transfer_target');
420 'open-ils.open-ils.cat.asset.volume.batch.transfer.override',
421 egCore.auth.token(), {
422 docid : $scope.record_id,
424 volumes : gatherSelectedVolumeIds()
426 ).then(function(success) {
429 rid : $scope.record_id,
430 org : $scope.holdings_ou,
431 copy: $scope.holdings_show_copies,
432 vol : $scope.holdings_show_vols,
433 empty: $scope.holdings_show_empty
435 $scope.holdingsGridDataProvider.refresh();
438 alert('Could not transfer volumes!');
445 $scope.transferItems = function (){
446 var xfer_target = egCore.hatch.getLocalItem('eg.cat.item_transfer_target');
448 var copy_list = gatherSelectedRawCopies();
450 angular.forEach(copy_list, function (cp) {
451 cp.call_number(xfer_target);
456 ).then(function(success) {
459 rid : $scope.record_id,
460 org : $scope.holdings_ou,
461 copy: $scope.holdings_show_copies,
462 vol : $scope.holdings_show_vols,
463 empty: $scope.holdings_show_empty
465 $scope.holdingsGridDataProvider.refresh();
468 alert('Could not transfer items!');
475 $scope.selectedHoldingsItemStatusTgrEvt = function (){
477 gatherSelectedHoldingsIds(),
479 var url = egCore.env.basePath +
480 'cat/item/' + cid + '/triggered_events';
481 $timeout(function() { $window.open(url, '_blank') });
486 $scope.selectedHoldingsItemStatusHolds = function (){
488 gatherSelectedHoldingsIds(),
490 var url = egCore.env.basePath +
491 'cat/item/' + cid + '/holds';
492 $timeout(function() { $window.open(url, '_blank') });
497 $scope.selectedHoldingsDamaged = function () {
498 egCirc.mark_damaged(gatherSelectedHoldingsIds()).then(function() {
500 rid : $scope.record_id,
501 org : $scope.holdings_ou,
502 copy: $scope.holdings_show_copies,
503 vol : $scope.holdings_show_vols,
504 empty: $scope.holdings_show_empty
506 $scope.holdingsGridDataProvider.refresh();
511 $scope.selectedHoldingsMissing = function () {
512 egCirc.mark_missing(gatherSelectedHoldingsIds()).then(function() {
514 rid : $scope.record_id,
515 org : $scope.holdings_ou,
516 copy: $scope.holdings_show_copies,
517 vol : $scope.holdings_show_vols,
518 empty: $scope.holdings_show_empty
520 $scope.holdingsGridDataProvider.refresh();
526 // ------------------------------------------------------------------
528 var provider = egGridDataProvider.instance({});
529 $scope.hold_grid_data_provider = provider;
530 $scope.grid_actions = egHoldGridActions;
531 $scope.grid_actions.refresh = function () { provider.refresh() };
532 $scope.hold_grid_controls = {};
534 var hold_ids = []; // current list of holds
535 function fetchHolds(offset, count) {
536 var ids = hold_ids.slice(offset, offset + count);
537 return egHolds.fetch_holds(ids).then(null, null,
538 function(hold_data) {
544 provider.get = function(offset, count) {
545 if ($scope.record_tab != 'holds') return $q.when();
546 var deferred = $q.defer();
547 hold_ids = []; // no caching ATM
552 'open-ils.circ.holds.retrieve_all_from_title',
553 egCore.auth.token(), $scope.record_id,
554 {pickup_lib : egCore.org.descendants($scope.pickup_ou.id(), true)}
556 function(hold_data) {
557 angular.forEach(hold_data, function(list, type) {
558 hold_ids = hold_ids.concat(list);
560 fetchHolds(offset, count).then(
561 deferred.resolve, null, deferred.notify);
565 return deferred.promise;
568 $scope.detail_view = function(action, user_data, items) {
570 $scope.detail_hold_id = h.hold.id();
574 $scope.list_view = function(items) {
575 $scope.detail_hold_id = null;
578 // refresh the list of record holds when the pickup lib is changed.
579 $scope.pickup_ou = egCore.org.get(egCore.auth.user().ws_ou());
580 $scope.pickup_ou_changed = function(org) {
581 $scope.pickup_ou = org;
585 $scope.print_holds = function() {
587 angular.forEach($scope.hold_grid_controls.allItems(), function(item) {
589 hold : egCore.idl.toHash(item.hold),
590 patron_last : item.patron_last,
591 patron_alias : item.patron_alias,
592 patron_barcode : item.patron_barcode,
593 copy : egCore.idl.toHash(item.copy),
594 volume : egCore.idl.toHash(item.volume),
595 title : item.mvr.title(),
596 author : item.mvr.author()
602 template : 'holds_for_bib',
603 scope : {holds : holds}
607 $scope.mark_hold_transfer_dest = function() {
608 egCore.hatch.setLocalItem(
609 'eg.circ.hold.title_transfer_target', $scope.record_id);
612 // UI presents this option as "all holds"
613 $scope.transfer_holds_to_marked = function() {
614 var hold_ids = $scope.hold_grid_controls.allItems().map(
615 function(hold_data) {return hold_data.hold.id()});
616 egHolds.transfer_to_marked_title(hold_ids);
619 // ------------------------------------------------------------------
620 // Initialize the selected tab
622 function init_cat_url() {
623 // Set the initial catalog URL. This only happens once.
624 // The URL is otherwise generated through user navigation.
625 if ($scope.catalog_url) return;
627 var url = $location.absUrl().replace(/\/staff.*/, '/opac/advanced');
629 // A record ID in the path indicates a request for the record-
631 if ($routeParams.record_id) {
632 url = url.replace(/advanced/, '/record/' + $scope.record_id);
635 $scope.catalog_url = url;
638 function init_parts_url() {
639 $scope.parts_url = $location
643 '/conify/global/biblio/monograph_part?r='+$scope.record_id
647 $scope.set_record_tab = function(tab) {
648 $scope.record_tab = tab;
661 $scope.detail_hold_record_id = $scope.record_id;
662 // refresh the holds grid
668 $scope.set_default_record_tab = function() {
669 egCore.hatch.setLocalItem(
670 'eg.cat.default_record_tab', $scope.record_tab);
671 $timeout(function(){$scope.default_tab = $scope.record_tab});
675 if ($scope.record_id) {
676 $scope.default_tab = egCore.hatch.getLocalItem( 'eg.cat.default_record_tab' );
677 tab = $routeParams.record_tab || $scope.default_tab || 'catalog';
680 tab = $routeParams.record_tab || 'catalog';
682 $scope.set_record_tab(tab);
686 .controller('AuthorityCtrl',
687 ['$scope','$routeParams','$location','$window','$q','egCore',
688 function($scope , $routeParams , $location , $window , $q , egCore) {
690 // set record ID on page load if available...
691 $scope.authority_id = $routeParams.authority_id;
693 if ($routeParams.authority_id) $scope.from_route = true;
694 else $scope.from_route = false;
696 $scope.stop_unload = false;
699 .controller('URLVerifyCtrl',
700 ['$scope','$location',
701 function($scope , $location) {
702 $scope.verifyurls_url = $location.absUrl().replace(/\/staff.*/, '/url_verify/sessions');
705 .controller('VandelayCtrl',
706 ['$scope','$location',
707 function($scope , $location) {
708 $scope.vandelay_url = $location.absUrl().replace(/\/staff.*/, '/vandelay/vandelay');
711 .controller('ManageAuthoritiesCtrl',
712 ['$scope','$location',
713 function($scope , $location) {
714 $scope.manageauthorities_url = $location.absUrl().replace(/\/staff.*/, '/cat/authority/list');
717 .controller('BatchEditCtrl',
718 ['$scope','$location','$routeParams',
719 function($scope , $location , $routeParams) {
720 $scope.batchedit_url = $location.absUrl().replace(/\/eg.*/, '/opac/extras/merge_template');
721 if ($routeParams.container_type) {
722 switch ($routeParams.container_type) {
724 $scope.batchedit_url += '?recordSource=b&containerid=' + $routeParams.container_id;
727 $scope.batchedit_url += '?recordSource=r&recid=' + $routeParams.container_id;
734 .filter('boolText', function(){
735 return function (v) {
740 .factory('holdingsSvc',
742 function(egCore , $q) {
746 copies : [], // record search results
747 index : 0, // search grid index
755 acp : ['status','location'],
756 acn : ['prefix','suffix','copies']
760 // resolved with the last received copy
761 service.fetch = function(opts) {
762 if (service.ongoing) {
763 console.log('Skipping fetch, ongoing = true');
769 var copy = opts.copy;
771 var empty = opts.empty;
773 if (!rid) return $q.when();
774 if (!org) return $q.when();
776 service.ongoing = true;
783 var org_list = egCore.org.descendants(org.id(), true);
784 console.log('Holdings fetch with: rid='+rid+' org='+org_list+' copy='+copy+' vol='+vol+' empty='+empty);
786 return egCore.pcrud.search(
788 {record : rid, owning_lib : org_list, deleted : 'f'},
791 function() { // finished
792 service.copies = service.copies.sort(
794 function compare_array (x, y, i) {
795 if (x[i] && y[i]) { // both have values
796 if (x[i] == y[i]) { // need to look deeper
797 return compare_array(x, y, ++i);
800 if (x[i] < y[i]) { // x is first
802 } else if (x[i] > y[i]) { // y is first
806 } else { // no orgs to compare ...
813 var owner_order = compare_array(a.owner_list, b.owner_list, 0);
815 // now compare on CN label
816 if (a.call_number.label < b.call_number.label) return -1;
817 if (a.call_number.label > b.call_number.label) return 1;
820 if (a.copy_number < b.copy_number) return -1;
821 if (a.copy_number > b.copy_number) return 1;
824 if (a.barcode < b.barcode) return -1;
825 if (a.barcode > b.barcode) return 1;
831 // create a label using just the unique part of the owner list
834 angular.forEach(service.copies, function (cp) {
835 if (!prev_owner_list) {
836 cp.owner_label = cp.owner_list.join(' ... ');
838 var current_owner_list = cp.owner_list.slice();
839 while (current_owner_list[1] && prev_owner_list[1] && current_owner_list[0] == prev_owner_list[0]) {
840 current_owner_list.shift();
841 prev_owner_list.shift();
843 cp.owner_label = current_owner_list.join(' ... ');
847 prev_owner_list = cp.owner_list.slice();
850 var new_list = service.copies;
851 if (!copy || !vol) { // collapse copy rows, supply a count instead
856 var current_blob = {};
857 angular.forEach(new_list, function (cp) {
859 prev_key = cp.owner_list.join('') + cp.call_number.label;
860 if (cp.barcode) current_blob.copy_count = 1;
861 current_blob.index = index++;
862 current_blob.id_list = cp.id_list;
863 current_blob.raw = cp.raw;
864 current_blob.call_number = cp.call_number;
865 current_blob.owner_list = cp.owner_list;
866 current_blob.owner_label = cp.owner_label;
868 var current_key = cp.owner_list.join('') + cp.call_number.label;
869 if (prev_key == current_key) { // collapse into current_blob
870 current_blob.copy_count++;
871 current_blob.id_list = current_blob.id_list.concat(cp.id_list);
872 current_blob.raw = current_blob.raw.concat(cp.raw);
874 current_blob.barcode = current_blob.copy_count;
875 cp_list.push(current_blob);
876 prev_key = current_key;
878 if (cp.barcode) current_blob.copy_count = 1;
879 current_blob.index = index++;
880 current_blob.id_list = cp.id_list;
881 current_blob.raw = cp.raw;
882 current_blob.owner_label = cp.owner_label;
883 current_blob.call_number = cp.call_number;
884 current_blob.owner_list = cp.owner_list;
889 current_blob.barcode = current_blob.copy_count;
890 cp_list.push(current_blob);
893 if (!vol) { // do the same for vol rows
898 var current_blob = {};
899 angular.forEach(cp_list, function (cp) {
901 prev_key = cp.owner_list.join('');
902 current_blob.index = index++;
903 current_blob.id_list = cp.id_list;
904 current_blob.raw = cp.raw;
905 current_blob.cn_count = 1;
906 current_blob.copy_count = cp.copy_count;
907 current_blob.owner_list = cp.owner_list;
908 current_blob.owner_label = cp.owner_label;
910 var current_key = cp.owner_list.join('');
911 if (prev_key == current_key) { // collapse into current_blob
912 current_blob.cn_count++;
913 current_blob.copy_count += cp.copy_count;
914 current_blob.id_list = current_blob.id_list.concat(cp.id_list);
915 current_blob.raw = current_blob.raw.concat(cp.raw);
917 current_blob.barcode = current_blob.copy_count;
918 current_blob.call_number = { label : current_blob.cn_count };
919 cn_list.push(current_blob);
920 prev_key = current_key;
922 current_blob.index = index++;
923 current_blob.id_list = cp.id_list;
924 current_blob.raw = cp.raw;
925 current_blob.owner_label = cp.owner_label;
926 current_blob.cn_count = 1;
927 current_blob.copy_count = cp.copy_count;
928 current_blob.owner_list = cp.owner_list;
933 current_blob.barcode = current_blob.copy_count;
934 current_blob.call_number = { label : current_blob.cn_count };
935 cn_list.push(current_blob);
941 service.copies = new_list;
942 service.ongoing = false;
947 // notify reads the stream of copies, one at a time.
950 var copies = cn.copies();
953 angular.forEach(copies, function (cp) {
957 var owner_id = cn.owning_lib();
958 var owner = egCore.org.get(owner_id);
960 var owner_name_list = [];
961 while (owner.parent_ou()) { // we're going to skip the top of the tree...
962 owner_name_list.unshift(owner.name());
963 owner = egCore.org.get(owner.parent_ou());
968 angular.forEach(copies, function (cp) {
969 var flat_cp = egCore.idl.toHash(cp);
970 flat_cp.owner_id = owner_id;
971 flat_cp.owner_list = owner_name_list;
972 flat_cp.id_list = [flat_cp.id];
977 service.copies = service.copies.concat(flat);
979 service.copies.push({
981 owner_list : owner_name_list,
982 call_number: egCore.idl.toHash(cn)