-import {Component, OnInit, Input} from '@angular/core';
+import {Component, OnInit, Input, Output, EventEmitter} from '@angular/core';
import {Router} from '@angular/router';
import {StoreService} from '@eg/core/store.service';
import {CatalogService} from '@eg/share/catalog/catalog.service';
})
export class RecordActionsComponent implements OnInit {
+ @Output() addHoldingsRequested: EventEmitter<void>
+ = new EventEmitter<void>();
+
recId: number;
initDone = false;
searchContext: CatalogSearchContext;
.then(txt => this.toast.success(txt));
}
- // TODO: Support adding copies to existing call numbers by getting
- // selected call numbers from the holdings grid.
- // TODO: Support adding like call numbers by getting selected
- // call numbers from the holdings grid.
addHoldings() {
- this.holdings.spawnAddHoldingsUi(this.recId);
+ this.addHoldingsRequested.emit();
}
-
}
<!-- push the actions component to the right -->
<div class="flex-1"></div>
<div id='staff-catalog-bib-navigation'>
- <eg-catalog-record-actions [recordId]="recordId">
+ <eg-catalog-record-actions [recordId]="recordId"
+ (addHoldingsRequested)="addHoldingsRequested()">
</eg-catalog-record-actions>
</div>
</div>
</ngb-tab>
<ngb-tab title="Holdings View" i18n-title id="holdings">
<ng-template ngbTabContent>
- <eg-holdings-maintenance [recordId]="recordId">
+ <eg-holdings-maintenance #holdingsMaint [recordId]="recordId">
</eg-holdings-maintenance>
</ng-template>
</ngb-tab>
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
import {PcrudService} from '@eg/core/pcrud.service';
import {IdlObject} from '@eg/core/idl.service';
+import {AuthService} from '@eg/core/auth.service';
import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
import {CatalogService} from '@eg/share/catalog/catalog.service';
import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service';
import {StoreService} from '@eg/core/store.service';
import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
import {MarcEditorComponent} from '@eg/staff/share/marc-edit/editor.component';
+import {HoldingsMaintenanceComponent} from './holdings.component';
+import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
@Component({
selector: 'eg-catalog-record',
searchContext: CatalogSearchContext;
@ViewChild('recordTabs', { static: true }) recordTabs: NgbTabset;
@ViewChild('marcEditor', {static: false}) marcEditor: MarcEditorComponent;
+
+ @ViewChild('holdingsMaint', {static: false})
+ holdingsMaint: HoldingsMaintenanceComponent;
+
defaultTab: string; // eg.cat.default_record_tab
@ViewChild('pendingChangesDialog', {static: false})
private router: Router,
private route: ActivatedRoute,
private pcrud: PcrudService,
+ private auth: AuthService,
private bib: BibRecordService,
private cat: CatalogService,
private staffCat: StaffCatalogService,
+ private holdings: HoldingsService,
private store: StoreService
) {}
this.staffCat.currentDetailRecordSummary = null;
this.loadRecord();
}
+
+ // Our actions component broadcast a request to add holdings.
+ // If our Holdings Maintenance component is active/visible, ask
+ // it to figure out what data to pass to the holdings editor.
+ // Otherwise, just tell it to create a new call number and
+ // copy at the current working location.
+ addHoldingsRequested() {
+ if (this.holdingsMaint && this.holdingsMaint.holdingsGrid) {
+ this.holdingsMaint.openHoldingAdd(
+ this.holdingsMaint.holdingsGrid.context.getSelectedRows(),
+ true, true
+ );
+
+ } else {
+
+ this.holdings.spawnAddHoldingsUi(
+ this.recordId, null, [{owner: this.auth.user().ws_ou()}]);
+ }
+ }
}