Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dynamic-table): cria nova propriedade visibleFixedFilters #2323

Merged
merged 1 commit into from
Dec 13, 2024
Merged
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 @@ -183,4 +183,26 @@ describe('PoPageDynamicSearchBaseComponent:', () => {
expect(component.advancedFilterLiterals).toEqual(expectedValue);
});
});

describe('p-visible-fixed-filters:', () => {
it('should update `_visibleFixedFilters` when `visibleFixedFilters` is set', () => {
component.visibleFixedFilters = true;
expect(component['_visibleFixedFilters']).toBe(true);

component.visibleFixedFilters = false;
expect(component['_visibleFixedFilters']).toBe(false);
});

it('should return `_visibleFixedFilters` when `visibleFixedFilters` is accessed', () => {
component['_visibleFixedFilters'] = true;
expect(component.visibleFixedFilters).toBe(true);

component['_visibleFixedFilters'] = false;
expect(component.visibleFixedFilters).toBe(false);
});

it('should have a default value of `true` for `visibleFixedFilters` if not set', () => {
expect(component.visibleFixedFilters).toBeTrue();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,34 @@ export abstract class PoPageDynamicSearchBaseComponent {
*/
@Input('p-quick-search-value') quickSearchValue: string;

_visibleFixedFilters = true;

/**
* @optional
*
* @description
*
* Controla a visibilidade dos filtros fixos na página.
*
* - Quando `true` (default), todos os filtros, incluindo os fixos, são exibidos, permitindo que o usuário visualize os filtros aplicados.
* - Quando `false`, os filtros fixos são ocultados, não sendo exibidos na interface, mas ainda sendo aplicados como filtros nas requisições.
*
* Esta propriedade trabalha em conjunto com a propriedade `fixed` dos filtros individuais. Filtros marcados como `fixed: true` não serão exibidos na interface do filtro avançado quando `visibleFixedFilters` for `false`, mas continuarão a ser aplicados de forma transparente ao usuário. Dessa forma, permite-se maior flexibilidade no controle de quais filtros devem ser visíveis ao usuário ou devem ser aplicados permanentemente sem interferência.
*
* **Exemplo de uso:**
* ```html
* <!-- Para ocultar os filtros fixos -->
* <po-page-dynamic-table [p-visible-fixed-filters]="false"></po-page-dynamic-table>
* ```
*/
@Input('p-visible-fixed-filters') set visibleFixedFilters(visible: boolean) {
this._visibleFixedFilters = visible;
}

get visibleFixedFilters(): boolean {
return this._visibleFixedFilters;
}

/**
* @optional
*
Expand Down Expand Up @@ -189,10 +217,10 @@ export abstract class PoPageDynamicSearchBaseComponent {
private _hideCloseDisclaimers: Array<string> = [];
private _literals: PoPageDynamicSearchLiterals;
private _quickSearchWidth: number;

private previousFilters: Array<PoDynamicFormField>;
private language: string;

previousFilters: Array<PoDynamicFormField>;

/**
* @optional
*
Expand Down Expand Up @@ -258,12 +286,6 @@ export abstract class PoPageDynamicSearchBaseComponent {
*/
@Input('p-filters') set filters(filters: Array<PoPageDynamicSearchFilters>) {
this._filters = Array.isArray(filters) ? [...filters] : [];

if (this.stringify(this._filters) !== this.stringify(this.previousFilters)) {
this.onChangeFilters(this.filters);

this.previousFilters = [...this._filters];
}
}

get filters(): Array<PoPageDynamicSearchFilters> {
Expand Down Expand Up @@ -320,7 +342,7 @@ export abstract class PoPageDynamicSearchBaseComponent {
};
}

private stringify(columns: Array<PoPageDynamicSearchFilters>) {
stringify(columns: Array<PoPageDynamicSearchFilters>) {
// não faz o stringify da propriedade searchService, pois pode conter objeto complexo e disparar um erro.
return JSON.stringify(columns, (key, value) => {
if (key !== 'searchService') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ export interface PoPageDynamicSearchFilters extends PoDynamicFormField {
* Define um valor inicial para um filtro de busca avançada.
*/
initValue?: any;

/**
* Define um valor fixed para um filtro de busca avançada.
*/
fixed?: boolean;
}
Loading
Loading