Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,14 @@
</ul>
</div>
</div>
<div class="po-row po-footer-group">
<po-field-container-bottom
[p-additional-help-tooltip]="getAdditionalHelpTooltip()"
[p-append-in-body]="appendBox"
[p-help]="help"
[p-disabled]="disabled"
[p-error-limit]="errorLimit"
[p-error-pattern]="getErrorPattern()"
[p-hide-additional-help-by-label]="poHelper.hideAdditionalHelp"
[p-show-additional-help]="displayAdditionalHelp"
[p-show-additional-help-icon]="showAdditionalHelpIcon()"
[p-size]="size"
(p-additional-help)="emitAdditionalHelp()"
></po-field-container-bottom>
@if ((!label && poHelperComponent()) || (!label && poHelper.hideAdditionalHelp)) {
<po-helper
#helperEl
[p-size]="size"
[p-helper]="poHelper.helperSettings"
[p-disabled]="disabled"
[p-append-in-body]="appendBox"
>
</po-helper>
}
</div>
<po-field-container-bottom
[p-append-in-body]="appendBox"
[p-help]="help"
[p-disabled]="disabled"
[p-error-limit]="errorLimit"
[p-error-pattern]="getErrorPattern()"
[p-size]="size"
[p-helper]="!label ? poHelper.helperSettings : undefined"
[p-show-helper]="!label ? displayAdditionalHelp : undefined"
></po-field-container-bottom>
</po-field-container>
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@ export class PoCheckboxGroupComponent
return this.displayAdditionalHelp;
}

showAdditionalHelpIcon() {
return !!this.additionalHelpTooltip || this.isAdditionalHelpEventTriggered();
}

trackByFn(index) {
return index;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,28 +512,6 @@ describe('PoCheckboxComponent:', () => {
expect(component.showAdditionalHelp).not.toHaveBeenCalled();
});
});
describe('showAdditionalHelpIcon:', () => {
it('should return true when additionalHelpTooltip is truthy', () => {
(component as any).additionalHelpTooltip = 'additionalHelpTooltip';
spyOn(component as any, 'isAdditionalHelpEventTriggered').and.returnValue(false);

expect(component.showAdditionalHelpIcon()).toBeTrue();
});

it('should return true when additionalHelpTooltip is falsy but event is triggered', () => {
(component as any).additionalHelpTooltip = null;
spyOn(component as any, 'isAdditionalHelpEventTriggered').and.returnValue(true);

expect(component.showAdditionalHelpIcon()).toBeTrue();
});

it('should return false when additionalHelpTooltip is falsy and event not triggered', () => {
(component as any).additionalHelpTooltip = null;
spyOn(component as any, 'isAdditionalHelpEventTriggered').and.returnValue(false);

expect(component.showAdditionalHelpIcon()).toBeFalse();
});
});
});

describe('Templates:', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ export class PoCheckboxComponent extends PoCheckboxBaseComponent implements Afte
return this.displayAdditionalHelp;
}

showAdditionalHelpIcon() {
return !!this.additionalHelpTooltip || this.isAdditionalHelpEventTriggered();
}

setHelper(label?: string, additionalHelpTooltip?: string) {
return setHelperSettings(
label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,12 @@
}

<po-field-container-bottom
[p-additional-help-tooltip]="getAdditionalHelpTooltip()"
[p-append-in-body]="appendBox"
[p-help]="help"
[p-disabled]="disabled"
[p-error-pattern]="getErrorPattern()"
[p-error-limit]="errorLimit"
[p-hide-additional-help-by-label]="poHelper.hideAdditionalHelp"
[p-show-additional-help]="displayAdditionalHelp"
[p-show-additional-help-icon]="showAdditionalHelpIcon()"
[p-size]="size"
(p-additional-help)="emitAdditionalHelp()"
></po-field-container-bottom>
</po-field-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,6 @@ export class PoComboComponent extends PoComboBaseComponent implements AfterViewI
}
}

showAdditionalHelpIcon() {
return !!this.additionalHelpTooltip || this.isAdditionalHelpEventTriggered();
}

showMoreInfiniteScroll(): void {
if (this.defaultService.hasNext) {
this.infiniteLoading = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,12 @@

@if (!readonly) {
<po-field-container-bottom
[p-additional-help-tooltip]="getAdditionalHelpTooltip()"
[p-append-in-body]="appendBox"
[p-help]="help"
[p-disabled]="disabled"
[p-error-pattern]="getErrorMessage"
[p-error-limit]="errorLimit"
[p-hide-additional-help-by-label]="poHelper.hideAdditionalHelp"
[p-show-additional-help]="displayAdditionalHelp"
[p-show-additional-help-icon]="showAdditionalHelpIcon()"
[p-size]="size"
(p-additional-help)="emitAdditionalHelp()"
></po-field-container-bottom>
}
</po-field-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,6 @@ export class PoDatepickerRangeComponent
this.isDateRangeInputFormatValid = true;
}

showAdditionalHelpIcon() {
return !!this.additionalHelpTooltip || this.isAdditionalHelpEventTriggered();
}

/**
* Método que exibe `p-helper` ou executa a ação definida em `p-helper{eventOnClick}` ou em `p-additionalHelp`.
* Para isso, será necessário configurar uma tecla de atalho utilizando o evento `p-keydown`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,12 @@

@if (!readonly) {
<po-field-container-bottom
[p-additional-help-tooltip]="getAdditionalHelpTooltip()"
[p-append-in-body]="appendBox"
[p-help]="help"
[p-disabled]="disabled"
[p-error-pattern]="getErrorPattern()"
[p-error-limit]="errorLimit"
[p-hide-additional-help-by-label]="poHelper.hideAdditionalHelp"
[p-show-additional-help]="displayAdditionalHelp"
[p-show-additional-help-icon]="showAdditionalHelpIcon()"
[p-size]="size"
(p-additional-help)="emitAdditionalHelp()"
></po-field-container-bottom>
}
</po-field-container>
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,6 @@ export class PoDatepickerComponent extends PoDatepickerBaseComponent implements
return element.classList.contains('po-datepicker-calendar-overlay');
}

showAdditionalHelpIcon() {
return !!this.additionalHelpTooltip || this.isAdditionalHelpEventTriggered();
}

verifyErrorAsync(value) {
if (this.errorPattern !== '' && this.errorAsync) {
const errorAsync = this.errorAsync(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,12 @@

@if (!readonly) {
<po-field-container-bottom
[p-additional-help-tooltip]="getAdditionalHelpTooltip()"
[p-append-in-body]="appendBox"
[p-help]="help"
[p-disabled]="disabled"
[p-error-limit]="errorLimit"
[p-error-pattern]="getErrorPatternMessage()"
[p-hide-additional-help-by-label]="poHelper.hideAdditionalHelp"
[p-show-additional-help]="displayAdditionalHelp"
[p-show-additional-help-icon]="showAdditionalHelpIcon()"
[p-size]="size"
(p-additional-help)="emitAdditionalHelp()"
></po-field-container-bottom>
}
</po-field-container>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div
class="po-field-container-bottom"
class="po-field-container-bottom po-footer-group"
[class.po-field-container-bottom-disabled]="disabled"
[attr.aria-label]="errorPattern && errorLimit ? errorPattern : null"
[attr.p-size]="size"
Expand All @@ -21,25 +21,23 @@
</span>
</div>
}
@if (!errorPattern && (help || showAdditionalHelpIcon)) {
@if (!errorPattern && help) {
<div class="po-field-container-bottom-help-text">
@if (help) {
<span>
{{ help }}
</span>
}
@if (showAdditionalHelpIcon && !hideAdditionalHelpByLabel()) {
<div class="po-icon-container">
<po-icon
class="po-icon-additional-help"
[class.po-clickable]="!additionalHelpTooltip"
p-icon="an an-fill an an-info"
[p-append-in-body]="appendBox"
[p-tooltip]="additionalHelpTooltip"
(click)="additionalHelp.emit()"
></po-icon>
</div>
}
</div>
}
@if (poHelperComponent()) {
<po-helper
#helperEl
[p-size]="size"
[p-helper]="poHelperComponent()"
[p-disabled]="disabled"
[p-append-in-body]="appendBox"
>
</po-helper>
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,75 @@ describe('PoFieldContainerBottomComponent', () => {

beforeEach(() => {
changes = {
showAdditionalHelp: new SimpleChange(false, true, true)
showHelperComponent: new SimpleChange(false, true, false)
};

component.poTooltip = { toggleTooltipVisibility: jasmine.createSpy() } as any;
spyOn(component.additionalHelp, 'emit');
(component as any).helperEl = {
openHelperPopover: jasmine.createSpy('openHelperPopover'),
closeHelperPopover: jasmine.createSpy('closeHelperPopover')
} as any;

spyOn(component as any, 'poHelperComponent').and.returnValue({});
spyOn(component as any, 'showHelperComponent').and.returnValue(false);
});

describe('ngOnChanges', () => {
it('should emit `p-additional-help` event if `p-additional-help-tooltip` is not defined', () => {
(component as any).isInitialChange = false;
component.additionalHelpTooltip = null;
it('should call `eventOnClick` when `showHelperComponent()` is true and `eventOnClick` is a function', () => {
const eventOnClickSpy = jasmine.createSpy('eventOnClick');
(component as any).poHelperComponent.and.returnValue({ eventOnClick: eventOnClickSpy });
(component as any).showHelperComponent.and.returnValue(true);
component.ngOnChanges(changes);

expect(eventOnClickSpy).toHaveBeenCalled();
expect((component as any).helperEl.openHelperPopover).not.toHaveBeenCalled();
expect((component as any).helperEl.closeHelperPopover).not.toHaveBeenCalled();
});

it('should open the popover when `showHelperComponent()` is true and `eventOnClick` is not a function', () => {
(component as any).poHelperComponent.and.returnValue({ eventOnClick: undefined });
(component as any).showHelperComponent.and.returnValue(true);
component.ngOnChanges(changes);

expect((component as any).helperEl.openHelperPopover).toHaveBeenCalled();
expect((component as any).helperEl.closeHelperPopover).not.toHaveBeenCalled();
});

it('should open the popover when `showHelperComponent()` is true and `poHelperComponent()` returns null/undefined', () => {
(component as any).poHelperComponent.and.returnValue(undefined);
(component as any).showHelperComponent.and.returnValue(true);
component.ngOnChanges(changes);

expect(component.additionalHelp.emit).toHaveBeenCalled();
expect((component as any).helperEl.openHelperPopover).toHaveBeenCalled();
expect((component as any).helperEl.closeHelperPopover).not.toHaveBeenCalled();
});

it('should toggle the visibility of `p-additional-help-tooltip` is defined', () => {
(component as any).isInitialChange = false;
component.additionalHelpTooltip = 'Mensagem de apoio complementar.';
component.showAdditionalHelp = true;
it('should close the popover when `showHelperComponent()` is false', () => {
(component as any).showHelperComponent.and.returnValue(false);
component.ngOnChanges(changes);

expect(component.poTooltip.toggleTooltipVisibility).toHaveBeenCalledWith(true);
expect((component as any).helperEl.closeHelperPopover).toHaveBeenCalled();
expect((component as any).helperEl.openHelperPopover).not.toHaveBeenCalled();
});

it('should do nothing when `changes` does not contain `showHelperComponent`', () => {
const otherChanges: SimpleChanges = {
someOtherInput: new SimpleChange(undefined, 'x', false)
} as any;
component.ngOnChanges(otherChanges);

expect((component as any).helperEl.openHelperPopover).not.toHaveBeenCalled();
expect((component as any).helperEl.closeHelperPopover).not.toHaveBeenCalled();
});

it('should not emit the `p-additional-help` event or display `p-additional-help-tooltip` at initialization', () => {
(component as any).isInitialChange = true;
it('should not open/close the popover when `eventOnClick` is a function (since it returns after calling the function)', () => {
const eventOnClickSpy = jasmine.createSpy('eventOnClick');
(component as any).poHelperComponent.and.returnValue({ eventOnClick: eventOnClickSpy });
(component as any).showHelperComponent.and.returnValue(true);
component.ngOnChanges(changes);

expect(component.additionalHelp.emit).not.toHaveBeenCalled();
expect(component.poTooltip.toggleTooltipVisibility).not.toHaveBeenCalled();
expect(eventOnClickSpy).toHaveBeenCalled();
expect((component as any).helperEl.openHelperPopover).not.toHaveBeenCalled();
expect((component as any).helperEl.closeHelperPopover).not.toHaveBeenCalled();
});
});
});
Expand Down
Loading