From 1528c22bce523fc79cbdfd2244938db9977d5e57 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 27 Jul 2020 10:58:52 -0400 Subject: [PATCH] LP1878079 Staffcat Add Holdings action support Teaches the staff catalog Add Holdings button to open the holdings editor using the appropriate parameters. If the holdings maintenance grid is active, arguments to pass are based on the grid selection. Otherwise it simply open the item editor with a single call number / copy to be created 'here'. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../app/staff/catalog/record/actions.component.ts | 12 ++++------ .../app/staff/catalog/record/holdings.component.ts | 4 ++-- .../app/staff/catalog/record/record.component.html | 5 ++-- .../app/staff/catalog/record/record.component.ts | 28 ++++++++++++++++++++++ 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts index 52e89bee6b..bb4eca1ce7 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts @@ -1,4 +1,4 @@ -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'; @@ -15,6 +15,9 @@ import {HoldingsService} from '@eg/staff/share/holdings/holdings.service'; }) export class RecordActionsComponent implements OnInit { + @Output() addHoldingsRequested: EventEmitter + = new EventEmitter(); + recId: number; initDone = false; searchContext: CatalogSearchContext; @@ -93,14 +96,9 @@ export class RecordActionsComponent implements OnInit { .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(); } - } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts index 46347e4915..7a064a5468 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts @@ -42,7 +42,7 @@ import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; // The holdings grid models a single HoldingsTree, composed of HoldingsTreeNodes // flattened on-demand into a list of HoldingEntry objects. -class HoldingsTreeNode { +export class HoldingsTreeNode { children: HoldingsTreeNode[]; nodeType: 'org' | 'callNum' | 'copy'; target: any; @@ -62,7 +62,7 @@ class HoldingsTree { } } -class HoldingsEntry { +export class HoldingsEntry { index: number; // org unit shortname, call number label, or copy barcode locationLabel: string; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html index a9330c3c2b..0630d3b6d8 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html @@ -22,7 +22,8 @@
- +
@@ -73,7 +74,7 @@ - + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts index b900ea8734..e68e01791d 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts @@ -3,6 +3,7 @@ import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; 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'; @@ -11,6 +12,8 @@ import {BibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.compo 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', @@ -24,6 +27,10 @@ export class RecordComponent implements OnInit { 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}) @@ -33,9 +40,11 @@ export class RecordComponent implements OnInit { 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 ) {} @@ -179,6 +188,25 @@ export class RecordComponent implements OnInit { 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()}]); + } + } } -- 2.11.0