From 76e35b6e5415d808286a56646bebd518ac495c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Mon, 27 May 2024 12:41:46 +0300 Subject: [PATCH] Fixed #15703 | Table: use Button component for all filter buttons && add filterButtonProps --- src/app/components/table/table.interface.ts | 48 +++++++++++ src/app/components/table/table.ts | 92 +++++++++++++++++---- 2 files changed, 125 insertions(+), 15 deletions(-) diff --git a/src/app/components/table/table.interface.ts b/src/app/components/table/table.interface.ts index c33e01bd3e4..9e47e02b0c8 100644 --- a/src/app/components/table/table.interface.ts +++ b/src/app/components/table/table.interface.ts @@ -1,6 +1,7 @@ import { FilterMetadata, LazyLoadMeta, TableState } from 'primeng/api'; import { Table } from './table'; import { TemplateRef } from '@angular/core'; +import { ButtonProps } from 'primeng/button'; /** * Custom select event. * @see {@link Table.onRowSelect} @@ -254,6 +255,53 @@ export interface TableSelectAllChangeEvent { */ checked: boolean; } +/** + * Custom table filter popover button props options. + */ +export interface TableFilterButtonPopoverPropsOptions { + /** + * Add rule button props + */ + addRule: ButtonProps | undefined; + /** + * Remove rule button props + */ + removeRule: ButtonProps | undefined; + /** + * Apply button props + */ + apply: ButtonProps | undefined; + /** + * Apply button props + */ + clear: ButtonProps | undefined; +} +/** + * Custom table filter inline button props options. + */ +export interface TableFilterButtonInlinePropsOptions { + /** + * Apply button props + */ + clear: ButtonProps | undefined; +} +/** + * Custom table filter buttons' props options. + */ +export interface TableFilterButtonPropsOptions { + /** + * Filter button props + */ + filter: ButtonProps | undefined; + /** + * Inline filter buttons' options + */ + inline: TableFilterButtonInlinePropsOptions | undefined; + /** + * Popover filter buttons' options + */ + popover: TableFilterButtonPopoverPropsOptions | undefined; +} /** * Custom CSV export options. */ diff --git a/src/app/components/table/table.ts b/src/app/components/table/table.ts index cb7b0610d56..2fb6c03aed7 100644 --- a/src/app/components/table/table.ts +++ b/src/app/components/table/table.ts @@ -33,7 +33,7 @@ import { } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { BlockableUI, FilterMatchMode, FilterMetadata, FilterOperator, FilterService, LazyLoadMeta, OverlayService, PrimeNGConfig, PrimeTemplate, ScrollerOptions, SelectItem, SharedModule, SortMeta, TableState, TranslationKeys } from 'primeng/api'; -import { ButtonModule } from 'primeng/button'; +import { Button, ButtonModule } from 'primeng/button'; import { CalendarModule } from 'primeng/calendar'; import { ConnectedOverlayScrollHandler, DomHandler } from 'primeng/dom'; import { DropdownModule } from 'primeng/dropdown'; @@ -58,6 +58,7 @@ import { Nullable, VoidListener } from 'primeng/ts-helpers'; import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primeng/utils'; import { Subject, Subscription } from 'rxjs'; import { + TableFilterButtonPropsOptions, ExportCSVOptions, TableColResizeEvent, TableColumnReorderEvent, @@ -5016,11 +5017,11 @@ export class ReorderableRow implements AfterViewInit { [useGrouping]="useGrouping" [showButtons]="showButtons" > - - +
- +
- +
- - + +
@@ -5265,6 +5300,33 @@ export class ColumnFilter implements AfterContentInit { * @group Props */ @Input() ariaLabel: string | undefined; + /** + * Used to pass all filter button property object + * @defaultValue { + filter: { severity: 'secondary', text: true, rounded: true }, + inline: { + clear: { severity: 'secondary', text: true, rounded: true } + }, + popover: { + addRule: { severity: 'info', text: true, size: 'small' }, + removeRule: { severity: 'danger', text: true, size: 'small' }, + apply: { size: 'small' }, + clear: { outlined: true, size: 'small' } + } + } + */ + @Input() filterButtonProps: TableFilterButtonPropsOptions = { + filter: { severity: 'secondary', text: true, rounded: true }, + inline: { + clear: { severity: 'secondary', text: true, rounded: true } + }, + popover: { + addRule: { severity: 'info', text: true, size: 'small' }, + removeRule: { severity: 'danger', text: true, size: 'small' }, + apply: { size: 'small' }, + clear: { outlined: true, size: 'small' } + } + }; /** * Callback to invoke on overlay is shown. * @param {AnimationEvent} originalEvent - animation event. @@ -5278,7 +5340,7 @@ export class ColumnFilter implements AfterContentInit { */ @Output() onHide: EventEmitter<{ originalEvent: AnimationEvent }> = new EventEmitter<{ originalEvent: AnimationEvent }>(); - @ViewChild('icon') icon: Nullable; + @ViewChild(Button, { static: false, read: ElementRef }) icon: ElementRef | undefined; @ViewChild('clearBtn') clearButtonViewChild: Nullable;