-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(module:pagination): refactor pagination to support OnPush (#…
- Loading branch information
Showing
6 changed files
with
196 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,133 +1,111 @@ | ||
<ng-template #renderItemTemplate let-type let-page="page"> | ||
<a class="ant-pagination-item-link" *ngIf="type==='pre'"><i nz-icon type="left"></i></a> | ||
<a class="ant-pagination-item-link" *ngIf="type==='next'"><i nz-icon type="right"></i></a> | ||
<a *ngIf="type=='page'">{{page}}</a> | ||
<a *ngIf="type=='page'">{{ page }}</a> | ||
</ng-template> | ||
<ng-container *ngIf="(nzHideOnSinglePage&&(nzTotal>nzPageSize))||!nzHideOnSinglePage"> | ||
<ul | ||
*ngIf="nzSimple" | ||
<ng-container *ngIf="nzHideOnSinglePage && (nzTotal > nzPageSize) || !nzHideOnSinglePage"> | ||
<ul class="ant-pagination" | ||
[class.ant-table-pagination]="nzInTable" | ||
class="ant-pagination ant-pagination-simple"> | ||
<li | ||
title="{{ locale.prev_page }}" | ||
class="ant-pagination-prev" | ||
(click)="jumpPreOne()" | ||
[class.ant-pagination-disabled]="isFirstIndex"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'pre'}"></ng-template> | ||
</li> | ||
<li [attr.title]="nzPageIndex+'/'+lastIndex" class="ant-pagination-simple-pager"> | ||
<input | ||
#simplePagerInput | ||
[ngModel]="nzPageIndex" | ||
(keydown.enter)="handleKeyDown($event,simplePagerInput,false)" | ||
size="3"> | ||
<span class="ant-pagination-slash">/</span> | ||
{{ lastIndex }} | ||
</li> | ||
<li | ||
title="{{ locale.next_page }}" | ||
class="ant-pagination-next" | ||
(click)="jumpNextOne()" | ||
[class.ant-pagination-disabled]="isLastIndex"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'next'}"></ng-template> | ||
</li> | ||
</ul> | ||
<ul | ||
*ngIf="!nzSimple" | ||
[class.mini]="nzSize=='small'" | ||
[class.ant-table-pagination]="nzInTable" | ||
class="ant-pagination"> | ||
<li class="ant-pagination-total-text" *ngIf="nzShowTotal"> | ||
<ng-template | ||
[ngTemplateOutlet]="nzShowTotal" | ||
[ngTemplateOutletContext]="{ $implicit: nzTotal,range:[(nzPageIndex-1)*nzPageSize+1, min(nzPageIndex*nzPageSize, nzTotal)] }"> | ||
</ng-template> | ||
</li> | ||
<li | ||
title="{{ locale.prev_page }}" | ||
class="ant-pagination-prev" | ||
(click)="jumpPreOne()" | ||
[class.ant-pagination-disabled]="isFirstIndex"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'pre'}"></ng-template> | ||
</li> | ||
<li | ||
[attr.title]="firstIndex" | ||
class="ant-pagination-item" | ||
(click)="jumpPage(firstIndex)" | ||
[class.ant-pagination-item-active]="isFirstIndex"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'page',page: firstIndex }"></ng-template> | ||
</li> | ||
<li | ||
[attr.title]="locale.prev_5" | ||
(click)="jumpPreFive()" | ||
class="ant-pagination-jump-prev" | ||
*ngIf="(lastIndex >9)&&(nzPageIndex-3>firstIndex)"> | ||
<a class="ant-pagination-item-link"> | ||
<div class="ant-pagination-item-container"> | ||
<i nz-icon type="double-left" class="ant-pagination-item-link-icon"></i> | ||
<span class="ant-pagination-item-ellipsis">•••</span> | ||
</div> | ||
</a> | ||
</li> | ||
<li | ||
*ngFor="let page of pages" | ||
[attr.title]="page.index" | ||
class="ant-pagination-item" | ||
(click)="jumpPage(page.index)" | ||
[class.ant-pagination-item-active]="nzPageIndex==page.index"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'page',page: page.index }"></ng-template> | ||
</li> | ||
<li | ||
[attr.title]="locale.next_5" | ||
(click)="jumpNextFive()" | ||
class="ant-pagination-jump-next ant-pagination-item-link-icon" | ||
*ngIf="(lastIndex >9)&&(nzPageIndex+3<lastIndex)"> | ||
<a class="ant-pagination-item-link"> | ||
<div class="ant-pagination-item-container"> | ||
<i nz-icon type="double-right" class="ant-pagination-item-link-icon"></i> | ||
<span class="ant-pagination-item-ellipsis">•••</span> | ||
[class.ant-pagination-simple]="nzSimple" | ||
[class.mini]="(nzSize === 'small') && !nzSimple"> | ||
<ng-container *ngIf="nzSimple; else normalTemplate"> | ||
<li class="ant-pagination-prev" | ||
[attr.title]="locale.prev_page" | ||
[class.ant-pagination-disabled]="isFirstIndex" | ||
(click)="jumpDiff(-1)"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'pre'}"></ng-template> | ||
</li> | ||
<li [attr.title]="nzPageIndex+'/'+lastIndex" class="ant-pagination-simple-pager"> | ||
<input #simplePagerInput [value]="nzPageIndex" (keydown.enter)="handleKeyDown($event,simplePagerInput,false)" size="3"> | ||
<span class="ant-pagination-slash">/</span> | ||
{{ lastIndex }} | ||
</li> | ||
<li class="ant-pagination-next" | ||
[attr.title]="locale.next_page" | ||
[class.ant-pagination-disabled]="isLastIndex" | ||
(click)="jumpDiff(1)"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'next'}"></ng-template> | ||
</li> | ||
</ng-container> | ||
<ng-template #normalTemplate> | ||
<li class="ant-pagination-total-text" *ngIf="nzShowTotal"> | ||
<ng-template [ngTemplateOutlet]="nzShowTotal" [ngTemplateOutletContext]="{ $implicit: nzTotal,range:ranges }"></ng-template> | ||
</li> | ||
<li class="ant-pagination-prev" | ||
[attr.title]="locale.prev_page" | ||
[class.ant-pagination-disabled]="isFirstIndex" | ||
(click)="jumpDiff(-1)"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'pre'}"></ng-template> | ||
</li> | ||
<li class="ant-pagination-item" | ||
[attr.title]="firstIndex" | ||
[class.ant-pagination-item-active]="isFirstIndex" | ||
(click)="jumpPage(firstIndex)"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'page',page: firstIndex }"></ng-template> | ||
</li> | ||
<li class="ant-pagination-jump-prev" | ||
*ngIf="(lastIndex > 9) && (nzPageIndex - 3 > firstIndex)" | ||
[attr.title]="locale.prev_5" | ||
(click)="jumpDiff(-5)"> | ||
<a class="ant-pagination-item-link"> | ||
<div class="ant-pagination-item-container"> | ||
<i nz-icon type="double-left" class="ant-pagination-item-link-icon"></i> | ||
<span class="ant-pagination-item-ellipsis">•••</span> | ||
</div> | ||
</a> | ||
</li> | ||
<li class="ant-pagination-item" | ||
*ngFor="let page of pages" | ||
[attr.title]="page" | ||
[class.ant-pagination-item-active]="nzPageIndex === page" | ||
(click)="jumpPage(page)"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'page',page: page }"></ng-template> | ||
</li> | ||
<li class="ant-pagination-jump-next ant-pagination-item-link-icon" | ||
[attr.title]="locale.next_5" | ||
(click)="jumpDiff(5)" | ||
*ngIf="(lastIndex > 9) && (nzPageIndex + 3 < lastIndex)"> | ||
<a class="ant-pagination-item-link"> | ||
<div class="ant-pagination-item-container"> | ||
<i nz-icon type="double-right" class="ant-pagination-item-link-icon"></i> | ||
<span class="ant-pagination-item-ellipsis">•••</span> | ||
</div> | ||
</a> | ||
</li> | ||
<li class="ant-pagination-item" | ||
[attr.title]="lastIndex" | ||
(click)="jumpPage(lastIndex)" | ||
*ngIf="(lastIndex > 0) && (lastIndex !== firstIndex)" | ||
[class.ant-pagination-item-active]="isLastIndex"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'page',page: lastIndex }"></ng-template> | ||
</li> | ||
<li class="ant-pagination-next" | ||
[title]="locale.next_page" | ||
[class.ant-pagination-disabled]="isLastIndex" | ||
(click)="jumpDiff(1)"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'next'}"></ng-template> | ||
</li> | ||
<div class="ant-pagination-options" *ngIf="nzShowQuickJumper || nzShowSizeChanger"> | ||
<nz-select class="ant-pagination-options-size-changer" | ||
*ngIf="nzShowSizeChanger" | ||
[nzSize]="nzSize" | ||
[ngModel]="nzPageSize" | ||
(ngModelChange)="onPageSizeChange($event)"> | ||
<nz-option *ngFor="let option of nzPageSizeOptions" | ||
[nzLabel]="option + locale.items_per_page" | ||
[nzValue]="option"> | ||
</nz-option> | ||
<nz-option *ngIf="showAddOption" | ||
[nzLabel]="nzPageSize + locale.items_per_page" | ||
[nzValue]="nzPageSize"> | ||
</nz-option> | ||
</nz-select> | ||
<div class="ant-pagination-options-quick-jumper" *ngIf="nzShowQuickJumper"> | ||
{{ locale.jump_to }} | ||
<input #quickJumperInput (keydown.enter)="handleKeyDown($event,quickJumperInput,true)"> | ||
{{ locale.page }} | ||
</div> | ||
</a> | ||
</li> | ||
<li | ||
[attr.title]="lastIndex" | ||
class="ant-pagination-item" | ||
(click)="jumpPage(lastIndex)" | ||
*ngIf="(lastIndex>0)&&(lastIndex!==firstIndex)" | ||
[class.ant-pagination-item-active]="isLastIndex"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'page',page: lastIndex }"></ng-template> | ||
</li> | ||
<li | ||
title="{{ locale.next_page }}" | ||
class="ant-pagination-next" | ||
(click)="jumpNextOne()" | ||
[class.ant-pagination-disabled]="isLastIndex"> | ||
<ng-template [ngTemplateOutlet]="nzItemRender" [ngTemplateOutletContext]="{ $implicit: 'next'}"></ng-template> | ||
</li> | ||
<div class="ant-pagination-options" *ngIf="nzShowQuickJumper||nzShowSizeChanger"> | ||
<nz-select | ||
*ngIf="nzShowSizeChanger" | ||
[nzSize]="nzSize=='small'?'small':''" | ||
class="ant-pagination-options-size-changer" | ||
[ngModel]="nzPageSize" | ||
(ngModelChange)="onPageSizeChange($event)"> | ||
<nz-option | ||
*ngFor="let option of nzPageSizeOptions" | ||
[nzLabel]="option + locale.items_per_page" | ||
[nzValue]="option"> | ||
</nz-option> | ||
<nz-option | ||
*ngIf="nzPageSizeOptions.indexOf(nzPageSize)==-1" | ||
[nzLabel]="nzPageSize + locale.items_per_page" | ||
[nzValue]="nzPageSize"> | ||
</nz-option> | ||
</nz-select> | ||
<div class="ant-pagination-options-quick-jumper" | ||
*ngIf="nzShowQuickJumper"> | ||
{{ locale.jump_to }} | ||
<input #quickJumperInput (keydown.enter)="handleKeyDown($event,quickJumperInput,true)"> | ||
{{ locale.page }} | ||
</div> | ||
</div> | ||
</ng-template> | ||
</ul> | ||
</ng-container> |
Oops, something went wrong.