[open-ils-commits] [GIT] Evergreen ILS branch master updated. cfada67d541f660b6d7f6430e74eceb9772bb944

Evergreen Git git at git.evergreen-ils.org
Thu Aug 1 10:12:39 EDT 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  cfada67d541f660b6d7f6430e74eceb9772bb944 (commit)
       via  b02b454abdf42e0575f29f4bff0d727e358131a0 (commit)
       via  e85385f7d1d341d1fbca6a91979d326cc7a8fac0 (commit)
       via  d321c4ffc9e9418df1c7791bf6d4948ef88376a7 (commit)
      from  2c0df3989352f96e3a7edc5c1a99d570dfb9b610 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cfada67d541f660b6d7f6430e74eceb9772bb944
Author: Jane Sandberg <sandbej at linnbenton.edu>
Date:   Fri Jul 26 11:28:13 2019 -0700

    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 at linnbenton.edu>
    Signed-off-by: Galen Charlton <gmc at 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'},

commit b02b454abdf42e0575f29f4bff0d727e358131a0
Author: Jane Sandberg <sandbej at linnbenton.edu>
Date:   Mon Jul 8 06:44:53 2019 -0700

    LP1831390: Fixing implementation of registerOnTouch
    
    This commit ensures that the onTouch callback is called on the blur
    event, per the official Angular documentation.
    
    Also improves the display of default values in the datepicker
    
    Signed-off-by: Jane Sandberg <sandbej at linnbenton.edu>
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Galen Charlton <gmc at 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 9277bb060e..2139e5b69e 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
@@ -107,8 +107,9 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
     // and display.  Default version trims leading/trailing spaces.
     formatDisplayString: (e: ComboboxEntry) => string;
 
-    // Stub function required by ControlValueAccessor
+    // Stub functions required by ControlValueAccessor
     propagateChange = (_: any) => {};
+    propagateTouch = () => {};
 
     constructor(
       private elm: ElementRef,
@@ -155,14 +156,12 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
     }
 
     onClick($event) {
-        this.registerOnTouched();
         this.click$.next($event.target.value);
     }
 
     openMe($event) {
         // Give the input a chance to focus then fire the click
         // handler to force open the typeahead
-        this.registerOnTouched();
         this.elm.nativeElement.getElementsByTagName('input')[0].focus();
         setTimeout(() => this.click$.next(''));
     }
@@ -232,6 +231,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
             this.selectorChanged(
                 {item: this.selected, preventDefault: () => true});
         }
+        this.propagateTouch();
     }
 
     // Fired by the typeahead to inform us of a change.
@@ -313,7 +313,9 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
         this.propagateChange = fn;
     }
 
-    registerOnTouched() { }
+    registerOnTouched(fn) {
+        this.propagateTouch = fn;
+    }
 
 }
 
diff --git a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.html b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.html
index 0ff48314c1..80f0188482 100644
--- a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.html
+++ b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.html
@@ -15,6 +15,7 @@
       name="{{fieldName}}"
       [disabled]="disabled"
       [required]="required"
+      (blur)="propagateTouch()"
       [(ngModel)]="current"
       (keyup.enter)="onDateEnter()"
       (dateSelect)="onDateSelect($event)"/>
diff --git a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
index ec35601928..66d363af15 100644
--- a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
+++ b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
@@ -58,8 +58,9 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
         return date;
     }
 
-    // Stub function required by ControlValueAccessor
+    // Stub functions required by ControlValueAccessor
     propagateChange = (_: any) => {};
+    propagateTouch = () => {};
 
     constructor() {
         this.onChangeAsDate = new EventEmitter<Date>();
@@ -78,11 +79,7 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
         }
 
         if (this.initialDate) {
-            this.current = {
-                year: this.initialDate.getFullYear(),
-                month: this.initialDate.getMonth() + 1,
-                day: this.initialDate.getDate()
-            };
+            this.writeValue(this.initialDate);
         }
     }
 
@@ -126,8 +123,12 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
     }
 
     writeValue(value: Date) {
-        if (value !== undefined) {
-            this.initialDate = value;
+        if (value) {
+            this.current = {
+                year: value.getFullYear(),
+                month: value.getMonth() + 1,
+                day: value.getDate()
+            };
         }
     }
 
@@ -135,7 +136,9 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
         this.propagateChange = fn;
     }
 
-    registerOnTouched() { }
+    registerOnTouched(fn) {
+        this.propagateTouch = fn;
+    }
 }
 
 

commit e85385f7d1d341d1fbca6a91979d326cc7a8fac0
Author: Bill Erickson <berickxx at gmail.com>
Date:   Fri Jun 28 15:07:03 2019 -0400

    LP1831390 ControlValueAccessor continued
    
    Make eg-date-select traffic in Date objects instead of YMD strings.
    Added simple combobox [(ngModel)] example.
    Added combobox freetext testing
    Avoid forcing startIdFiresOnChange for combobox.
    Avoid redundant FormsModule import.
    Minor lint repairs.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Jane Sandberg <sandbej at linnbenton.edu>
    Signed-off-by: Galen Charlton <gmc at 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 b4c85bf5e2..9277bb060e 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
@@ -107,6 +107,9 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
     // and display.  Default version trims leading/trailing spaces.
     formatDisplayString: (e: ComboboxEntry) => string;
 
+    // Stub function required by ControlValueAccessor
+    propagateChange = (_: any) => {};
+
     constructor(
       private elm: ElementRef,
       private store: StoreService,
@@ -153,7 +156,7 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
 
     onClick($event) {
         this.registerOnTouched();
-        this.click$.next($event.target.value)
+        this.click$.next($event.target.value);
     }
 
     openMe($event) {
@@ -303,12 +306,9 @@ export class ComboboxComponent implements ControlValueAccessor, OnInit {
     writeValue(value: any) {
         if (value !== undefined) {
             this.startId = value;
-            this.startIdFiresOnChange = true;
         }
     }
 
-    propagateChange = (_: any) => {};
-
     registerOnChange(fn) {
         this.propagateChange = fn;
     }
diff --git a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
index 079c4fe715..ec35601928 100644
--- a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
+++ b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
@@ -58,6 +58,9 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
         return date;
     }
 
+    // Stub function required by ControlValueAccessor
+    propagateChange = (_: any) => {};
+
     constructor() {
         this.onChangeAsDate = new EventEmitter<Date>();
         this.onChangeAsIso = new EventEmitter<string>();
@@ -102,8 +105,8 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
         const iso = date.toISOString();
         this.onChangeAsDate.emit(date);
         this.onChangeAsYmd.emit(ymd);
-        this.propagateChange(ymd);
         this.onChangeAsIso.emit(iso);
+        this.propagateChange(date);
     }
 
     // Create a date in the local time zone with selected YMD values.
@@ -122,14 +125,12 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
         };
     }
 
-    writeValue(value: string) {
+    writeValue(value: Date) {
         if (value !== undefined) {
-            this.initialYmd = value;
+            this.initialDate = value;
         }
     }
 
-    propagateChange = (_: any) => {};
-
     registerOnChange(fn) {
         this.propagateChange = fn;
     }
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 fd8a75508b..cc778ce230 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">
+        <eg-combobox ngModel #templateEntry="ngModel" [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>
@@ -253,9 +253,9 @@
         </eg-combobox>
       Result: {{templateEntry.value | json}}
         <hr>
-        <eg-date-select [(ngModel)]="dateString">
+        <eg-date-select [(ngModel)]="dateObject">
         </eg-date-select>
-      ngModel: {{dateString}}
+      ngModel: {{dateObject.toLocaleDateString()}}
       </div>
     </div>
   </div>
@@ -264,7 +264,8 @@
       <h3 class="card-title">Or perhaps reactive forms interest you?</h3>
       <div class="card-text">
         Choose your favorite law of library science: 
-        <eg-combobox formControlName="law" value="second">
+        <eg-combobox formControlName="law" value="second" 
+          [allowFreeText]="true" [startIdFiresOnChange]="true">
           <eg-combobox-entry entryId="first" entryLabel="Books are for use" i18n-entryLabel></eg-combobox-entry>
           <eg-combobox-entry entryId="second" entryLabel="Every person his or her book" i18n-entryLabel></eg-combobox-entry>
           <eg-combobox-entry entryId="third" entryLabel="Every book its reader" i18n-entryLabel></eg-combobox-entry>
@@ -318,3 +319,19 @@
     Test Readonly Date
   </button>
 </div>
+
+<div class="row m-3 p-3 border-top border-dark">
+  <div class="col-lg-3">Simple Combobox using [(ngModel)]</div>
+  <div class="col-lg-3">
+    <eg-combobox [(ngModel)]="simpleCombo" [allowFreeText]="true">
+      <eg-combobox-entry 
+        entryId="abc" entryLabel="ABC" i18n-entryLabel></eg-combobox-entry>
+      <eg-combobox-entry 
+        entryId="def" entryLabel="DEF" i18n-entryLabel></eg-combobox-entry>
+    </eg-combobox>
+  </div>
+  <div class="col-lg-3">
+    <span i18n>Combobox Value: {{simpleCombo ? simpleCombo.label : ''}}</span>
+  </div>
+</div>
+
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 373e86fe4c..d5b37bf8e2 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
@@ -83,7 +83,9 @@ export class SandboxComponent implements OnInit {
 
     ranganathan: FormGroup;
 
-    dateString = '2019-09-09';
+    dateObject: Date = new Date();
+
+    simpleCombo: ComboboxEntry;
 
     complimentEvergreen: (rows: IdlObject[]) => void;
     notOneSelectedRow: (rows: IdlObject[]) => boolean;
@@ -126,7 +128,7 @@ export class SandboxComponent implements OnInit {
         this.ranganathan = new FormGroup({
             'law': new FormControl('second', (c: FormControl) => {
                 // An Angular custom validator
-                if ("wrong" === c.value.id) {
+                if ('wrong' === c.value.id || c.value.freetext) {
                     return { notALaw: 'That\'s not a real law of library science!' };
                     } else {
                         return null;
diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts
index ebb886a67f..0937ab0ee3 100644
--- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts
+++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts
@@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
 import {StaffCommonModule} from '@eg/staff/common.module';
 import {SandboxRoutingModule} from './routing.module';
 import {SandboxComponent} from './sandbox.component';
-import {FormsModule, ReactiveFormsModule} from '@angular/forms';
+import {ReactiveFormsModule} from '@angular/forms';
 
 @NgModule({
   declarations: [
@@ -11,8 +11,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
   imports: [
     StaffCommonModule,
     SandboxRoutingModule,
-    FormsModule,
-    ReactiveFormsModule,
+    ReactiveFormsModule
   ],
   providers: [
   ]

commit d321c4ffc9e9418df1c7791bf6d4948ef88376a7
Author: Jane Sandberg <sandbej at linnbenton.edu>
Date:   Tue Jun 25 11:17:07 2019 -0700

    LP1831390: combobox and date-select implement ControlValueAccessor
    
    This makes both components compatible with [(ngModel)] and
    reactive forms.
    
    Also adds sandbox examples.
    
    Signed-off-by: Jane Sandberg <sandbej at linnbenton.edu>
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html
index 0a5deeeb8c..b6099fcae9 100644
--- a/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html
+++ b/Open-ILS/src/eg2/src/app/share/combobox/combobox.component.html
@@ -16,7 +16,7 @@
     [ngbTypeahead]="filter"
     [resultTemplate]="displayTemplate"
     [inputFormatter]="formatDisplayString"
-    (click)="click$.next($event.target.value)"
+    (click)="onClick($event)"
     (blur)="onBlur()"
     (selectItem)="selectorChanged($event)"
     #instance="ngbTypeahead"/>
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 99206321cd..b4c85bf5e2 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
@@ -3,7 +3,8 @@
  *  <!-- see also <eg-combobox-entry> -->
  * </eg-combobox>
  */
-import {Component, OnInit, Input, Output, ViewChild, EventEmitter, ElementRef} from '@angular/core';
+import {Component, OnInit, Input, Output, ViewChild, EventEmitter, ElementRef, forwardRef} from '@angular/core';
+import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
 import {Observable, of, Subject} from 'rxjs';
 import {map, tap, reduce, mergeMap, mapTo, debounceTime, distinctUntilChanged, merge, filter} from 'rxjs/operators';
 import {NgbTypeahead, NgbTypeaheadSelectItemEvent} from '@ng-bootstrap/ng-bootstrap';
@@ -24,9 +25,14 @@ export interface ComboboxEntry {
   styles: [`
     .icons {margin-left:-18px}
     .material-icons {font-size: 16px;font-weight:bold}
-  `]
+  `],
+  providers: [{
+    provide: NG_VALUE_ACCESSOR,
+    useExisting: forwardRef(() => ComboboxComponent),
+    multi: true
+  }]
 })
-export class ComboboxComponent implements OnInit {
+export class ComboboxComponent implements ControlValueAccessor, OnInit {
 
     selected: ComboboxEntry;
     click$: Subject<string>;
@@ -145,9 +151,15 @@ export class ComboboxComponent implements OnInit {
         }
     }
 
+    onClick($event) {
+        this.registerOnTouched();
+        this.click$.next($event.target.value)
+    }
+
     openMe($event) {
         // Give the input a chance to focus then fire the click
         // handler to force open the typeahead
+        this.registerOnTouched();
         this.elm.nativeElement.getElementsByTagName('input')[0].focus();
         setTimeout(() => this.click$.next(''));
     }
@@ -222,6 +234,7 @@ export class ComboboxComponent implements OnInit {
     // Fired by the typeahead to inform us of a change.
     selectorChanged(selEvent: NgbTypeaheadSelectItemEvent) {
         this.onChange.emit(selEvent.item);
+        this.propagateChange(selEvent.item);
     }
 
     // Adds matching async entries to the entry list
@@ -286,6 +299,22 @@ export class ComboboxComponent implements OnInit {
             })
         );
     }
+
+    writeValue(value: any) {
+        if (value !== undefined) {
+            this.startId = value;
+            this.startIdFiresOnChange = true;
+        }
+    }
+
+    propagateChange = (_: any) => {};
+
+    registerOnChange(fn) {
+        this.propagateChange = fn;
+    }
+
+    registerOnTouched() { }
+
 }
 
 
diff --git a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
index d877300677..079c4fe715 100644
--- a/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
+++ b/Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts
@@ -1,5 +1,6 @@
-import {Component, OnInit, Input, Output, ViewChild, EventEmitter} from '@angular/core';
+import {Component, OnInit, Input, Output, ViewChild, EventEmitter, forwardRef} from '@angular/core';
 import {NgbDateStruct} from '@ng-bootstrap/ng-bootstrap';
+import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
 
 /**
  * RE: displaying locale dates in the input field:
@@ -10,9 +11,14 @@ import {NgbDateStruct} from '@ng-bootstrap/ng-bootstrap';
 @Component({
   selector: 'eg-date-select',
   templateUrl: './date-select.component.html',
-  styleUrls: ['date-select.component.css']
+  styleUrls: ['date-select.component.css'],
+  providers: [ {
+      provide: NG_VALUE_ACCESSOR,
+      useExisting: forwardRef(() => DateSelectComponent),
+      multi: true
+  } ]
 })
-export class DateSelectComponent implements OnInit {
+export class DateSelectComponent implements OnInit, ControlValueAccessor {
 
     @Input() initialIso: string; // ISO string
     @Input() initialYmd: string; // YYYY-MM-DD (uses local time zone)
@@ -96,6 +102,7 @@ export class DateSelectComponent implements OnInit {
         const iso = date.toISOString();
         this.onChangeAsDate.emit(date);
         this.onChangeAsYmd.emit(ymd);
+        this.propagateChange(ymd);
         this.onChangeAsIso.emit(iso);
     }
 
@@ -115,6 +122,19 @@ export class DateSelectComponent implements OnInit {
         };
     }
 
+    writeValue(value: string) {
+        if (value !== undefined) {
+            this.initialYmd = value;
+        }
+    }
+
+    propagateChange = (_: any) => {};
+
+    registerOnChange(fn) {
+        this.propagateChange = fn;
+    }
+
+    registerOnTouched() { }
 }
 
 
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 37e46d9c86..fd8a75508b 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
@@ -241,13 +241,48 @@
           ngModel #bestOnes="ngModel">
         </eg-org-family-select>
         The best libraries are: {{bestOnes.value | json}}
+        <hr>
+        <eg-combobox ngModel #templateEntry="ngModel">
+          <eg-combobox-entry entryId="Bacteria"></eg-combobox-entry>
+          <eg-combobox-entry entryId="Archaea"></eg-combobox-entry>
+          <eg-combobox-entry entryId="Protozoa"></eg-combobox-entry>
+          <eg-combobox-entry entryId="Chromista"></eg-combobox-entry>
+          <eg-combobox-entry entryId="Plantae"></eg-combobox-entry>
+          <eg-combobox-entry entryId="Fungi"></eg-combobox-entry>
+          <eg-combobox-entry entryId="Animalia"></eg-combobox-entry>
+        </eg-combobox>
+      Result: {{templateEntry.value | json}}
+        <hr>
+        <eg-date-select [(ngModel)]="dateString">
+        </eg-date-select>
+      ngModel: {{dateString}}
       </div>
     </div>
   </div>
-  <form class="card col-md-6" [formGroup]="badOrgForm">
+  <form class="card col-md-4" [formGroup]="ranganathan">
     <div class="card-body">
       <h3 class="card-title">Or perhaps reactive forms interest you?</h3>
       <div class="card-text">
+        Choose your favorite law of library science: 
+        <eg-combobox formControlName="law" value="second">
+          <eg-combobox-entry entryId="first" entryLabel="Books are for use" i18n-entryLabel></eg-combobox-entry>
+          <eg-combobox-entry entryId="second" entryLabel="Every person his or her book" i18n-entryLabel></eg-combobox-entry>
+          <eg-combobox-entry entryId="third" entryLabel="Every book its reader" i18n-entryLabel></eg-combobox-entry>
+          <eg-combobox-entry entryId="fourth" entryLabel="Save the time of the reader" i18n-entryLabel></eg-combobox-entry>
+          <eg-combobox-entry entryId="fifth" entryLabel="Library is a growing organism" i18n-entryLabel></eg-combobox-entry>
+          <eg-combobox-entry entryId="wrong" entryLabel="42" i18n-entryLabel></eg-combobox-entry>
+        </eg-combobox>
+        <div *ngIf="!ranganathan.valid" class="alert alert-danger">
+          <span class="material-icons">error</span>
+          <span i18n>That isn't a real law of library science!</span>
+        </div>
+      </div>
+    </div>
+  </form>
+  <form class="card col-md-4" [formGroup]="badOrgForm">
+    <div class="card-body">
+      <h3 class="card-title">Another reactive form!</h3>
+      <div class="card-text">
         <eg-org-family-select
           formControlName="badOrgSelector"
           labelText="Choose the fanciest libraries">
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 a816caffb8..373e86fe4c 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
@@ -81,6 +81,10 @@ export class SandboxComponent implements OnInit {
 
     badOrgForm: FormGroup;
 
+    ranganathan: FormGroup;
+
+    dateString = '2019-09-09';
+
     complimentEvergreen: (rows: IdlObject[]) => void;
     notOneSelectedRow: (rows: IdlObject[]) => boolean;
 
@@ -119,10 +123,25 @@ export class SandboxComponent implements OnInit {
             } )
         });
 
+        this.ranganathan = new FormGroup({
+            'law': new FormControl('second', (c: FormControl) => {
+                // An Angular custom validator
+                if ("wrong" === c.value.id) {
+                    return { notALaw: 'That\'s not a real law of library science!' };
+                    } else {
+                        return null;
+                    }
+            } )
+        });
+
         this.badOrgForm.get('badOrgSelector').valueChanges.subscribe(bad => {
             this.toast.danger('The fanciest libraries are: ' + JSON.stringify(bad.orgIds));
         });
 
+        this.ranganathan.get('law').valueChanges.subscribe(l => {
+            this.toast.success('You chose: ' + l.label);
+        });
+
         this.gridDataSource.data = [
             {name: 'Jane', state: 'AZ'},
             {name: 'Al', state: 'CA'},
diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts
index ec817d0d51..ebb886a67f 100644
--- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts
+++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.module.ts
@@ -12,7 +12,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
     StaffCommonModule,
     SandboxRoutingModule,
     FormsModule,
-    ReactiveFormsModule
+    ReactiveFormsModule,
   ],
   providers: [
   ]

-----------------------------------------------------------------------

Summary of changes:
 .../src/app/share/combobox/combobox.component.html |  2 +-
 .../src/app/share/combobox/combobox.component.ts   | 38 +++++++++++++--
 .../share/date-select/date-select.component.html   |  1 +
 .../app/share/date-select/date-select.component.ts | 40 ++++++++++++----
 .../src/app/staff/sandbox/sandbox.component.html   | 54 +++++++++++++++++++++-
 .../eg2/src/app/staff/sandbox/sandbox.component.ts | 24 ++++++++++
 .../eg2/src/app/staff/sandbox/sandbox.module.ts    |  3 +-
 7 files changed, 147 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list