From: Bill Erickson Date: Fri, 12 Jun 2020 14:01:41 +0000 (-0400) Subject: LPXXX Angular Volcopy X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=be785c55f79288edd3907163a86e42469b2e738e;p=working%2FEvergreen.git LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts index 4566fc2ffd..16a586221e 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.ts @@ -46,8 +46,6 @@ export class VolEditComponent implements OnInit { autoId = -1; - volsToDelete: IdlObject[] = []; - copiesToDelete: IdlObject[] = []; deleteVolCount: number = null; deleteCopyCount: number = null; @@ -68,8 +66,6 @@ export class VolEditComponent implements OnInit { ngOnInit() { - this.volsToDelete = []; - this.copiesToDelete = []; this.deleteVolCount = null; this.deleteCopyCount = null; @@ -461,7 +457,7 @@ export class VolEditComponent implements OnInit { volNode.children.splice(copyIdx, 1); if (!copy.isnew()) { copy.isdeleted(true); - this.copiesToDelete.push(copy); + this.context.copiesToDelete.push(copy); } if (volNode.children.length === 0) { @@ -518,7 +514,7 @@ export class VolEditComponent implements OnInit { // Mark volume and attached copies as deleted // and track for later deletion. targetVol.isdeleted(true); - this.volsToDelete.push(targetVol); + this.context.volsToDelete.push(targetVol); volNode.children.forEach(copyNode => { const copy = copyNode.target; @@ -526,7 +522,7 @@ export class VolEditComponent implements OnInit { // New copies can simply be discarded. } else { copy.isdeleted(true); - this.copiesToDelete.push(copy); + this.context.copiesToDelete.push(copy); } }); } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts index 6502392fd6..50a1df176c 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.component.ts @@ -152,6 +152,12 @@ export class VolCopyComponent implements OnInit { volNode.children.forEach(copyNode => { const copy = copyNode.target; + if (copy.isnew() && !copy.barcode()) { + // A new copy w/ no barcode is a stub copy sitting + // on an empty call number. Ignore it. + return; + } + if (copy.ischanged() || copy.isnew() || copy.isdeleted()) { const copyClone = this.idl.clone(copy); // De-flesh call number @@ -167,10 +173,35 @@ export class VolCopyComponent implements OnInit { } }); - // TODO: deletedVols and deletedCopies + this.context.volsToDelete.forEach(vol => { + const cloneVol = this.idl.clone(vol); + // If a deleted volume also has deleted copies, they will + // be appended below. + cloneVol.copies([]); + volumes.push(cloneVol); + }); + + this.context.copiesToDelete.forEach(copy => { + const cloneCopy = this.idl.clone(copy); + const copyVol = cloneCopy.call_number(); + cloneCopy.call_number(copyVol.id()); // de-flesh + + let vol = volumes.filter(v => v.id() === copyVol.id())[0]; + + if (vol) { + vol.copies().push(cloneCopy); + } else { + vol = this.idl.clone(copyVol); + vol.copies([cloneCopy]); + } + + volumes.push(vol); + }) if (volumes.length > 0) { this.saveApi(volumes); + } else { + this.loading = false; } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts index 716fac7be4..891824447e 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/volcopy.ts @@ -24,8 +24,13 @@ export class VolCopyContext { holdings: HoldingsTree = new HoldingsTree(); org: OrgService; // injected + volsToDelete: IdlObject[] = []; + copiesToDelete: IdlObject[] = []; + reset() { this.holdings = new HoldingsTree(); + this.volsToDelete = []; + this.copiesToDelete = []; } orgNodes(): HoldingsTreeNode[] {