Skip to content

Commit

Permalink
fix(dynamic-view): corrige exibicao de campos com opcoes
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosAlmeida01 committed Mar 19, 2024
1 parent e5f46a2 commit 398e571
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,6 @@ describe('PoDynamicViewBaseComponent:', () => {
expect(result).toBe('1 - Company1 - 261-81-7609');
});

it(`createField: should call 'transformFieldLabel' and return a fieldLabel property`, () => {
const field = { property: 'name', label: 'Nome', fieldLabel: 'title', fieldValue: 'id' };
component.value = { name: 'Test Name', title: 'Title Test', id: 123 };

const newField = component['createField'](field);

expect(newField.value).toBe('Title Test');
});

it('createField: should call `transformFieldLabel`, return a `fieldLabel` and `fieldValue` property if `concatLabelValue` is true', () => {
const field = {
property: 'name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class PoDynamicViewBaseComponent {
if (field.isArrayOrObject && this.value[property]) {
value = this.transformArrayValue(this.value[property], field);
} else if (field.fieldLabel) {
value = this.transformFieldLabel(property, field);
value = this.transformFieldLabel(field);
}

if (!value) {
Expand Down Expand Up @@ -339,15 +339,11 @@ export class PoDynamicViewBaseComponent {
}
}

private transformFieldLabel(property: string, field: PoDynamicViewField) {
private transformFieldLabel(field: PoDynamicViewField) {
if (field.concatLabelValue && field.fieldLabel && field.fieldValue && !field.isArrayOrObject) {
const transformedValue = this.transformValue(field.type, this.value[field.fieldLabel], field.format);
return `${transformedValue} - ${this.value[field.fieldValue]}`;
}

if (field.fieldLabel && !field.concatLabelValue && !field.isArrayOrObject) {
this.value[property] = this.value[field.fieldLabel];
}
return undefined;
}

Expand Down

0 comments on commit 398e571

Please sign in to comment.