2 * Common code for mananging holdings
4 import {Injectable, EventEmitter} from '@angular/core';
5 import {NetService} from '@eg/core/net.service';
6 import {AnonCacheService} from '@eg/share/util/anon-cache.service';
7 import {AuthService} from '@eg/core/auth.service';
8 import {EventService} from '@eg/core/event.service';
10 interface NewVolumeData {
16 export class HoldingsService {
19 private net: NetService,
20 private auth: AuthService,
21 private evt: EventService,
22 private anonCache: AnonCacheService
25 // Open the holdings editor UI in a new browser window/tab.
27 recordId: number, // Bib record ID
28 addToVols: number[] = [], // Add copies to existing volumes
29 volumeData: NewVolumeData[] = []) { // Creating new volumes
31 const raw: any[] = [];
34 addToVols.forEach(volId => raw.push({callnumber: volId}));
35 } else if (volumeData) {
36 volumeData.forEach(data => raw.push(data));
39 if (raw.length === 0) { raw.push({}); }
41 this.anonCache.setItem(null, 'edit-these-copies', {
48 console.error('Could not create holds cache key!');
52 const url = `/eg/staff/cat/volcopy/${key}`;
53 window.open(url, '_blank');