LP1903357 date select emits on clear
authorBill Erickson <berickxx@gmail.com>
Thu, 15 Apr 2021 19:42:46 +0000 (15:42 -0400)
committerJosh Stompro <stompro@stompro.org>
Thu, 12 Aug 2021 15:38:17 +0000 (10:38 -0500)
Emit value changes from <eg-date-select /> when the value is cleared.
The value emitted on clear is 'null'.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Josh Stompro <stompro@stompro.org>
Open-ILS/src/eg2/src/app/share/date-select/date-select.component.html
Open-ILS/src/eg2/src/app/share/date-select/date-select.component.ts

index 0f5777e..aa87fd7 100644 (file)
@@ -17,6 +17,7 @@
       [required]="required"
       (blur)="propagateTouch(); onDateEnter()"
       [(ngModel)]="current"
+      (ngModelChange)="inputChanged($event)"
       (keyup.enter)="onDateEnter()"
       (dateSelect)="onDateSelect($event)"/>
     <div class="input-group-append">
index b66a261..06dd312 100644 (file)
@@ -115,6 +115,17 @@ export class DateSelectComponent implements OnInit, ControlValueAccessor {
             Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
     }
 
+    // onDateSelect() is not called when the value is cleared.
+    // Handle that here.
+    inputChanged(value) {
+        if (value === null) {
+            this.onChangeAsDate.emit(null);
+            this.onChangeAsYmd.emit(null);
+            this.onChangeAsIso.emit(null);
+            this.propagateChange(null);
+        }
+    }
+
     reset() {
         this.current = {
             year: null,