mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Activiti form - Dropdown display label in complete form (#1777)
* Dropdown - retrieve the label instead of the id * Add unit test * Use find instead of filter
This commit is contained in:
parent
406d96d5bf
commit
952df8d81c
@ -121,6 +121,19 @@ describe('FormFieldModel', () => {
|
||||
expect(field.value).toBe('deferred');
|
||||
});
|
||||
|
||||
it('should return the label of selected dropdown value ', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
options: [
|
||||
{id: 'fake-option-1', name: 'fake label 1'},
|
||||
{id: 'fake-option-2', name: 'fake label 2'},
|
||||
{id: 'fake-option-3', name: 'fake label 3'}
|
||||
],
|
||||
value: 'fake-option-2'
|
||||
});
|
||||
expect(field.getOptionName()).toBe('fake label 2');
|
||||
});
|
||||
|
||||
it('should parse and resolve radio button value', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.RADIO_BUTTONS,
|
||||
|
@ -340,4 +340,9 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getOptionName(): string {
|
||||
let option: FormFieldOption = this.options.find(opt => opt.id === this.value);
|
||||
return option ? option.name : null;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
|
||||
if (this.field.restUrl) {
|
||||
this.loadRestFieldValue();
|
||||
} else {
|
||||
this.value = this.field.value;
|
||||
this.value = this.field.getOptionName();
|
||||
}
|
||||
break;
|
||||
case FormFieldTypes.RADIO_BUTTONS:
|
||||
|
Loading…
x
Reference in New Issue
Block a user