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: [
UnapiService,
CatalogService,
CatalogUrlService,
- StaffCatalogService
+ StaffCatalogService,
+ HoldingsService
]
})
<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>
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',
private cat: CatalogService,
private catUrl: CatalogUrlService,
private staffCat: StaffCatalogService,
+ private holdings: HoldingsService
) {}
ngOnInit() {
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);
+ }
+
}
--- /dev/null
+/**
+ * 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');
+ });
+ }
+ );
+ }
+
+}
+