94031: Fix findById for concat fields

As far as I can tell the suffix is never used with a numeric part, causing this branch to always miss concat group fields
This commit is contained in:
Yura Bondarenko
2022-09-07 13:49:11 +02:00
committed by Yury Bondarenko
parent 342a712513
commit d88352f513
2 changed files with 11 additions and 2 deletions

View File

@@ -325,6 +325,14 @@ describe('FormBuilderService test suite', () => {
typeBindRelations: [{ match: 'VISIBLE', operator: 'OR', when: [{id: 'dc.type', value: 'Book' }]}]
},
),
new DynamicConcatModel({
id: 'testConcatGroup_CONCAT_GROUP',
group: [
new DynamicInputModel({ id: 'testConcatGroup_CONCAT_FIRST_INPUT' }),
new DynamicInputModel({ id: 'testConcatGroup_CONCAT_SECOND_INPUT' }),
]
} as any)
];
testFormConfiguration = {
@@ -463,6 +471,7 @@ describe('FormBuilderService test suite', () => {
expect(service.findById('testTimePicker', testModel) instanceof DynamicTimePickerModel).toBe(true);
expect(service.findById('testRating', testModel) instanceof DynamicRatingModel).toBe(true);
expect(service.findById('testColorPicker', testModel) instanceof DynamicColorPickerModel).toBe(true);
expect(service.findById('testConcatGroup', testModel) instanceof DynamicConcatModel).toBe(true);
});
it('should find a nested dynamic form control model by id', () => {

View File

@@ -116,8 +116,8 @@ export class FormBuilderService extends DynamicFormService {
}
if (this.isConcatGroup(controlModel)) {
if (controlModel.id.match(new RegExp(findId + CONCAT_GROUP_SUFFIX + `_\\d+$`))) {
result = (controlModel as DynamicConcatModel).group[0];
if (controlModel.id.match(new RegExp(findId + CONCAT_GROUP_SUFFIX))) {
result = (controlModel as DynamicConcatModel);
break;
}
}