mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
[ADF-1951] fixed parsing date value when on readonly mode (#2674)
This commit is contained in:
@@ -224,6 +224,31 @@ describe('FormFieldModel', () => {
|
|||||||
expect(form.values['ddmmyyy']).toEqual('2017-04-28T00:00:00.000Z');
|
expect(form.values['ddmmyyy']).toEqual('2017-04-28T00:00:00.000Z');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse the date with the format DD-MM-YYYY when it is readonly', () => {
|
||||||
|
let form = new FormModel();
|
||||||
|
let field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'ddmmyyy',
|
||||||
|
name: 'DD-MM-YYYY',
|
||||||
|
type: 'readonly',
|
||||||
|
value: '2017-04-28T00:00:00.000+0000',
|
||||||
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'ddmmyyy',
|
||||||
|
name: 'DD-MM-YYYY',
|
||||||
|
type: 'date',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dateDisplayFormat: 'DD-MM-YYYY'
|
||||||
|
});
|
||||||
|
expect(field.value).toBe('28-04-2017');
|
||||||
|
});
|
||||||
|
|
||||||
it('should return the label of selected dropdown value ', () => {
|
it('should return the label of selected dropdown value ', () => {
|
||||||
let field = new FormFieldModel(new FormModel(), {
|
let field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.DROPDOWN,
|
type: FormFieldTypes.DROPDOWN,
|
||||||
|
@@ -311,7 +311,7 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
This is needed due to Activiti displaying/editing dates in d-M-YYYY format
|
This is needed due to Activiti displaying/editing dates in d-M-YYYY format
|
||||||
but storing on server in ISO8601 format (i.e. 2013-02-04T22:44:30.652Z)
|
but storing on server in ISO8601 format (i.e. 2013-02-04T22:44:30.652Z)
|
||||||
*/
|
*/
|
||||||
if (json.type === FormFieldTypes.DATE) {
|
if (this.isDateField(json)) {
|
||||||
if (value) {
|
if (value) {
|
||||||
let dateValue;
|
let dateValue;
|
||||||
if (NumberFieldValidator.isNumber(value)) {
|
if (NumberFieldValidator.isNumber(value)) {
|
||||||
@@ -417,4 +417,11 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
hasOptions() {
|
hasOptions() {
|
||||||
return this.options && this.options.length > 0;
|
return this.options && this.options.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isDateField(json: any) {
|
||||||
|
return (json.params &&
|
||||||
|
json.params.field &&
|
||||||
|
json.params.field.type === FormFieldTypes.DATE ) ||
|
||||||
|
json.type === FormFieldTypes.DATE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user