From 5b5c39e4b00a12d8c531fa914be72899d0885c19 Mon Sep 17 00:00:00 2001 From: jcorrea97 Date: Tue, 21 May 2024 14:52:42 -0300 Subject: [PATCH] fix(page-dynamic): corrige container sem titulo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige container sem titulo quando algum valor é `null` e utiliza serviço fixes DTHFUI-8884 --- .../po-dynamic-view-base.component.spec.ts | 22 +++++++++++++++++++ .../po-dynamic-view-base.component.ts | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.spec.ts b/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.spec.ts index 5e4f543d3e..ded9e0bf5f 100644 --- a/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.spec.ts +++ b/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.spec.ts @@ -581,6 +581,28 @@ describe('PoDynamicViewBaseComponent:', () => { expect(component.ensureFieldHasContainer).toHaveBeenCalled(); }); + + it('should call createFieldWithService if the field has a container, even if the property value is null', () => { + component.fields = [ + { + searchService: 'https://api/test', + container: 'Dados Empresa', + property: 'empresa', + type: 'string', + label: 'Empresa' + } + ]; + + component.value = { + empresa: null + }; + + spyOn(component, 'createFieldWithService'); + + component['getConfiguredFields'](); + + expect(component['createFieldWithService']).toHaveBeenCalled(); + }); }); it('searchById: should return null if value is empty', done => { diff --git a/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.ts b/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.ts index b4f0890bcf..cd893c1c00 100644 --- a/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.ts +++ b/projects/ui/src/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view-base.component.ts @@ -171,7 +171,8 @@ export class PoDynamicViewBaseComponent extends PoDynamicSharedBase { const hasValue = this.value[field.property]?.length || - (!Array.isArray(this.value[field.property]) && this.value[field.property] && useSearchService); + (!Array.isArray(this.value[field.property]) && this.value[field.property] && useSearchService) || + field.container; if (hasValue) { const _field = this.returnValues({ ...field }, '');