From 4231540b8ffbb2858ff557e1c596f6d1727594fb Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 11 May 2020 15:10:37 -0400 Subject: [PATCH] LP1878079 Staffcat Add Call Nums honors selected orgs When adding new call numbers from the Angular staff catalog Holdings View grid, take all selected grid rows into consideration when determining how many call numbers to add and what their owning libs should be. To test: * Navigate to the Holdings View tab of a record detail page in the Angular staff catalog. * Select multiple rows in the grid which are org unit-only rows (i.e. the row does not refer to a specific call number or item). * From the action menu / right client menu, select "Add Callnumbers" * Confirm that a call number entry for each selected org unit is present in the spawned holdings editor. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../catalog/record/holdings.component.ts | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts index bec07303be..0c529af341 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts @@ -749,14 +749,20 @@ export class HoldingsMaintenanceComponent implements OnInit { openHoldingEdit(rows: HoldingsEntry[], addCallNums: boolean, addCopies: boolean) { - // The user may select a set of call numbers by selecting call number and/or - // copy rows. + // The user may select a set of call numbers by selecting call + // number and/or item rows. Owning libs for new call numbers may + // also come from org unit row selection. + const orgs = {}; const callNums = []; rows.forEach(r => { if (r.treeNode.nodeType === 'callNum') { callNums.push(r.callNum); + } else if (r.treeNode.nodeType === 'copy') { callNums.push(r.treeNode.parentNode.target); + + } else if (r.treeNode.nodeType === 'org') { + orgs[r.treeNode.target.id()] = true; } }); @@ -770,16 +776,15 @@ export class HoldingsMaintenanceComponent implements OnInit { } else if (addCallNums) { const entries = []; - if (callNums.length > 0) { + // Use selected call numbers as basis for new call numbers. + callNums.forEach(v => + entries.push({label: v.label(), owner: v.owning_lib()})); - // When adding call numbers, if any are selected in the grid, - // create call numbers that have the same label and owner. - callNums.forEach(v => - entries.push({label: v.label(), owner: v.owning_lib()})); - - } else { + // Use selected org units as owning libs for new call numbers + Object.keys(orgs).forEach(id => entries.push({owner: id})); - // Otherwise create new call numbers from scratch. + if (entries.length === 0) { + // Otherwise create new call numbers for "here" entries.push({owner: this.auth.user().ws_ou()}); } -- 2.43.2