i18n-label label="Print Labels" (onClick)="openItemPrintLabels($event)">
</eg-grid-toolbar-action>
- <!-- row actions : Show group -->
+ <!-- row actions : Add -->
+
+ <eg-grid-toolbar-action
+ i18n-group group="Add" i18n-label label="Add Call Numbers"
+ (onClick)="openVolCopyEdit($event, true, false)">
+ </eg-grid-toolbar-action>
+
+ <eg-grid-toolbar-action
+ i18n-group group="Add" i18n-label label="Add Items"
+ (onClick)="openVolCopyEdit($event, false, true)">
+ </eg-grid-toolbar-action>
+
+ <eg-grid-toolbar-action
+ i18n-group group="Add" i18n-label label="Add Call Numbers and Items"
+ (onClick)="openVolCopyEdit($event, true, true)">
+ </eg-grid-toolbar-action>
+
+ <!-- row actions : Show -->
<eg-grid-toolbar-action
i18n-group group="Show" i18n-label label="Show Item Status (list)"
i18n-group group="Show" i18n-label label="Show Triggered Events"
(onClick)="openItemTriggeredEvents($event)"></eg-grid-toolbar-action>
- <!-- row actions : Mark group -->
+ <!-- row actions : Mark -->
<eg-grid-toolbar-action
group="Mark" i18n-group i18n-label label="Mark Item Damaged"
import {StaffCatalogService} from '../catalog.service';
import {OrgService} from '@eg/core/org.service';
import {PcrudService} from '@eg/core/pcrud.service';
+import {AuthService} from '@eg/core/auth.service';
import {GridDataSource} from '@eg/share/grid/grid';
import {GridComponent} from '@eg/share/grid/grid.component';
import {GridToolbarCheckboxComponent} from '@eg/share/grid/grid-toolbar-checkbox.component';
import {MarkMissingDialogComponent
} from '@eg/staff/share/holdings/mark-missing-dialog.component';
import {AnonCacheService} from '@eg/share/util/anon-cache.service';
+import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
// The holdings grid models a single HoldingsTree, composed of HoldingsTreeNodes
constructor(
private org: OrgService,
private pcrud: PcrudService,
+ private auth: AuthService,
private staffCat: StaffCatalogService,
private store: ServerStoreService,
private localStore: StoreService,
+ private holdings: HoldingsService,
private anonCache: AnonCacheService
) {
// Set some sane defaults before settings are loaded.
return copyRows.map(c => Number(c.id()));
}
+ selectedVolumeIds(rows: HoldingsEntry[]): number[] {
+ return rows
+ .filter(r => r.treeNode.nodeType === 'volume')
+ .map(r => Number(r.volume.id()));
+ }
+
async showMarkDamagedDialog(rows: HoldingsEntry[]) {
const copyIds = this.selectedCopyIds(rows, 14 /* ignore damaged */);
this.anonCache.setItem(null, 'print-labels-these-copies', {copies: ids})
.then(key => this.openAngJsWindow(`cat/printlabels/${key}`));
}
+
+ openVolCopyEdit(rows: HoldingsEntry[], addVols: boolean, addCopies: boolean) {
+
+ // The user may select a set of volumes by selecting volume and/or
+ // copy rows.
+ const volumes = [];
+ rows.forEach(r => {
+ if (r.treeNode.nodeType === 'volume') {
+ volumes.push(r.volume);
+ } else if (r.treeNode.nodeType === 'copy') {
+ volumes.push(r.treeNode.parentNode.target);
+ }
+ });
+
+ if (addCopies && !addVols) {
+ // Adding copies to an existing set of volumes.
+ if (volumes.length > 0) {
+ const volIds = volumes.map(v => Number(v.id()));
+ this.holdings.spawnAddHoldingsUi(this.recordId, volIds);
+ }
+
+ } else if (addVols) {
+ const entries = [];
+
+ if (volumes.length > 0) {
+
+ // When adding volumes, if any are selected in the grid,
+ // create volumes that have the same label and owner.
+ volumes.forEach(v =>
+ entries.push({label: v.label(), owner: v.owning_lib()}));
+
+ } else {
+
+ // Otherwise create new volumes from scratch.
+ entries.push({owner: this.auth.user().ws_ou()})
+ }
+
+ this.holdings.spawnAddHoldingsUi(
+ this.recordId, null, entries, !addCopies);
+ }
+ }
}
// 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
+ recordId: number, // Bib record ID
+ addToVols?: number[], // Add copies to existing volumes
+ volumeData?: NewVolumeData[], // Creating new volumes
+ hideCopies?: boolean) { // Hide the copy edit pane
const raw: any[] = [];
record_id: recordId,
raw: raw,
hide_vols : false,
- hide_copies : false
+ hide_copies : hideCopies ? true : false
}).then(key => {
if (!key) {
console.error('Could not create holds cache key!');