LP1878079 Staffcat Add Holdings action support
authorBill Erickson <berickxx@gmail.com>
Mon, 27 Jul 2020 14:58:52 +0000 (10:58 -0400)
committerJane Sandberg <sandbej@linnbenton.edu>
Mon, 27 Jul 2020 16:33:23 +0000 (09:33 -0700)
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 <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts

index 52e89be..bb4eca1 100644 (file)
@@ -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<void>
+        = new EventEmitter<void>();
+
     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();
     }
-
 }
 
 
index 46347e4..7a064a5 100644 (file)
@@ -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;
index a9330c3..0630d3b 100644 (file)
@@ -22,7 +22,8 @@
     <!-- 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>
@@ -73,7 +74,7 @@
       </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>
index b900ea8..e68e017 100644 (file)
@@ -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()}]);
+        }
+    }
 }