From 24eb0d5c81192abe4ce6d4572e7b588876738e96 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 9 Jun 2020 13:33:36 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../app/staff/cat/volcopy/vol-edit.component.html | 48 ++++++++++++-------- .../app/staff/cat/volcopy/vol-edit.component.ts | 51 ++++++++++++++++++++-- 2 files changed, 78 insertions(+), 21 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html index 30d7e7857e..a606b5d76f 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/volcopy/vol-edit.component.html @@ -4,12 +4,16 @@ dialogTitle="Delete Call Number?" dialogBody="Delete {{deleteVolCount}} Call Number(s) and {{deleteCopyCount}} Associated Item(s)?"> + +
-
-
-
-
+
+
@@ -192,20 +196,28 @@
- -
- Duplicate Barcode
+ +
+ + + +
+ Duplicate Barcode
+
{ + nodes.forEach(volNode => { if (volNode.children.length == 0) { const vol = volNode.target; const copy = this.createStubCopy(vol); @@ -426,6 +430,47 @@ export class VolEditComponent implements OnInit { } } + deleteCopy(copyNode: HoldingsTreeNode) { + this.deleteCopyCount = 1; + this.confirmDelCopy.open().toPromise().then(confirmed => { + if (confirmed) { this.deleteOneCopy(copyNode); } + }); + } + + deleteOneCopy(copyNode: HoldingsTreeNode) { + + const targetCopy = copyNode.target; + + const orgNodes = this.context.orgNodes(); + for (let orgIdx = 0; orgIdx < orgNodes.length; orgIdx++) { + const orgNode = orgNodes[orgIdx]; + + for (let volIdx = 0; volIdx < orgNode.children.length; volIdx++) { + const volNode = orgNode.children[volIdx]; + + for (let copyIdx = 0; copyIdx < volNode.children.length; copyIdx++) { + const copy = volNode.children[copyIdx].target; + + if (copy.id() === targetCopy.id()) { + volNode.children.splice(copyIdx, 1); + if (!copy.isnew()) { + copy.isdeleted(true); + this.copiesToDelete.push(copy); + } + + if (volNode.children.length === 0) { + // When removing the last copy, add a stub copy. + this.addStubCopies(); + } + + return; + } + } + } + } + } + + deleteVol(volNode: HoldingsTreeNode) { this.deleteVolCount = 1; this.deleteCopyCount = volNode.children.length; @@ -473,7 +518,7 @@ export class VolEditComponent implements OnInit { }); } - if (deleteVolIdx) { break; } + if (deleteVolIdx !== null) { break; } } if (deleteVolIdx !== null) { -- 2.11.0