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:56:04 +0000 (09:56 -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 2e3e2ad..7f0905e 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;
@@ -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();
     }
-
 }
 
 
index f96bb3a..cb39360 100644 (file)
@@ -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;
index db13bb0..5079956 100644 (file)
@@ -15,7 +15,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>
@@ -69,7 +70,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 e397444..b9e6dca 100644 (file)
@@ -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()}]);
+        }
+    }
 }