1 import {Component, OnInit, Input, Output, EventEmitter} 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 {
18 @Output() addHoldingsRequested: EventEmitter<void>
19 = new EventEmitter<void>();
23 searchContext: CatalogSearchContext;
27 key: 'eg.cat.marked_conjoined_record',
31 key: 'eg.cat.marked_overlay_record',
35 key: 'eg.circ.hold.title_transfer_target',
39 key: 'eg.cat.transfer_target_record',
41 clear: [ // Clear these values on mark.
42 'eg.cat.transfer_target_lib',
43 'eg.cat.transfer_target_vol'
48 @Input() set recordId(recId: number) {
51 // Fire any record specific actions here
56 private router: Router,
57 private store: StoreService,
58 private strings: StringService,
59 private toast: ToastService,
60 private cat: CatalogService,
61 private catUrl: CatalogUrlService,
62 private staffCat: StaffCatalogService,
63 private holdings: HoldingsService
69 Object.keys(this.targets).forEach(name => {
70 const target = this.targets[name];
71 target.current = this.store.getLocalItem(target.key);
76 const target = this.targets[name];
77 target.current = this.recId;
78 this.store.setLocalItem(target.key, this.recId);
81 // Some marks require clearing other marks.
82 target.clear.forEach(key => this.store.removeLocalItem(key));
85 this.strings.interpolate('catalog.record.toast.' + name)
86 .then(txt => this.toast.success(txt));
90 Object.keys(this.targets).forEach(name => {
91 const target = this.targets[name];
92 target.current = null;
93 this.store.removeLocalItem(target.key);
95 this.strings.interpolate('catalog.record.toast.cleared')
96 .then(txt => this.toast.success(txt));
100 this.addHoldingsRequested.emit();