From 9f60a5706ed4091bb0a3a4f5a52655f254773b44 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 7 Oct 2021 14:58:32 -0400 Subject: [PATCH] LP1840782 component Signed-off-by: Bill Erickson --- .../date-select-native.component.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/date-select-native/date-select-native.component.ts b/Open-ILS/src/eg2/src/app/share/date-select-native/date-select-native.component.ts index 5fe5aa781c..42f2da355f 100644 --- a/Open-ILS/src/eg2/src/app/share/date-select-native/date-select-native.component.ts +++ b/Open-ILS/src/eg2/src/app/share/date-select-native/date-select-native.component.ts @@ -13,7 +13,6 @@ import {DateUtil} from '@eg/share/util/date'; }] }) export class DateSelectNativeComponent implements OnInit, ControlValueAccessor { - static domAutoId = 1; @Input() fieldName = ''; @@ -25,6 +24,10 @@ export class DateSelectNativeComponent implements OnInit, ControlValueAccessor { // Emits YYYY-MM-DD on value change, null on empty. @Output() dateChange: EventEmitter = new EventEmitter(); + // Emits Date object + @Output() dateChangeAsDate: EventEmitter = new EventEmitter(); + // Emits ISO8601 date string + @Output() dateChangeAsIso: EventEmitter = new EventEmitter(); // Stub functions required by ControlValueAccessor propagateChange = (_: any) => {}; @@ -40,8 +43,20 @@ export class DateSelectNativeComponent implements OnInit, ControlValueAccessor { inputChange(evt: Event) { const value = this.input().value; - this.dateChange.emit(value || null); this.propagateChange(value); + + if (!value) { + this.dateChange.emit(null); + this.dateChangeAsDate.emit(null); + this.dateChangeAsIso.emit(null); + + } else { + + let date = DateUtil.localDateFromYmd(value); + this.dateChange.emit(value); + this.dateChangeAsDate.emit(date); + this.dateChangeAsIso.emit(date.toISOString()); + } } writeValue(ymd: string) { -- 2.11.0