From b5ce8beb5d800b4184c59b718fc031de96633acc Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 5 Jun 2020 16:54:23 -0400 Subject: [PATCH] LPXXX Angular Volcopy Signed-off-by: Bill Erickson --- .../app/staff/cat/volcopy/vol-edit.component.html | 47 ++++++++----- .../app/staff/cat/volcopy/vol-edit.component.ts | 80 ++++++++++++++++++++++ 2 files changed, 110 insertions(+), 17 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 42fd35465c..a5f42a555e 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 @@ -8,7 +8,7 @@
- @@ -18,7 +18,7 @@
- @@ -37,7 +37,7 @@
- @@ -46,7 +46,7 @@
-
-
-
-
+
+ +
+ + +
+
@@ -117,12 +125,12 @@
- - @@ -130,12 +138,12 @@
- - @@ -152,12 +160,12 @@
- - @@ -176,10 +184,15 @@ id="barcode-input-{{copyNode.target.id()}}" spellcheck="false" [required]="true" + [ngClass]="{'text-danger': copyNode.target._dupe_barcode}" + (ngModelChange)="barcodeChanged(copyNode.target, $event)" (keyup.enter)="selectNextBarcode(copyNode.target.id())" (keyup.shift.enter)="selectNextBarcode(copyNode.target.id(), true)" [ngModel]="copyNode.target.barcode()" (ngModelChange)="applyCopyValue(copyNode.target, 'barcode', $event)"/> +
+ Duplicate Barcode
N/A - { + // During autogen we do not replace the first item, + // so it's status is not relevant. + return idx === 0 || this.barcodeCanChange(copy); + }); + + if (copies.length > 1) { // seed barcode will always be present + this.proceedWithAutogen(copies) + .then(_ => this.autoBarcodeInProgress = false); + }; + } + + proceedWithAutogen(copyList: IdlObject[]): Promise { + + const seedBarcode: string = copyList[0].barcode(); + copyList.shift(); // Avoid replacing the seed barcode + + const count = copyList.length; + + return this.net.request('open-ils.cat', + 'open-ils.cat.item.barcode.autogen', + this.auth.token(), seedBarcode, count, { + checkdigit: this.useCheckdigit, + skip_dupes: true + } + ).pipe(tap(barcodes => { + + copyList.forEach(copy => { + if (copy.barcode() !== barcodes[0]) { + copy.barcode(barcodes[0]); + copy.ischanged(true); + } + barcodes.shift(); + }); + + })).toPromise(); + } + + barcodeChanged(copy: IdlObject, barcode: string) { + copy.barcode(barcode); + copy.ischanged(true); + copy._dupe_barcode = false; + + if (barcode && !this.autoBarcodeInProgress) { + // Manual barcode entry requires dupe check + + copy._dupe_barcode = false; + this.pcrud.search('acp', { + deleted: 'f', + barcode: barcode, + id: {'!=': copy.id()} + }).subscribe(resp => { + if (resp) { copy._dupe_barcode = true; } + }); + } } } -- 2.11.0