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 / modify existing vols
29 volumeData?: NewVolumeData[], // Creating new volumes
30 hideCopies?: boolean) { // Hide the copy edit pane
32 const raw: any[] = [];
35 addToVols.forEach(volId => raw.push({callnumber: volId}));
36 } else if (volumeData) {
37 volumeData.forEach(data => raw.push(data));
40 if (raw.length === 0) { raw.push({}); }
42 this.anonCache.setItem(null, 'edit-these-copies', {
46 hide_copies : hideCopies ? true : false
49 console.error('Could not create holds cache key!');
53 const url = `/eg/staff/cat/volcopy/${key}`;
54 window.open(url, '_blank');