1 import {Component, OnInit, Input} from '@angular/core';
2 import {Router} from '@angular/router';
3 import {StoreService} from '@eg/core/store.service';
4 import {CatalogService} from '@eg/share/catalog/catalog.service';
5 import {CatalogSearchContext} from '@eg/share/catalog/search-context';
6 import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service';
7 import {StaffCatalogService} from '../catalog.service';
8 import {StringService} from '@eg/share/string/string.service';
9 import {ToastService} from '@eg/share/toast/toast.service';
10 import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
13 selector: 'eg-catalog-record-actions',
14 templateUrl: 'actions.component.html'
16 export class RecordActionsComponent implements OnInit {
20 searchContext: CatalogSearchContext;
24 key: 'eg.cat.marked_conjoined_record',
28 key: 'eg.cat.marked_overlay_record',
32 key: 'eg.circ.hold.title_transfer_target',
36 key: 'eg.cat.transfer_target_record',
38 clear: [ // Clear these values on mark.
39 'eg.cat.transfer_target_lib',
40 'eg.cat.transfer_target_vol'
45 @Input() set recordId(recId: number) {
48 // Fire any record specific actions here
53 private router: Router,
54 private store: StoreService,
55 private strings: StringService,
56 private toast: ToastService,
57 private cat: CatalogService,
58 private catUrl: CatalogUrlService,
59 private staffCat: StaffCatalogService,
60 private holdings: HoldingsService
66 Object.keys(this.targets).forEach(name => {
67 const target = this.targets[name];
68 target.current = this.store.getLocalItem(target.key);
73 const target = this.targets[name];
74 target.current = this.recId;
75 this.store.setLocalItem(target.key, this.recId);
78 // Some marks require clearing other marks.
79 target.clear.forEach(key => this.store.removeLocalItem(key));
82 this.strings.interpolate('catalog.record.toast.' + name)
83 .then(txt => this.toast.success(txt));
87 Object.keys(this.targets).forEach(name => {
88 const target = this.targets[name];
89 target.current = null;
90 this.store.removeLocalItem(target.key);
92 this.strings.interpolate('catalog.record.toast.cleared')
93 .then(txt => this.toast.success(txt));
96 // TODO: Support adding copies to existing call numbers by getting
97 // selected call numbers from the holdings grid.
98 // TODO: Support adding like call numbers by getting selected
99 // call numbers from the holdings grid.
101 this.holdings.spawnAddHoldingsUi(this.recId);