Skip to content

Commit 762db82

Browse files
marioAntonioTotvsfabiana-monteiro
authored andcommitted
feat(widget): centraliza botão de ações com tag-position top
Centraliza o botão de ações quando há tag-position top. Mantém o posicionamento que já existia para os outros casos 'right' e 'bottom'. Feat: DTHFUI-12922
1 parent d8603ed commit 762db82

4 files changed

Lines changed: 47 additions & 8 deletions

File tree

projects/ui/src/lib/components/po-dynamic/po-dynamic-form/interfaces/po-dynamic-form-field.interface.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ export interface PoDynamicFormField extends PoDynamicField {
118118
* **Componentes compatíveis:** `po-select`, `po-radio-group`, `po-checkbox-group`, `po-multiselect`.
119119
* */
120120
options?:
121-
| Array<string>
122-
| Array<PoSelectOption>
123-
| Array<PoMultiselectOption>
124-
| Array<PoCheckboxGroupOption>
125-
| Array<any>;
121+
Array<string> | Array<PoSelectOption> | Array<PoMultiselectOption> | Array<PoCheckboxGroupOption> | Array<any>;
126122

127123
/**
128124
* Permite que o usuário faça múltipla seleção dentro da lista de opções.

projects/ui/src/lib/components/po-stepper/po-step/po-step.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ export class PoStepComponent implements AfterContentInit {
7474
* ```
7575
*/
7676
@Input('p-can-active-next-step') canActiveNextStep:
77-
| ((currentStep) => boolean)
78-
| ((currentStep) => Observable<boolean>);
77+
((currentStep) => boolean) | ((currentStep) => Observable<boolean>);
7978

8079
/** Título que será exibido descrevendo o passo (*step*). */
8180
@Input('p-label') label: string = '';

projects/ui/src/lib/components/po-widget/po-widget.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333

3434
<div class="po-widget-container__content">
3535
@if (hasTitleHelpOrSetting()) {
36-
<div class="po-widget-header">
36+
<div
37+
class="po-widget-header"
38+
[class.po-widget-header__tag-top-actions]="tagLabel && tagPosition() === 'top' && actions?.length"
39+
>
3740
@if (tagLabel && tagPosition() === 'top') {
3841
<div class="po-widget-header__tag-top">
3942
<ng-template [ngTemplateOutlet]="tag"></ng-template>

projects/ui/src/lib/components/po-widget/po-widget.component.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,47 @@ describe('PoWidgetComponent with title and actions', () => {
928928
expect(footer).toBeFalsy();
929929
});
930930

931+
it('should add `po-widget-header__tag-top-actions` class when tagLabel, tagPosition is top and actions exist', () => {
932+
component.tagLabel = 'Sales';
933+
fixture.componentRef.setInput('p-tag-position', 'top');
934+
component.actions = [{ label: 'Test' }];
935+
936+
fixture.detectChanges();
937+
938+
expect(nativeElement.querySelector('.po-widget-header__tag-top-actions')).toBeTruthy();
939+
});
940+
941+
it('should not add `po-widget-header__tag-top-actions` class when tagPosition is not top', () => {
942+
component.tagLabel = 'Sales';
943+
fixture.componentRef.setInput('p-tag-position', 'right');
944+
component.actions = [{ label: 'Test' }];
945+
946+
fixture.detectChanges();
947+
948+
expect(nativeElement.querySelector('.po-widget-header__tag-top-actions')).toBeFalsy();
949+
});
950+
951+
it('should not add `po-widget-header__tag-top-actions` class when there are no actions', () => {
952+
component.tagLabel = 'Sales';
953+
fixture.componentRef.setInput('p-tag-position', 'top');
954+
component.help = undefined;
955+
component.actions = [];
956+
957+
fixture.detectChanges();
958+
959+
expect(nativeElement.querySelector('.po-widget-header__tag-top-actions')).toBeFalsy();
960+
});
961+
962+
it('should not add `po-widget-header__tag-top-actions` class when there is no tagLabel', () => {
963+
component.tagLabel = undefined;
964+
fixture.componentRef.setInput('p-tag-position', 'top');
965+
component.actions = [{ label: 'Test' }];
966+
967+
fixture.detectChanges();
968+
969+
expect(nativeElement.querySelector('.po-widget-header__tag-top-actions')).toBeFalsy();
970+
});
971+
931972
it('should find .po-widget-disabled if disabled is true', () => {
932973
component.disabled = true;
933974

0 commit comments

Comments
 (0)