From fc78a9f3bb869e74c970b5814bd0dd20874ba9e2 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 22 Jun 2018 17:44:47 -0400 Subject: [PATCH] LP#1775466 Initial catalog add-volumes support Signed-off-by: Bill Erickson --- .../eg2/src/app/staff/catalog/catalog.module.ts | 4 +- .../staff/catalog/record/actions.component.html | 4 ++ .../app/staff/catalog/record/actions.component.ts | 11 +++++ .../eg2/src/app/staff/share/holdings.service.ts | 57 ++++++++++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 26f0db3ac8..6f65fedd77 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -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 ] }) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html index 53b7342fa6..6fd945414c 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html @@ -15,6 +15,10 @@
+ +
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 d888b636db..b6ab6ce061 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 @@ -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 index 0000000000..333027a414 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts @@ -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'); + }); + } + ); + } + +} + -- 2.11.0