mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-34140 Asynchronous Forms - automatically populated value cannot be used in another task (#11574)
* AAE-34140 Asynchronous Forms - automatically populated value cannot be used in another task * update * update
This commit is contained in:
@@ -420,6 +420,33 @@ describe('FormFieldModel', () => {
|
|||||||
expect(formDateTimeFormatted).toEqual(currentDateTimeFormatted);
|
expect(formDateTimeFormatted).toEqual(currentDateTimeFormatted);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle properly date string that is in ISO format', () => {
|
||||||
|
const form = new FormModel();
|
||||||
|
const field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'date',
|
||||||
|
name: 'date',
|
||||||
|
type: FormFieldTypes.DATE,
|
||||||
|
value: '',
|
||||||
|
required: false,
|
||||||
|
readOnly: false,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'date',
|
||||||
|
name: 'date',
|
||||||
|
type: FormFieldTypes.DATE,
|
||||||
|
value: '',
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
field.value = '2026-01-23T15:25:03.439+0000';
|
||||||
|
|
||||||
|
expect(field.getFormValue()).toEqual('2026-01-23T00:00:00.000Z');
|
||||||
|
});
|
||||||
|
|
||||||
it('should set the value to null when the value is null', () => {
|
it('should set the value to null when the value is null', () => {
|
||||||
const form = new FormModel();
|
const form = new FormModel();
|
||||||
const field = new FormFieldModel(form, {
|
const field = new FormFieldModel(form, {
|
||||||
|
|||||||
@@ -681,7 +681,15 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
let dateValue;
|
let dateValue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dateValue = DateFnsUtils.parseDate(this.value, this.dateDisplayFormat);
|
let dateWithProperFormat: string | Date;
|
||||||
|
|
||||||
|
if (typeof this.value === 'string') {
|
||||||
|
dateWithProperFormat = DateFnsUtils.formatDate(this.value, this.dateDisplayFormat);
|
||||||
|
} else {
|
||||||
|
dateWithProperFormat = this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
dateValue = DateFnsUtils.parseDate(dateWithProperFormat, this.dateDisplayFormat);
|
||||||
} catch {
|
} catch {
|
||||||
dateValue = new Date('error');
|
dateValue = new Date('error');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user