@hmcts/ccd-case-ui-toolkit 7.3.0-exui-3066 → 7.3.0-exui-3066-2
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.
|
@@ -637,7 +637,11 @@ class DateInputComponent {
|
|
|
637
637
|
].join(':');
|
|
638
638
|
const localDateTimeString = `${date}T${time}.000`;
|
|
639
639
|
// convert from local time to UTC for storage
|
|
640
|
-
const localMoment = moment(localDateTimeString);
|
|
640
|
+
const localMoment = moment(localDateTimeString, 'YYYY-MM-DDTHH:mm:ss.SSS', true);
|
|
641
|
+
// if invalid, return the raw string for validation to catch
|
|
642
|
+
if (!localMoment.isValid()) {
|
|
643
|
+
return localDateTimeString;
|
|
644
|
+
}
|
|
641
645
|
const utcMoment = localMoment.utc();
|
|
642
646
|
// return in the expected format
|
|
643
647
|
return utcMoment.format('YYYY-MM-DDTHH:mm:ss.000');
|
|
@@ -29327,7 +29331,6 @@ class DatetimePickerComponent extends AbstractFormFieldComponent {
|
|
|
29327
29331
|
ngOnInit() {
|
|
29328
29332
|
this.dateTimeEntryFormat = this.formatTranslationService.showOnlyDates(this.caseField.dateTimeEntryFormat);
|
|
29329
29333
|
this.configureDatePicker(this.dateTimeEntryFormat);
|
|
29330
|
-
const existingControl = (this.parent || this.formGroup)?.controls?.[this.caseField.id];
|
|
29331
29334
|
// for when navigating back to an existing form
|
|
29332
29335
|
this.dateControl = (this.caseField.isMandatory ?
|
|
29333
29336
|
this.registerControl(new FormControl(this.caseField.value || '', [Validators.required]))
|
|
@@ -29483,23 +29486,21 @@ class DatetimePickerComponent extends AbstractFormFieldComponent {
|
|
|
29483
29486
|
this.inputElement.nativeElement.value = keepErrorText;
|
|
29484
29487
|
}
|
|
29485
29488
|
}
|
|
29486
|
-
else {
|
|
29489
|
+
else if (this.localDisplayControl.value) {
|
|
29487
29490
|
// input is empty - check if we need to sync from control values
|
|
29488
|
-
|
|
29489
|
-
|
|
29490
|
-
|
|
29491
|
-
|
|
29492
|
-
|
|
29493
|
-
|
|
29494
|
-
|
|
29495
|
-
this.inputElement.nativeElement.value = formattedValue;
|
|
29496
|
-
}
|
|
29497
|
-
}
|
|
29498
|
-
else if (!this.dateControl.value) {
|
|
29499
|
-
this.localDisplayControl.setValue('');
|
|
29500
|
-
this.dateControl.setValue('');
|
|
29491
|
+
// control has a value but input doesn't - this happens when navigating back
|
|
29492
|
+
// manually sync the control value to the input element
|
|
29493
|
+
const controlValue = this.localDisplayControl.value;
|
|
29494
|
+
const parsedMoment = moment(controlValue, this.momentFormat);
|
|
29495
|
+
if (parsedMoment.isValid()) {
|
|
29496
|
+
const formattedValue = parsedMoment.format(this.dateTimeEntryFormat);
|
|
29497
|
+
this.inputElement.nativeElement.value = formattedValue;
|
|
29501
29498
|
}
|
|
29502
29499
|
}
|
|
29500
|
+
else if (!this.dateControl.value) {
|
|
29501
|
+
this.localDisplayControl.setValue('');
|
|
29502
|
+
this.dateControl.setValue('');
|
|
29503
|
+
}
|
|
29503
29504
|
}
|
|
29504
29505
|
static ɵfac = function DatetimePickerComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DatetimePickerComponent)(i0.ɵɵdirectiveInject(FormatTranslatorService), i0.ɵɵdirectiveInject(NGX_MAT_DATE_FORMATS)); };
|
|
29505
29506
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DatetimePickerComponent, selectors: [["ccd-datetime-picker"]], viewQuery: function DatetimePickerComponent_Query(rf, ctx) { if (rf & 1) {
|