From: Bill Erickson Date: Wed, 13 May 2020 16:17:19 +0000 (-0400) Subject: LP1878079 Staffcat 'Edit' items / call numbers support X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=caa1460d9575e8f2460f4e983e056cc830205ae5;p=working%2FEvergreen.git LP1878079 Staffcat 'Edit' items / call numbers support Adds support to the Angular staff catalog to properly handle requests to Edit Items, Edit Call Numbers, and Edit Call Numbers and Items. Prior to his change, these operations would behave more like Add operations than Edit operations. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html index 3d6c4d44ce..86f35cb9e2 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html @@ -102,17 +102,17 @@ + (onClick)="openHoldingAdd($event, true, false)"> + (onClick)="openHoldingAdd($event, false, true)"> + (onClick)="openHoldingAdd($event, true, true)"> + (onClick)="openHoldingEdit($event, false, true)"> + (onClick)="openHoldingEdit($event, false, false)"> + (onClick)="openHoldingEdit($event, true, false)"> 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) { @@ -747,7 +753,32 @@ export class HoldingsMaintenanceComponent implements OnInit { .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 @@ -762,7 +793,10 @@ export class HoldingsMaintenanceComponent implements OnInit { 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; + } } }); @@ -789,7 +823,7 @@ export class HoldingsMaintenanceComponent implements OnInit { } this.holdings.spawnAddHoldingsUi( - this.recordId, null, entries, !addCopies); + this.recordId, null, entries, null, !addCopies); } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts index 5c91a68474..f61d3d4192 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.service.ts @@ -26,26 +26,28 @@ export class HoldingsService { // 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!');