mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5165] Fix Checkbok widget in completed tasks (#5979)
This commit is contained in:
@@ -249,6 +249,150 @@ describe('FormFieldModel', () => {
|
|||||||
expect(field.value).toBe('28-04-2017');
|
expect(field.value).toBe('28-04-2017');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse the checkbox set to "true" when it is readonly', () => {
|
||||||
|
const form = new FormModel();
|
||||||
|
const field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'readonly',
|
||||||
|
value: 'true',
|
||||||
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(field.value).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse the checkbox set to null when it is readonly', () => {
|
||||||
|
const form = new FormModel();
|
||||||
|
const field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'readonly',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(field.value).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse the checkbox set to "false" when it is readonly', () => {
|
||||||
|
const form = new FormModel();
|
||||||
|
const field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'readonly',
|
||||||
|
value: 'false',
|
||||||
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(field.value).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse the checkbox set to "true" when it is editable', () => {
|
||||||
|
const form = new FormModel();
|
||||||
|
const field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: 'true',
|
||||||
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(field.value).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse the checkbox set to null when it is editable', () => {
|
||||||
|
const form = new FormModel();
|
||||||
|
const field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(field.value).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should parse the checkbox set to "false" when it is editable', () => {
|
||||||
|
const form = new FormModel();
|
||||||
|
const field = new FormFieldModel(form, {
|
||||||
|
fieldType: 'FormFieldRepresentation',
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: 'false',
|
||||||
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
params: {
|
||||||
|
field: {
|
||||||
|
id: 'checkbox',
|
||||||
|
name: 'Checkbox',
|
||||||
|
type: 'boolean',
|
||||||
|
value: null,
|
||||||
|
required: false,
|
||||||
|
readOnly: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(field.value).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
it('should return the label of selected dropdown value ', () => {
|
it('should return the label of selected dropdown value ', () => {
|
||||||
const field = new FormFieldModel(new FormModel(), {
|
const field = new FormFieldModel(new FormModel(), {
|
||||||
type: FormFieldTypes.DROPDOWN,
|
type: FormFieldTypes.DROPDOWN,
|
||||||
|
@@ -320,7 +320,7 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json.type === FormFieldTypes.BOOLEAN) {
|
if (this.isCheckboxField(json)) {
|
||||||
value = json.value === 'true' || json.value === true ? true : false;
|
value = json.value === 'true' || json.value === true ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,4 +447,11 @@ export class FormFieldModel extends FormWidgetModel {
|
|||||||
json.type === FormFieldTypes.DATETIME;
|
json.type === FormFieldTypes.DATETIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isCheckboxField(json: any): boolean {
|
||||||
|
return (json.params &&
|
||||||
|
json.params.field &&
|
||||||
|
json.params.field.type === FormFieldTypes.BOOLEAN) ||
|
||||||
|
json.type === FormFieldTypes.BOOLEAN;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user