Skip to content

Commit

Permalink
fix(module:pagination): fix pagination nzTotal 0 bug (NG-ZORRO#3651)
Browse files Browse the repository at this point in the history
  • Loading branch information
vthinkxie authored Jun 25, 2019
1 parent 5629035 commit bd7233a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
8 changes: 0 additions & 8 deletions components/i18n/date-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import fnsFormat from 'date-fns/format';
import fnsGetISOWeek from 'date-fns/get_iso_week';
import fnsParse from 'date-fns/parse';

import { warnDeprecation } from 'ng-zorro-antd/core';

import { mergeDateConfig, NzDateConfig, NZ_DATE_CONFIG } from './date-config';
import { NzI18nService } from './nz-i18n.service';

Expand Down Expand Up @@ -87,16 +85,10 @@ export class DateHelperByDateFns extends DateHelperService {
*
* @see https://github.com/NG-ZORRO/ng-zorro-antd/issues/2406 - DatePipe may cause non-standard week bug, see:
*
* @deprecated 9.0.0 - `DateHelperByDatePipe` would be removed in 9.0.0 due to the serious bug above, unless it's get fixed.
* Please use `DateHelperByDateFns` instead.
*/
export class DateHelperByDatePipe extends DateHelperService {
constructor(i18n: NzI18nService, @Optional() @Inject(NZ_DATE_CONFIG) config: NzDateConfig) {
super(i18n, config);

warnDeprecation(
`'DateHelperByDatePipe' would be removed in 9.0.0 due to this serious bug of Angular: https://github.com/NG-ZORRO/ng-zorro-antd/issues/2406. Please use 'DateHelperByDateFns' instead.`
);
}

getISOWeek(date: Date): number {
Expand Down
2 changes: 1 addition & 1 deletion components/pagination/nz-pagination.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</a>
<a *ngIf="type=='page'">{{ page }}</a>
</ng-template>
<ng-container *ngIf="nzHideOnSinglePage && (nzTotal > nzPageSize) || !nzHideOnSinglePage">
<ng-container *ngIf="(nzHideOnSinglePage && (nzTotal > nzPageSize)) || (nzTotal && !nzHideOnSinglePage)">
<ul class="ant-pagination"
[class.ant-table-pagination]="nzInTable"
[class.ant-pagination-simple]="nzSimple"
Expand Down
5 changes: 5 additions & 0 deletions components/pagination/nz-pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ describe('pagination', () => {
expect(testComponent.pageIndex).toBe(5);
});
});
it('should zero total hide all', () => {
testComponent.total = 0;
fixture.detectChanges();
expect(pagination.nativeElement.innerText).toEqual('');
});
it('should be hidden pagination when total is 0 and nzHideOnSinglePage is true', () => {
(testComponent as NzTestPaginationComponent).total = 0;
(testComponent as NzTestPaginationComponent).hideOnSinglePage = true;
Expand Down

0 comments on commit bd7233a

Please sign in to comment.