@hmcts/ccd-case-ui-toolkit 7.4.27-date-range-filter-4 → 7.4.27-date-range-filter-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34937,6 +34937,11 @@ const CUSTOM_MOMENT_FORMATS = {
|
|
|
34937
34937
|
monthYearA11yLabel: 'MMMM YYYY',
|
|
34938
34938
|
},
|
|
34939
34939
|
};
|
|
34940
|
+
// Factory function to provide custom moment formats for Angular Material date pickers
|
|
34941
|
+
const customMomentFormatsFactory = () => ({
|
|
34942
|
+
parse: { ...CUSTOM_MOMENT_FORMATS.parse },
|
|
34943
|
+
display: { ...CUSTOM_MOMENT_FORMATS.display }
|
|
34944
|
+
});
|
|
34940
34945
|
|
|
34941
34946
|
const _c0$j = ["picker"];
|
|
34942
34947
|
const _c1$6 = ["input"];
|
|
@@ -35050,6 +35055,8 @@ class DatetimePickerComponent extends AbstractFormFieldComponent {
|
|
|
35050
35055
|
ngOnInit() {
|
|
35051
35056
|
this.dateTimeEntryFormat = this.formatTranslationService.showOnlyDates(this.caseField.dateTimeEntryFormat);
|
|
35052
35057
|
this.configureDatePicker(this.dateTimeEntryFormat);
|
|
35058
|
+
// set date time format so that correct format is applied to the date picker input
|
|
35059
|
+
this.setDateTimeFormat();
|
|
35053
35060
|
// set date control based on mandatory field
|
|
35054
35061
|
this.dateControl = (this.caseField.isMandatory ?
|
|
35055
35062
|
this.registerControl(new FormControl(this.caseField.value || '', [Validators.required]))
|
|
@@ -35164,7 +35171,7 @@ class DatetimePickerComponent extends AbstractFormFieldComponent {
|
|
|
35164
35171
|
formatValueAndSetErrors() {
|
|
35165
35172
|
if (this.inputElement.nativeElement.value) {
|
|
35166
35173
|
let formValue = this.inputElement.nativeElement.value;
|
|
35167
|
-
formValue = moment(formValue, this.dateTimeEntryFormat).format(this.momentFormat);
|
|
35174
|
+
formValue = moment(formValue, this.dateTimeEntryFormat, true).format(this.momentFormat);
|
|
35168
35175
|
if (formValue !== 'Invalid date') {
|
|
35169
35176
|
// if not invalid set the value as the formatted value
|
|
35170
35177
|
this.dateControl.setValue(formValue);
|
|
@@ -35190,7 +35197,7 @@ class DatetimePickerComponent extends AbstractFormFieldComponent {
|
|
|
35190
35197
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.datetimePicker = _t.first);
|
|
35191
35198
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.inputElement = _t.first);
|
|
35192
35199
|
} }, inputs: { dateControl: "dateControl", caseFieldLabel: "caseFieldLabel" }, outputs: { dateChange: "dateChange" }, standalone: false, features: [i0.ɵɵProvidersFeature([
|
|
35193
|
-
{ provide: MAT_DATE_FORMATS,
|
|
35200
|
+
{ provide: MAT_DATE_FORMATS, useFactory: customMomentFormatsFactory },
|
|
35194
35201
|
{
|
|
35195
35202
|
provide: DateAdapter,
|
|
35196
35203
|
useClass: MomentDateAdapter,
|
|
@@ -35243,7 +35250,7 @@ class DatetimePickerComponent extends AbstractFormFieldComponent {
|
|
|
35243
35250
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DatetimePickerComponent, [{
|
|
35244
35251
|
type: Component,
|
|
35245
35252
|
args: [{ selector: 'ccd-datetime-picker', encapsulation: ViewEncapsulation.None, providers: [
|
|
35246
|
-
{ provide: MAT_DATE_FORMATS,
|
|
35253
|
+
{ provide: MAT_DATE_FORMATS, useFactory: customMomentFormatsFactory },
|
|
35247
35254
|
{
|
|
35248
35255
|
provide: DateAdapter,
|
|
35249
35256
|
useClass: MomentDateAdapter,
|
|
@@ -39308,7 +39315,8 @@ class DatePickerRangeComponent {
|
|
|
39308
39315
|
setDateRangeTime(controlName, hour, minute, second, millisecond) {
|
|
39309
39316
|
const control = this.formGroup.get(controlName);
|
|
39310
39317
|
if (control?.value) {
|
|
39311
|
-
|
|
39318
|
+
// ISO_8601 strict parsing due to some strings previously setting incorrect dates
|
|
39319
|
+
const date = moment(control.value, moment.ISO_8601, true);
|
|
39312
39320
|
if (date.isValid()) {
|
|
39313
39321
|
control.setValue(date.hour(hour).minute(minute).second(second ?? 0).millisecond(millisecond ?? 0).format('YYYY-MM-DDTHH:mm:ss.SSS'));
|
|
39314
39322
|
}
|