From: Jane Sandberg <sandbej@linnbenton.edu>
Date: Fri, 26 Jul 2019 18:28:13 +0000 (-0700)
Subject: LP1831390: Don't clobber startId of combobox with null values
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=cfada67d541f660b6d7f6430e74eceb9772bb944;p=evergreen%2Fjoelewis.git

LP1831390: Don't clobber startId of combobox with null values

Also ensures that writeValue accepts only ComboboxEntry values,
so [(ngModel)] both gives and receives ComboboxEntry values, rather
than a confusing mix.

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
---

diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts
index 2139e5b69e..0696a989fb 100644
--- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts
+++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.ts
@@ -303,9 +303,10 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
         );
     }
 
-    writeValue(value: any) {
-        if (value !== undefined) {
-            this.startId = value;
+    writeValue(value: ComboboxEntry) {
+        if (value !== undefined && value !== null) {
+            this.startId = value.id;
+            this.applySelection();
         }
     }
 
diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html
index cc778ce230..0bba0e517e 100644
--- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html
+++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html
@@ -242,7 +242,7 @@
         </eg-org-family-select>
         The best libraries are: {{bestOnes.value | json}}
         <hr>
-        <eg-combobox ngModel #templateEntry="ngModel" [allowFreeText]="true">
+        <eg-combobox [(ngModel)]="kingdom" [allowFreeText]="true">
           <eg-combobox-entry entryId="Bacteria"></eg-combobox-entry>
           <eg-combobox-entry entryId="Archaea"></eg-combobox-entry>
           <eg-combobox-entry entryId="Protozoa"></eg-combobox-entry>
@@ -251,7 +251,7 @@
           <eg-combobox-entry entryId="Fungi"></eg-combobox-entry>
           <eg-combobox-entry entryId="Animalia"></eg-combobox-entry>
         </eg-combobox>
-      Result: {{templateEntry.value | json}}
+      Result: {{kingdom | json}}
         <hr>
         <eg-date-select [(ngModel)]="dateObject">
         </eg-date-select>
diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts
index d5b37bf8e2..db4d58fe47 100644
--- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts
+++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts
@@ -86,6 +86,7 @@ export class SandboxComponent implements OnInit {
     dateObject: Date = new Date();
 
     simpleCombo: ComboboxEntry;
+    kingdom: ComboboxEntry;
 
     complimentEvergreen: (rows: IdlObject[]) => void;
     notOneSelectedRow: (rows: IdlObject[]) => boolean;
@@ -144,6 +145,8 @@ export class SandboxComponent implements OnInit {
             this.toast.success('You chose: ' + l.label);
         });
 
+        this.kingdom = {id: 'Bacteria', label: 'Bacteria'};
+
         this.gridDataSource.data = [
             {name: 'Jane', state: 'AZ'},
             {name: 'Al', state: 'CA'},