Skip to content

Commit

Permalink
fix(dynamic-form): corrige erro de visibilidade campos no container
Browse files Browse the repository at this point in the history
Corrige erro ao setar visibilidade nos campos quando dentro de um container

fixes DTHFUI-10270
  • Loading branch information
anderson-gregorio-totvs committed Nov 19, 2024
1 parent f86d1bd commit 54e19d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,7 @@ describe('PoDynamicFormFieldsComponent: ', () => {
const updatedFields = component['updateFieldContainer'](changes, containerFields);

expect(updatedFields[0][0].container).toBe('updatedContainer1');
expect(updatedFields[1][0].container).toBe('container2');
expect(updatedFields[2][0].container).toBe('updatedContainer3');
expect(updatedFields[1][0].container).toBe('updatedContainer3');
});

it('diffObjectsArray: should return the complete object if it is new in the array', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class PoDynamicFormFieldsComponent extends PoDynamicFormFieldsBaseCompone
this.containerFields = this.updateFieldContainer(result, this.containerFields);
}

private updateFieldContainer(changes, containerFields) {
private updateFieldContainer(changes: Array<PoDynamicFormField>, containerFields: Array<Array<PoDynamicFormField>>) {
const mapchanges = new Map(changes.map(obj => [obj.property, obj]));

containerFields.forEach(subArray => {
Expand All @@ -218,7 +218,14 @@ export class PoDynamicFormFieldsComponent extends PoDynamicFormFieldsBaseCompone
});
});

return containerFields;
// Garante que apenas os items de `changes` estejam em `containerFields`
return containerFields
.map(itemFields =>
itemFields.filter(formFieldContainer =>
changes.some(formFieldChanges => formFieldContainer.property === formFieldChanges.property)
)
)
.filter(subArray => subArray.length > 0);
}

private diffObjectsArray(oldArray, newArray) {
Expand Down

0 comments on commit 54e19d3

Please sign in to comment.