LP#1775466 Initial catalog add-volumes support
authorBill Erickson <berickxx@gmail.com>
Fri, 22 Jun 2018 21:44:47 +0000 (17:44 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 5 Sep 2018 14:05:23 +0000 (10:05 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts
Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts [new file with mode: 0644]

index 26f0db3..6f65fed 100644 (file)
@@ -19,6 +19,7 @@ import {RecordPaginationComponent} from './record/pagination.component';
 import {RecordActionsComponent} from './record/actions.component';
 import {MarcViewComponent} from './record/marc-view.component';
 import {RecordBucketDialogComponent} from '@eg/staff/share/buckets/record-bucket-dialog.component';
+import {HoldingsService} from '@eg/staff/share/holdings.service';
 
 @NgModule({
   declarations: [
@@ -45,7 +46,8 @@ import {RecordBucketDialogComponent} from '@eg/staff/share/buckets/record-bucket
     UnapiService,
     CatalogService,
     CatalogUrlService,
-    StaffCatalogService
+    StaffCatalogService,
+    HoldingsService
   ]
 })
 
index 53b7342..6fd9454 100644 (file)
 
 <div class="row ml-0 mr-0">
 
+  <button class="btn btn-info ml-1" (click)="addVolumes()" i18n>
+    Add Volumes
+  </button>
+
   <div ngbDropdown placement="bottom-right" class="ml-1">
     <button class="btn btn-info" id="actionsForDd" 
       ngbDropdownToggle i18n>Mark For...</button>
index d888b63..b6ab6ce 100644 (file)
@@ -7,6 +7,7 @@ import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service';
 import {StaffCatalogService} from '../catalog.service';
 import {StringService} from '@eg/share/string/string.service';
 import {ToastService} from '@eg/share/toast/toast.service';
+import {HoldingsService} from '@eg/staff/share/holdings.service';
 
 @Component({
   selector: 'eg-catalog-record-actions',
@@ -52,6 +53,7 @@ export class RecordActionsComponent implements OnInit {
         private cat: CatalogService,
         private catUrl: CatalogUrlService,
         private staffCat: StaffCatalogService,
+        private holdings: HoldingsService
     ) {}
 
     ngOnInit() {
@@ -80,6 +82,15 @@ export class RecordActionsComponent implements OnInit {
         this.strings.interpolate('catalog.record.toast.cleared')
             .then(txt => this.toast.success(txt));
     }
+
+    // TODO: Support adding copies to existing volumes by getting
+    // selected volumes from the holdings grid.
+    // TODO: Support adding like volumes by getting selected
+    // volumes from the holdings grid.
+    addVolumes() {
+        this.holdings.spawnAddHoldingsUi(this.recId);
+    }
+
 }
 
 
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts
new file mode 100644 (file)
index 0000000..333027a
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Common code for mananging holdings
+ */
+import {Injectable, EventEmitter} from '@angular/core';
+import {NetService} from '@eg/core/net.service';
+
+interface NewVolumeData {
+    owner: number,
+    label?: string
+}
+
+@Injectable()
+export class HoldingsService {
+
+    constructor(private net: NetService) {}
+
+    // Open the holdings editor UI in a new browser window/tab.
+    spawnAddHoldingsUi(
+        recordId: number,                   // Bib record ID
+        addToVols: number[] = [],           // Add copies to existing volumes
+        volumeData: NewVolumeData[] = []) { // Creating new volumes
+
+        const raw: any[] = [];
+
+        if (addToVols) {
+            addToVols.forEach(volId => raw.push({callnumber: volId}));
+        } else if (volumeData) {
+            volumeData.forEach(data => raw.push(data));
+        }
+
+        if (raw.length === 0) { raw.push({}); }
+
+        this.net.request(
+            'open-ils.actor',
+            'open-ils.actor.anon_cache.set_value',
+            null, 'edit-these-copies', {
+                record_id: recordId,
+                raw: raw,
+                hide_vols : false,
+                hide_copies : false
+            }
+        ).subscribe(
+            key => {
+                if (!key) {
+                    console.error('Could not create holds cache key!');
+                    return;
+                }
+                setTimeout(() => {
+                    const url = `/eg/staff/cat/volcopy/${key}`;
+                    window.open(url, '_blank');
+                });
+            }
+        );
+    }
+
+}
+