mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-12260] - fixing form field mapping (#8243)
* [AAE-12260] - reverting form field mapping to fix wrong behaivour * [AAE-12260] - fixed readonly radiobutton * [AAE-12260] - fixed valid check for rest options when multiple choice is made * [AAE-12260] - fixed name for array elements * [ci skip] * start ci
This commit is contained in:
@@ -714,8 +714,8 @@ describe('FormFieldModel', () => {
|
||||
]
|
||||
});
|
||||
field.updateForm();
|
||||
expect(form.values['dropdown_field']['fake-id-property']).toEqual('opt1');
|
||||
expect(form.values['dropdown_field']['fake-label-property']).toEqual('Option 1');
|
||||
expect(form.values['dropdown_field'].id).toEqual('opt1');
|
||||
expect(form.values['dropdown_field'].name).toEqual('Option 1');
|
||||
});
|
||||
|
||||
it('dropdown field type should be formatted on id and name properties if rest properties are not set', () => {
|
||||
@@ -760,8 +760,8 @@ describe('FormFieldModel', () => {
|
||||
]
|
||||
});
|
||||
field.updateForm();
|
||||
expect(form.values['radio_bananan_field']['banana']).toEqual('opt1');
|
||||
expect(form.values['radio_bananan_field']['banLabel']).toEqual('Option 1');
|
||||
expect(form.values['radio_bananan_field'].id).toEqual('opt1');
|
||||
expect(form.values['radio_bananan_field'].name).toEqual('Option 1');
|
||||
});
|
||||
|
||||
it('radio button field rest type should appear with id / name properties when rest properties are not configured', () => {
|
||||
|
@@ -384,14 +384,14 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
|
||||
const entry: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value);
|
||||
if (entry.length > 0) {
|
||||
this.setFormFieldValueOption(entry[0]);
|
||||
this.form.values[this.id] = entry[0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FormFieldTypes.RADIO_BUTTONS:
|
||||
const radioButton: FormFieldOption[] = this.options.filter((opt) => opt.id === this.value);
|
||||
if (radioButton.length > 0) {
|
||||
this.setFormFieldValueOption(radioButton[0]);
|
||||
this.form.values[this.id] = radioButton[0];
|
||||
}
|
||||
break;
|
||||
case FormFieldTypes.UPLOAD:
|
||||
@@ -500,17 +500,4 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
json.type === FormFieldTypes.BOOLEAN;
|
||||
}
|
||||
|
||||
private setFormFieldValueOption(option: FormFieldOption ) {
|
||||
if (this.optionType === 'rest' && !!this.restUrl) {
|
||||
const restEntry = {};
|
||||
const restIdProperty = this.restIdProperty || 'id';
|
||||
const restLabelProperty = this.restLabelProperty || 'name';
|
||||
restEntry[restIdProperty] = option.id;
|
||||
restEntry[restLabelProperty] = option.name;
|
||||
this.form.values[this.id] = restEntry;
|
||||
} else {
|
||||
this.form.values[this.id] = option;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user