LP#1942220: (follow-up) fix handling of item count in batch LID update
authorGalen Charlton <gmc@equinoxOLI.org>
Thu, 28 Jul 2022 19:20:09 +0000 (19:20 +0000)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 28 Jul 2022 19:20:09 +0000 (19:20 +0000)
It can be omitted if the user wants to update LIDs but not change
their numbers.

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/acq/lineitem/batch-update-copies-dialog.component.ts

index fb60ffc..0ca7575 100644 (file)
@@ -17,7 +17,7 @@ export class BatchUpdateCopiesDialogComponent extends DialogComponent {
 
     @Input() ids: number[];
 
-    copyCount = 0;
+    copyCount = '';
     selectedFormula: ComboboxEntry;
     formulaFilter = {owner: []};
     templateCopy: IdlObject;
@@ -35,7 +35,7 @@ export class BatchUpdateCopiesDialogComponent extends DialogComponent {
             args = {};
         }
 
-        this.copyCount = 1;
+        this.copyCount = '';
         this.selectedFormula = null;
         this.formulaFilter.owner =
             this.org.fullPath(this.auth.user().ws_ou(), true);
@@ -46,7 +46,8 @@ export class BatchUpdateCopiesDialogComponent extends DialogComponent {
     canApply(): boolean {
         if (!this.templateCopy) { return false; }
 
-        if (this.copyCount > 0 ||
+        const _copyCount = parseInt(this.copyCount, 10);
+        if ((_copyCount && _copyCount > 0) ||
             this.selectedFormula?.id ||
             this.templateCopy.owning_lib() ||
             this.templateCopy.location() ||
@@ -61,9 +62,12 @@ export class BatchUpdateCopiesDialogComponent extends DialogComponent {
 
     compileBatchChange(): any {
         const changes = {
-            item_count: this.copyCount,
             _dist_formula: this.selectedFormula?.id
         };
+        const _copyCount = parseInt(this.copyCount, 10);
+        if (_copyCount && _copyCount > 0) {
+            changes['item_count'] = _copyCount;
+        }
         if (this.templateCopy.owning_lib()) {
             changes['owning_lib'] = this.templateCopy.owning_lib();
         }