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

fix(module:pagination): fix pagination nzTotal 0 bug #3651

Merged
merged 1 commit into from
Jun 25, 2019
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
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