<eg-grid-toolbar-action
i18n-group group="Add" i18n-label label="Add Call Numbers"
- (onClick)="openHoldingEdit($event, true, false)">
+ (onClick)="openHoldingAdd($event, true, false)">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action
i18n-group group="Add" i18n-label label="Add Items"
- (onClick)="openHoldingEdit($event, false, true)">
+ (onClick)="openHoldingAdd($event, false, true)">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action
i18n-group group="Add" i18n-label label="Add Call Numbers and Items"
- (onClick)="openHoldingEdit($event, true, true)">
+ (onClick)="openHoldingAdd($event, true, true)">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action
<eg-grid-toolbar-action
i18n-group group="Edit" i18n-label label="Edit Call Numbers"
- (onClick)="openHoldingEdit($event, true, false)">
+ (onClick)="openHoldingEdit($event, false, true)">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action
i18n-group group="Edit" i18n-label label="Edit Call Numbers And Items"
- (onClick)="openHoldingEdit($event, true, true)">
+ (onClick)="openHoldingEdit($event, false, false)">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action
i18n-group group="Edit" i18n-label label="Edit Items"
- (onClick)="openHoldingEdit($event, false, true)">
+ (onClick)="openHoldingEdit($event, true, false)">
</eg-grid-toolbar-action>
<eg-grid-toolbar-action
return this.selectedCopies(rows, skipStatus).map(c => Number(c.id()));
}
+ selectedVolIds(rows: HoldingsEntry[]): number[] {
+ return rows
+ .filter(r => Boolean(r.callNum))
+ .map(r => Number(r.callNum.id()));
+ }
+
selectedCopies(rows: HoldingsEntry[], skipStatus?: number): IdlObject[] {
let copyRows = rows.filter(r => Boolean(r.copy)).map(r => r.copy);
if (skipStatus) {
.then(key => this.openAngJsWindow(`cat/printlabels/${key}`));
}
- openHoldingEdit(rows: HoldingsEntry[], addCallNums: boolean, addCopies: boolean) {
+ openHoldingEdit(rows: HoldingsEntry[], hideVols: boolean, hideCopies: boolean) {
+
+ // Avoid adding call number edit entries for call numbers
+ // that are already represented by selected items.
+
+ const copies = this.selectedCopies(rows);
+ const copyVols = copies.map(c => Number(c.call_number()));
+
+ const volIds = [];
+ this.selectedVolIds(rows).forEach(id => {
+ if (!copyVols.includes(id)) {
+ volIds.push(id);
+ }
+ });
+
+ this.holdings.spawnAddHoldingsUi(
+ this.recordId,
+ volIds,
+ null,
+ copies.map(c => Number(c.id())),
+ hideCopies,
+ hideVols
+ );
+ }
+
+ openHoldingAdd(rows: HoldingsEntry[], addCallNums: boolean, addCopies: boolean) {
// The user may select a set of call numbers by selecting call
// number and/or item rows. Owning libs for new call numbers may
callNums.push(r.treeNode.parentNode.target);
} else if (r.treeNode.nodeType === 'org') {
- orgs[r.treeNode.target.id()] = true;
+ const org = r.treeNode.target;
+ if (org.ou_type().can_have_vols() === 't') {
+ orgs[org.id()] = true;
+ }
}
});
}
this.holdings.spawnAddHoldingsUi(
- this.recordId, null, entries, !addCopies);
+ this.recordId, null, entries, null, !addCopies);
}
}
// Open the holdings editor UI in a new browser window/tab.
spawnAddHoldingsUi(
- recordId: number, // Bib record ID
- addToCallNums?: number[], // Add copies to / modify existing CNs
- callNumData?: NewCallNumData[], // Creating new call numbers
- hideCopies?: boolean) { // Hide the copy edit pane
+ recordId: number, // Bib record ID
+ editExistingCallNums?: number[], // Add copies to / modify existing CNs
+ newCallNumData?: NewCallNumData[], // Creating new call numbers
+ editCopyIds?: number[], // Edit existing items
+ hideCopies?: boolean, // Hide the copy edit pane
+ hideVols?: boolean) {
const raw: any[] = [];
- if (addToCallNums) {
- addToCallNums.forEach(callNumId => raw.push({callnumber: callNumId}));
- } else if (callNumData) {
- callNumData.forEach(data => raw.push(data));
+ if (editExistingCallNums) {
+ editExistingCallNums.forEach(
+ callNumId => raw.push({callnumber: callNumId}));
+ } else if (newCallNumData) {
+ newCallNumData.forEach(data => raw.push(data));
}
- if (raw.length === 0) { raw.push({}); }
-
this.anonCache.setItem(null, 'edit-these-copies', {
record_id: recordId,
raw: raw,
- hide_vols : false,
- hide_copies : hideCopies ? true : false
+ copies: editCopyIds,
+ hide_vols : hideVols === true,
+ hide_copies : hideCopies === true
}).then(key => {
if (!key) {
console.error('Could not create holds cache key!');