LP1929741 Combobox additional sanity checks on async/IDL values
authorBill Erickson <berickxx@gmail.com>
Wed, 20 Jan 2021 20:47:03 +0000 (15:47 -0500)
committerBill Erickson <berickxx@gmail.com>
Tue, 13 Jul 2021 20:46:13 +0000 (16:46 -0400)
1. Avoid PCRUD queries where the selected id value is set to null.
2. Avoid attempts to add null entries to the async entry cache.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts

index 0fbb7d0..7ddd3ed 100644 (file)
@@ -108,7 +108,10 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
         if (id === undefined) { return; }
 
         // clear on explicit null
-        if (id === null) { this.selected = null; }
+        if (id === null) {
+            this.selected = null;
+            return;
+        }
 
         if (this.entrylist.length) {
             this.selected = this.entrylist.filter(e => e.id === id)[0];
@@ -406,6 +409,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit, AfterVie
     }
 
     addAsyncEntry(entry: ComboboxEntry) {
+        if (!entry) { return; }
         // Avoid duplicate async entries
         if (!this.asyncIds['' + entry.id]) {
             this.asyncIds['' + entry.id] = true;