From 8ed4dce43fadcfe0dbbb38f8a34c3259101fb82c 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 | 30 ++++++++++++++++++++++ 4 files changed, 40 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 2e3e2ad302..7f0905efc3 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; @@ -83,14 +86,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 f96bb3adb8..cb39360ecf 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 @@ -36,7 +36,7 @@ import {MakeBookableDialogComponent // 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; @@ -56,7 +56,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 db13bb0e2f..5079956d69 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 @@ -15,7 +15,8 @@
- +
@@ -69,7 +70,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 e397444819..b9e6dcad15 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,12 +3,17 @@ 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'; import {StaffCatalogService} from '../catalog.service'; import {BibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component'; 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', @@ -21,15 +26,21 @@ export class RecordComponent implements OnInit { summary: BibRecordSummary; searchContext: CatalogSearchContext; @ViewChild('recordTabs') recordTabs: NgbTabset; + + @ViewChild('holdingsMaint') + holdingsMaint: HoldingsMaintenanceComponent; + defaultTab: string; // eg.cat.default_record_tab constructor( 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 ) {} @@ -115,6 +126,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