Skip to content

Commit

Permalink
feat: Paginator & Table - Add option to customize dropdown icon prime…
Browse files Browse the repository at this point in the history
  • Loading branch information
kborzecki committed Jan 15, 2024
1 parent 0c28c0c commit 998c330
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/components/paginator/paginator.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export interface PaginatorState {
* @group Templates
*/
export interface PaginatorTemplates {
/**
* Custom dropdown trigger icon template.
*/
dropdownicon(): TemplateRef<any>
/**
* Custom first page link icon template.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/app/components/paginator/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ import { PaginatorState } from './paginator.interface';
[scrollHeight]="dropdownScrollHeight"
>
<ng-template pTemplate="selectedItem">{{ currentPageReport }}</ng-template>
<ng-template pTemplate="dropdownicon" *ngIf="dropdownIconTemplate">
<ng-container *ngTemplateOutlet="dropdownIconTemplate"></ng-container>
</ng-template>
</p-dropdown>
<button
type="button"
Expand Down Expand Up @@ -125,6 +128,9 @@ import { PaginatorState } from './paginator.interface';
<ng-container *ngTemplateOutlet="dropdownItemTemplate; context: { $implicit: item }"> </ng-container>
</ng-template>
</ng-container>
<ng-template pTemplate="dropdownicon" *ngIf="dropdownIconTemplate">
<ng-container *ngTemplateOutlet="dropdownIconTemplate"></ng-container>
</ng-template>
</p-dropdown>
<div class="p-paginator-right-content" *ngIf="templateRight" [attr.data-pc-section]="'end'">
<ng-container *ngTemplateOutlet="templateRight; context: { $implicit: paginatorState }"></ng-container>
Expand Down Expand Up @@ -261,6 +267,8 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges {

@ContentChildren(PrimeTemplate) templates: Nullable<QueryList<any>>;

dropdownIconTemplate: Nullable<TemplateRef<any>>;

firstPageLinkIconTemplate: Nullable<TemplateRef<any>>;

previousPageLinkIconTemplate: Nullable<TemplateRef<any>>;
Expand Down Expand Up @@ -309,6 +317,10 @@ export class Paginator implements OnInit, AfterContentInit, OnChanges {
ngAfterContentInit(): void {
(this.templates as QueryList<PrimeTemplate>).forEach((item) => {
switch (item.getType()) {
case 'dropdownicon':
this.dropdownIconTemplate = item.template;
break;

case 'firstpagelinkicon':
this.firstPageLinkIconTemplate = item.template;
break;
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/table/table.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ export interface TableTemplates {
* Custom paginator right template.
*/
paginatorright(): TemplateRef<any>;
/**
* Custom paginator dropdown trigger icon template.
*/
paginatordropdownicon(): TemplateRef<any>
/**
* Custom paginator dropdown item template.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export class TableService {
[styleClass]="paginatorStyleClass"
[locale]="paginatorLocale"
>
<ng-template pTemplate="dropdownicon" *ngIf="paginatorDropdownIconTemplate">
<ng-container *ngTemplateOutlet="paginatorDropdownIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="firstpagelinkicon" *ngIf="paginatorFirstPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorFirstPageLinkIconTemplate"></ng-container>
</ng-template>
Expand Down Expand Up @@ -278,6 +282,10 @@ export class TableService {
[styleClass]="paginatorStyleClass"
[locale]="paginatorLocale"
>
<ng-template pTemplate="dropdownicon" *ngIf="paginatorDropdownIconTemplate">
<ng-container *ngTemplateOutlet="paginatorDropdownIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="firstpagelinkicon" *ngIf="paginatorFirstPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorFirstPageLinkIconTemplate"></ng-container>
</ng-template>
Expand Down Expand Up @@ -1043,6 +1051,8 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable

headerCheckboxIconTemplate: Nullable<TemplateRef<any>>;

paginatorDropdownIconTemplate: Nullable<TemplateRef<any>>;

paginatorFirstPageLinkIconTemplate: Nullable<TemplateRef<any>>;

paginatorLastPageLinkIconTemplate: Nullable<TemplateRef<any>>;
Expand Down Expand Up @@ -1247,6 +1257,10 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable
this.paginatorRightTemplate = item.template;
break;

case 'paginatordropdownicon':
this.paginatorDropdownIconTemplate = item.template;
break;

case 'paginatordropdownitem':
this.paginatorDropdownItemTemplate = item.template;
break;
Expand Down

0 comments on commit 998c330

Please sign in to comment.