From: Jane Sandberg 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=refs%2Fheads%2Fuser%2Fsandbergja%2Flp1831390-ang-form-control-value-accessor-3;p=working%2FEvergreen.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 --- 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 d391244193..355bdf3cc2 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 @@ -267,9 +267,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 3f00f209f3..e2dfe1f8cf 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 @@ -192,7 +192,7 @@ The best libraries are: {{bestOnes.value | json}}
- + @@ -201,7 +201,7 @@ - Result: {{templateEntry.value | json}} + Result: {{kingdom | json}}
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 ce45df88cc..3b7b9b7369 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 @@ -68,6 +68,7 @@ export class SandboxComponent implements OnInit { dateObject: Date = new Date(); simpleCombo: ComboboxEntry; + kingdom: ComboboxEntry; complimentEvergreen: (rows: IdlObject[]) => void; notOneSelectedRow: (rows: IdlObject[]) => boolean; @@ -126,6 +127,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'},